his_api_controller.go 1.6MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981
  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. //
  7429. // timeLayout := "2006-01-02"
  7430. // loc, _ := time.LoadLocation("Local")
  7431. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7432. // if err != nil {
  7433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7434. // return
  7435. // }
  7436. // recordDateTime := theTime.Unix()
  7437. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7438. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7439. //
  7440. // //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7441. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7442. //
  7443. // //dept, _ := service.GetDepartMentDetail(info.Departments)
  7444. //
  7445. // for _, item := range prescriptions {
  7446. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7447. // if his.IdCardType == 1 {
  7448. // bas := strings.Split(psn.CardInfo, "|")
  7449. // basNumber := bas[1]
  7450. // fmt.Println(basNumber)
  7451. // card_sn := bas[3]
  7452. // card_no := bas[2]
  7453. // cFYLJG001.MdtrtCertType = "03"
  7454. // cFYLJG001.CardSn = card_sn
  7455. // cFYLJG001.MdtrtCertNo = card_no
  7456. // cFYLJG001.EcToken = ""
  7457. // cFYLJG001.AuthNo = ""
  7458. // } else if his.IdCardType == 2 {
  7459. // cFYLJG001.MdtrtCertType = "02"
  7460. // cFYLJG001.CardSn = ""
  7461. // cFYLJG001.MdtrtCertNo = his.IdCardNo
  7462. // cFYLJG001.EcToken = ""
  7463. // cFYLJG001.AuthNo = ""
  7464. // } else if his.IdCardType == 4 {
  7465. // cFYLJG001.MdtrtCertType = "01"
  7466. // cFYLJG001.CardSn = ""
  7467. // cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7468. // cFYLJG001.EcToken = psn.VerifyNumber
  7469. // cFYLJG001.AuthNo = ""
  7470. // }
  7471. // cFYLJG001.BizTypeCode = "01"
  7472. // cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7473. // cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7474. // cFYLJG001.RxTypeCode = "1"
  7475. // tempTime := time.Unix(item.PreTime, 0)
  7476. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7477. // cFYLJG001.PrscTime = timeFormatOne
  7478. // var count float64
  7479. // if item.Type == 1 {
  7480. // for _, sumItem := range item.HisDoctorAdviceInfo {
  7481. // count = count + sumItem.PrescribingNumber
  7482. // }
  7483. // }
  7484. // cFYLJG001.RxDrugCnt = count
  7485. // cFYLJG001.ValiDays = "5"
  7486. // ts := time.Unix(item.PreTime, 0)
  7487. // record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7488. // tempTime3 := time.Unix(record_time2, 0)
  7489. // timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7490. // cFYLJG001.ValiEndTime = timeFormat3
  7491. // cFYLJG001.RxCotnFlag = "0"
  7492. // for _, subItem := range item.HisDoctorAdviceInfo {
  7493. // var drug models.RxDrug
  7494. // drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7495. // drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7496. // drug.RxItemTypeCode = "11"
  7497. //
  7498. // drug.DrugDosform = "乳膏剂" //TODO
  7499. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7500. // drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7501. // }
  7502. //
  7503. // drug.MedcWayDscr = subItem.DeliveryWay
  7504. //
  7505. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7506. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7507. // drug.MedcBegntime = timeFormatTwo
  7508. // if subItem.Day > 0 {
  7509. // ts := time.Unix(subItem.StartTime, 0)
  7510. // record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7511. // tempTime4 := time.Unix(record_time, 0)
  7512. // timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7513. // drug.MedcEndtime = timeFormat5
  7514. // } else {
  7515. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7516. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7517. // drug.MedcEndtime = timeFormatTwo
  7518. // }
  7519. //
  7520. // drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7521. // drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7522. // drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7523. // drug.DrugCnt = subItem.PrescribingNumber
  7524. // drug.DrugDosunt = subItem.PrescribingNumberUnit
  7525. // drug.DrugGenname = subItem.AdviceName
  7526. // drug.MedcWayCodg = subItem.DeliveryWay
  7527. // //drug.DrugTotlcnt = subItem.PrescribingNumber
  7528. // drug.SinDoscnt = subItem.SingleDose
  7529. // drug.SinDosunt = subItem.SingleDoseUnit
  7530. // drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7531. // drug.UsedFrquName = subItem.ExecutionFrequency
  7532. // drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7533. // drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7534. // drug.HospApprFlag = "1"
  7535. // cFYLJG001.List = append(cFYLJG001.List, drug)
  7536. // }
  7537. // cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7538. // cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7539. // cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7540. // cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7541. // cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7542. // cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7543. // cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7544. // cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7545. // cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7546. // cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7547. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7548. // cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7549. // cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7550. // cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7551. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7552. // cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7553. // cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7554. // cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7555. // cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7556. // cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7557. // cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7558. // cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7559. // cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7560. // cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7561. // tempTime2 := time.Now().Unix()
  7562. // tempTime6 := time.Unix(tempTime2, 0)
  7563. // timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7564. // cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7565. // cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7566. // cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7567. // cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7568. // cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7569. //
  7570. // //memo := make(map[string]interface{})
  7571. // //inputData := make(map[string]interface{}, 0)
  7572. //
  7573. // //type MyData struct {
  7574. // // Insutype string `json:"insutype"`
  7575. // //}
  7576. // //
  7577. // // data := MyData{
  7578. // // Insutype: his.Insutype,
  7579. // //}
  7580. // //
  7581. //
  7582. // diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7583. // var config []*models.HisXtDiagnoseConfig
  7584. // for _, item := range diagnosis_ids {
  7585. // id, _ := strconv.ParseInt(item, 10, 64)
  7586. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7587. // config = append(config, &diagnosisConfig)
  7588. // }
  7589. // for index, subitem := range config {
  7590. // if index == 0 {
  7591. // var dia models.DiseInfo
  7592. // dia.DiagType = "1"
  7593. // dia.MaindiagFlag = "1"
  7594. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7595. // dia.DiagCode = subitem.CountryCode
  7596. // dia.DiagName = subitem.ClassName
  7597. // dia.DiagDept = "肾内科"
  7598. // dia.DiagDrNo = doctor.DoctorNumber
  7599. // dia.DiagDrName = doctor.UserName
  7600. // tempTime3 := time.Unix(item.PreTime, 0)
  7601. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7602. // dia.DiagTime = timeFormatTwo
  7603. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7604. // } else {
  7605. // var dia models.DiseInfo
  7606. // dia.DiagType = "1"
  7607. // dia.MaindiagFlag = "0"
  7608. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7609. // dia.DiagCode = subitem.CountryCode
  7610. // dia.DiagName = subitem.ClassName
  7611. // dia.DiagDept = "肾内科"
  7612. // dia.DiagDrNo = doctor.DoctorNumber
  7613. // dia.DiagDrName = doctor.UserName
  7614. // tempTime3 := time.Unix(item.PreTime, 0)
  7615. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7616. // dia.DiagTime = timeFormatTwo
  7617. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7618. // }
  7619. // }
  7620. // if miConfig.MdtrtareaAdmvs == "340699" {
  7621. // //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7622. // //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7623. //
  7624. // } else {
  7625. // result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7626. // saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7627. //
  7628. // }
  7629. //
  7630. // var res ResultCFYLJG001
  7631. // var respJSON2 map[string]interface{}
  7632. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7633. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7635. // return
  7636. // }
  7637. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7638. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7639. // utils.ErrorLog("解析失败:%v", err)
  7640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. // return
  7642. // }
  7643. // if res.Infcode == -1 {
  7644. // c.ServeSuccessJSON(map[string]interface{}{
  7645. // "failed_code": -10,
  7646. // "msg": res.ErrMsg,
  7647. // })
  7648. // return
  7649. //
  7650. // } else {
  7651. // var flow models.HisPrescriptionFlow
  7652. // flow.Ctime = time.Now().Unix()
  7653. // flow.SignDigest = ""
  7654. // flow.RxTraceCode = res.Output.RxTraceCode
  7655. // flow.HiRxno = res.Output.HiRxno
  7656. // flow.MID = his.Number
  7657. // flow.Status = 1
  7658. // flow.DCode = doctor_info.DoctorNumber
  7659. // flow.OriginalRxFile = ""
  7660. // flow.OriginalValue = ""
  7661. // flow.SignCertDn = ""
  7662. // flow.UserOrgId = 10454
  7663. // flow.SignCertSn = ""
  7664. // flow.Mtime = time.Now().Unix()
  7665. //
  7666. // service.Createflow(&flow)
  7667. // c.ServeSuccessJSON(map[string]interface{}{
  7668. // "msg": "上传成功",
  7669. // })
  7670. // }
  7671. // }
  7672. //}
  7673. //func (c *HisApiController) GetCFYLJG002() {
  7674. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7675. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7676. // record_time := c.GetString("record_time")
  7677. // admin_user_id = 3626
  7678. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7679. // //id, _ := c.GetInt64("id")
  7680. // admin_user_id = 3626
  7681. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7682. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7683. //
  7684. // flow, _ := service.Getflowtwo(his.Number)
  7685. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  7686. // //record_time := c.GetString("record_time")
  7687. // patient_id, _ := c.GetInt64("patient_id")
  7688. // //patient_id = 23834
  7689. // //record_time = "2023-09-18"
  7690. // timeLayout := "2006-01-02"
  7691. // loc, _ := time.LoadLocation("Local")
  7692. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7693. // if err != nil {
  7694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7695. // return
  7696. // }
  7697. // recordDateTime := theTime.Unix()
  7698. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7699. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7700. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7701. //
  7702. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7703. //
  7704. // inputData := make(map[string]interface{})
  7705. // inputData["rxTraceCode"] = flow.RxTraceCode
  7706. // inputData["hiRxno"] = flow.HiRxno
  7707. // inputData["mdtrtId"] = flow.MID
  7708. // inputData["patnName"] = his.PsnName
  7709. // inputData["psnCertType"] = his.PsnCertType
  7710. // inputData["certno"] = his.Certno
  7711. // inputData["fixmedinsName"] = miConfig.OrgName
  7712. // inputData["fixmedinsCode"] = miConfig.Code
  7713. // inputData["drCode"] = doctor_info.DoctorNumber
  7714. // inputData["prscDrName"] = doctor_info.UserName
  7715. // inputData["pharDeptName"] = dept.Name
  7716. // inputData["pharDeptCode"] = dept.Number
  7717. // inputData["pharProfttlCodg"] = dept.Name
  7718. // inputData["pharProfttlName"] = ""
  7719. // inputData["pharCode"] = "HY440309002107"
  7720. // inputData["pharCertType"] = "01"
  7721. // inputData["pharCertno"] = "430482199408260023"
  7722. // inputData["pharName"] = "彭斯遥"
  7723. // inputData["pharPracCertNo"] = ""
  7724. // tempTime2 := time.Unix(info.Ctime, 0)
  7725. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7726. // inputData["pharChkTime"] = timeFormatTwo
  7727. //
  7728. // bytesData, _ := json.Marshal(inputData)
  7729. // fmt.Println(string(bytesData))
  7730. // encoded := base64.StdEncoding.EncodeToString(bytesData)
  7731. // pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7732. // if err != nil {
  7733. // fmt.Println("Error reading PDF file:", err)
  7734. // return
  7735. // }
  7736. //
  7737. // // 将 PDF 文件内容进行 Base64 编码
  7738. // rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7739. //
  7740. // fmt.Println(err)
  7741. //
  7742. // if miConfig.MdtrtareaAdmvs == "340699" {
  7743. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7744. // //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7745. //
  7746. // } else {
  7747. // result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7748. // //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7749. // saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7750. //
  7751. // }
  7752. //
  7753. // var res2 Result002
  7754. // var respJSON2 map[string]interface{}
  7755. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7756. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. // return
  7759. // }
  7760. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7761. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7762. // utils.ErrorLog("解析失败:%v", err)
  7763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. // return
  7765. // }
  7766. // if res2.Infcode == 0 {
  7767. // flow.Ctime = time.Now().Unix()
  7768. // flow.SignDigest = res2.Output.SignDigest
  7769. // flow.RxFile = res2.Output.RxFile
  7770. // flow.MID = his.Number
  7771. // flow.Status = 1
  7772. // flow.DCode = doctor_info.DoctorNumber
  7773. // flow.OriginalRxFile = rx_encoded
  7774. // flow.OriginalValue = encoded
  7775. // flow.SignCertDn = res2.Output.SignCertDn
  7776. // flow.SignCertSn = res2.Output.SignCertSn
  7777. // flow.Mtime = time.Now().Unix()
  7778. // service.Saveflow(flow)
  7779. // c.ServeSuccessJSON(map[string]interface{}{
  7780. // "msg": "预签名成功",
  7781. // })
  7782. // } else {
  7783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7784. // return
  7785. // }
  7786. //}
  7787. //func (c *HisApiController) GetCFYLJG003() {
  7788. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7789. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7790. // record_time := c.GetString("record_time")
  7791. // admin_user_id = 3626
  7792. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7793. // //id, _ := c.GetInt64("id")
  7794. // admin_user_id = 3626
  7795. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7796. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7797. //
  7798. // flow, _ := service.Getflowtwo(his.Number)
  7799. // //id = 3
  7800. // patient_id, _ := c.GetInt64("patient_id")
  7801. // //patient_id = 23834
  7802. // //record_time = "2023-09-18"
  7803. // timeLayout := "2006-01-02"
  7804. // loc, _ := time.LoadLocation("Local")
  7805. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7806. // if err != nil {
  7807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7808. // return
  7809. // }
  7810. // recordDateTime := theTime.Unix()
  7811. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7812. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7813. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7814. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7815. //
  7816. // //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7817. //
  7818. // var cFYLJG003 models.CFYLJG003
  7819. //
  7820. // cFYLJG003.RxTraceCode = flow.RxTraceCode
  7821. // cFYLJG003.HiRxno = flow.HiRxno
  7822. // cFYLJG003.MdtrtID = flow.MID
  7823. // cFYLJG003.PatnName = his.Name
  7824. // cFYLJG003.Certno = his.Certno
  7825. // cFYLJG003.FixmedinsName = miConfig.OrgName
  7826. // cFYLJG003.FixmedinsCode = miConfig.Code
  7827. //
  7828. // cFYLJG003.DrCode = doctor_info.DoctorNumber
  7829. // cFYLJG003.PrscDrName = doctor_info.UserName
  7830. // cFYLJG003.PharDeptName = dept.Name
  7831. // cFYLJG003.PharDeptCode = dept.Number
  7832. // cFYLJG003.PharCode = "HY440309002107"
  7833. // cFYLJG003.PharCertType = "01"
  7834. // cFYLJG003.PharCertno = "430482199408260023"
  7835. // cFYLJG003.PharName = "彭斯遥"
  7836. // cFYLJG003.PsnCertType = "01"
  7837. // cFYLJG003.RxFile = flow.RxFile
  7838. // cFYLJG003.SignDigest = flow.SignDigest
  7839. // cFYLJG003.FixmedinsCode = miConfig.Code
  7840. // cFYLJG003.PsnCertType = "01"
  7841. // cFYLJG003.PharProfttlCodg = dept.Name
  7842. // //inputData["pharProfttlCodg"] =dept.Name
  7843. //
  7844. // tempTime2 := time.Unix(info.Ctime, 0)
  7845. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7846. // cFYLJG003.PharChkTime = timeFormatTwo
  7847. //
  7848. // if miConfig.MdtrtareaAdmvs == "340699" {
  7849. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7850. // //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7851. // //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7852. // } else {
  7853. // result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7854. // saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7855. //
  7856. // }
  7857. //
  7858. // var res ResultCFYLJG003
  7859. // var respJSON2 map[string]interface{}
  7860. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7861. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7862. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7863. // return
  7864. // }
  7865. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7866. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7867. // utils.ErrorLog("解析失败:%v", err)
  7868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7869. // return
  7870. // }
  7871. // if res.Infcode == -1 {
  7872. // c.ServeSuccessJSON(map[string]interface{}{
  7873. // "failed_code": -10,
  7874. // "msg": res.ErrMsg,
  7875. // })
  7876. // return
  7877. // } else {
  7878. // c.ServeSuccessJSON(map[string]interface{}{
  7879. // "info": res.Output,
  7880. // })
  7881. // }
  7882. //
  7883. //}
  7884. //func (c *HisApiController) GetCFYLJG004() {
  7885. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7886. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7887. // record_time := c.GetString("record_time")
  7888. // admin_user_id = 3626
  7889. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7890. // //id, _ := c.GetInt64("id")
  7891. // admin_user_id = 3626
  7892. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7893. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7894. //
  7895. // flow, _ := service.Getflowtwo(his.Number)
  7896. // //id = 3
  7897. // patient_id, _ := c.GetInt64("patient_id")
  7898. // //patient_id = 23834
  7899. // //record_time = "2023-09-18"
  7900. // timeLayout := "2006-01-02"
  7901. // loc, _ := time.LoadLocation("Local")
  7902. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7903. // if err != nil {
  7904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7905. // return
  7906. // }
  7907. // recordDateTime := theTime.Unix()
  7908. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7909. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7910. // var cFYLJG004 models.CFYLJG004
  7911. // cFYLJG004.HiRxno = flow.HiRxno
  7912. // cFYLJG004.FixmedinsCode = miConfig.Code
  7913. // cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7914. // cFYLJG004.UndoDrCertType = "01"
  7915. // cFYLJG004.UndoRea = "撤销处方"
  7916. // cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7917. // cFYLJG004.UndoDrName = doctor_info.UserName
  7918. // cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7919. //
  7920. // if miConfig.MdtrtareaAdmvs == "340699" {
  7921. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7922. // //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7923. // //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7924. //
  7925. // } else {
  7926. // result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7927. // saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7928. //
  7929. // }
  7930. //
  7931. // var res ResultCFYLJG004
  7932. // var respJSON2 map[string]interface{}
  7933. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7934. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. // return
  7937. // }
  7938. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7939. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7940. // utils.ErrorLog("解析失败:%v", err)
  7941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. // return
  7943. // }
  7944. // if res.Infcode == -1 {
  7945. // c.ServeSuccessJSON(map[string]interface{}{
  7946. // "failed_code": -10,
  7947. // "msg": res.ErrMsg,
  7948. // })
  7949. // return
  7950. // } else {
  7951. // flow.Status = 0
  7952. // service.Saveflow(flow)
  7953. // c.ServeSuccessJSON(map[string]interface{}{
  7954. // "msg": "撤销成功",
  7955. // })
  7956. // return
  7957. //
  7958. // }
  7959. //}
  7960. //func (c *HisApiController) GetCFYLJG005() {
  7961. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7962. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7963. // //record_time := c.GetString("record_time")
  7964. // admin_user_id = 3626
  7965. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7966. // //id, _ := c.GetInt64("id")
  7967. // admin_user_id = 3626
  7968. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7969. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7970. //
  7971. // flow, _ := service.Getflowtwo(his.Number)
  7972. // //id = 3
  7973. // var cFYLJG005 models.CFYLJG005
  7974. //
  7975. // //patient_id, _ := c.GetInt64("patient_id")
  7976. // cFYLJG005.HiRxno = flow.HiRxno
  7977. // cFYLJG005.MdtrtID = flow.MID
  7978. // cFYLJG005.EcToken = ""
  7979. // cFYLJG005.PsnName = his.Name
  7980. // cFYLJG005.PsnCertType = "01"
  7981. // cFYLJG005.Certno = his.IdCardNo
  7982. //
  7983. // if miConfig.MdtrtareaAdmvs == "340699" {
  7984. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7985. //
  7986. // //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7987. // //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7988. //
  7989. // } else {
  7990. // result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7991. // saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7992. //
  7993. // }
  7994. //
  7995. // var res ResultCFYLJG005
  7996. // var respJSON2 map[string]interface{}
  7997. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7998. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7999. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. // return
  8001. // }
  8002. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8003. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8004. // utils.ErrorLog("解析失败:%v", err)
  8005. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. // return
  8007. // }
  8008. // if res.Infcode == -1 {
  8009. // c.ServeSuccessJSON(map[string]interface{}{
  8010. // "failed_code": -10,
  8011. // "msg": res.ErrMsg,
  8012. // })
  8013. // return
  8014. // } else {
  8015. // c.ServeSuccessJSON(map[string]interface{}{
  8016. // "info": res.Output,
  8017. // })
  8018. // return
  8019. // }
  8020. //}
  8021. //func (c *HisApiController) GetCFYLJG006() {
  8022. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8023. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8024. // admin_user_id = 3626
  8025. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8026. // //id, _ := c.GetInt64("id")
  8027. // admin_user_id = 3626
  8028. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8029. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8030. //
  8031. // flow, _ := service.Getflowtwo(his.Number)
  8032. // //id = 3
  8033. // patient_id, _ := c.GetInt64("patient_id")
  8034. // var cFYLJG006 models.CFYLJG006
  8035. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8036. // cFYLJG006.HiRxno = flow.HiRxno
  8037. // cFYLJG006.MdtrtID = flow.MID
  8038. // cFYLJG006.PsnName = patient.Name
  8039. // cFYLJG006.PsnCertType = "01"
  8040. // cFYLJG006.Certno = patient.IdCardNo
  8041. //
  8042. // if miConfig.MdtrtareaAdmvs == "340699" {
  8043. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8044. //
  8045. // result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8046. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8047. // } else {
  8048. // result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8049. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8050. // }
  8051. //
  8052. // var res ResultCFYLJG006
  8053. // var respJSON2 map[string]interface{}
  8054. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8055. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8057. // return
  8058. // }
  8059. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8060. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8061. // utils.ErrorLog("解析失败:%v", err)
  8062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8063. // return
  8064. // }
  8065. // if res.Infcode == -1 {
  8066. // c.ServeSuccessJSON(map[string]interface{}{
  8067. // "failed_code": -10,
  8068. // "msg": res.ErrMsg,
  8069. // })
  8070. // return
  8071. // } else {
  8072. // c.ServeSuccessJSON(map[string]interface{}{
  8073. // "info": res.Output,
  8074. // })
  8075. // return
  8076. // }
  8077. //}
  8078. //func (c *HisApiController) GetCFYLJG007() {
  8079. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8080. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8081. // admin_user_id = 3626
  8082. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8083. // //id, _ := c.GetInt64("id")
  8084. // admin_user_id = 3626
  8085. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8086. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8087. //
  8088. // flow, _ := service.Getflowtwo(his.Number)
  8089. // //id = 3
  8090. // patient_id, _ := c.GetInt64("patient_id")
  8091. // var cFYLJG007 models.CFYLJG007
  8092. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8093. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8094. //
  8095. // cFYLJG007.HiRxno = flow.HiRxno
  8096. // cFYLJG007.MdtrtID = flow.MID
  8097. // cFYLJG007.PsnNo = his.PsnNo
  8098. // cFYLJG007.PsnCertType = "01"
  8099. // cFYLJG007.Certno = patient.IdCardNo
  8100. // cFYLJG007.PsnName = patient.Name
  8101. //
  8102. // if miConfig.MdtrtareaAdmvs == "340699" {
  8103. // result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8104. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8105. // } else {
  8106. // result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8107. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8108. // }
  8109. //
  8110. // var res ResultCFYLJG007
  8111. // var respJSON2 map[string]interface{}
  8112. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8113. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8115. // return
  8116. // }
  8117. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8118. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8119. // utils.ErrorLog("解析失败:%v", err)
  8120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8121. // return
  8122. // }
  8123. // if res.Infcode == -1 {
  8124. // c.ServeSuccessJSON(map[string]interface{}{
  8125. // "failed_code": -10,
  8126. // "msg": res.ErrMsg,
  8127. // })
  8128. // return
  8129. // } else {
  8130. // c.ServeSuccessJSON(map[string]interface{}{
  8131. // "info": res,
  8132. // })
  8133. // return
  8134. // }
  8135. //}
  8136. //
  8137. //func (c *HisApiController) GetCFYLJG008() {
  8138. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8139. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8140. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8141. // var cFYLJG008 models.CFYLJG008
  8142. // //id, _ := c.GetInt64("id")
  8143. // patient_id, _ := c.GetInt64("patient_id")
  8144. // //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8145. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8146. // //id = 3
  8147. // //flow, _ := service.Getflow(id)
  8148. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  8149. //
  8150. // //
  8151. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  8152. // //patient_id, _ := c.GetInt64("patient_id")
  8153. // //his_patient_id, _ := c.GetInt64("his_patient_id")
  8154. // record_time := c.GetString("record_time")
  8155. //
  8156. // admin_user_id = 3626
  8157. // patient_id = 19424
  8158. // //his_patient_id = 263947
  8159. // record_time = "2023-08-29"
  8160. //
  8161. // timeLayout := "2006-01-02"
  8162. // loc, _ := time.LoadLocation("Local")
  8163. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8164. // if err != nil {
  8165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8166. // return
  8167. // }
  8168. // recordDateTime := theTime.Unix()
  8169. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8170. //
  8171. // cFYLJG008.FixmedinsName = ""
  8172. // cFYLJG008.Lat = ""
  8173. // cFYLJG008.Lng = ""
  8174. // cFYLJG008.OrderType = "1"
  8175. // cFYLJG008.PoolareaNo = ""
  8176. // cFYLJG008.Lng = ""
  8177. // cFYLJG008.PageNum = 1
  8178. // cFYLJG008.PageSize = 10
  8179. // var MPI models.MedinsProdInvChgDDTO
  8180. // MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8181. // MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8182. // cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8183. //
  8184. // if miConfig.MdtrtareaAdmvs == "340699" {
  8185. // result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8186. // saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8187. //
  8188. // } else {
  8189. // result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8190. // saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8191. //
  8192. // var res ResultCFYLJG008
  8193. // var respJSON2 map[string]interface{}
  8194. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8195. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8196. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8197. // return
  8198. // }
  8199. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8200. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8201. // utils.ErrorLog("解析失败:%v", err)
  8202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8203. // return
  8204. // }
  8205. // if res.Infcode == -1 {
  8206. // c.ServeSuccessJSON(map[string]interface{}{
  8207. // "failed_code": -10,
  8208. // "msg": res.ErrMsg,
  8209. // })
  8210. // return
  8211. // } else {
  8212. // c.ServeSuccessJSON(map[string]interface{}{
  8213. // "info": res.Output,
  8214. // })
  8215. // return
  8216. // }
  8217. // }
  8218. //
  8219. //}
  8220. func (c *HisApiController) GetBL4201A() {
  8221. order_id, _ := c.GetInt64("order_id")
  8222. admin_user_id, _ := c.GetInt64("admin_user_id")
  8223. order, _ := service.GetHisOrderByIDTwo(order_id)
  8224. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8225. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8226. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8227. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8228. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8229. department, _ := service.GetDepartMentDetail(his.Departments)
  8230. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8231. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8232. if order.ID == 0 {
  8233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8234. return
  8235. }
  8236. var struct4201A models.Struct4201A
  8237. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8238. for _, items := range order_info {
  8239. memo := make(map[string]interface{})
  8240. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8241. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8242. fsiOPFLD.MedType = "14"
  8243. fsiOPFLD.BkkpSn = items.FeedetlSn
  8244. fsiOPFLD.FixmedinsCode = miConfig.Code
  8245. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8246. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8247. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8248. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8249. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8250. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8251. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8252. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8253. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8254. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8255. fsiOPFLD.BilgDeptName = department.Name
  8256. fsiOPFLD.BilgDeptCodg = department.Number
  8257. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8258. fsiOPFLD.BilgDrName = doctor.UserName
  8259. fsiOPFLD.MedChrgitmType = "09"
  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.AdviceId == 0 && items.ProjectId > 0 {
  8267. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8268. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8269. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8270. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8271. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8272. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8273. fsiOPFLD.BilgDeptName = department.Name
  8274. fsiOPFLD.BilgDeptCodg = department.Number
  8275. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8276. fsiOPFLD.BilgDrName = doctor.UserName
  8277. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8278. case 0:
  8279. break
  8280. case 1:
  8281. fsiOPFLD.MedChrgitmType = "14"
  8282. break
  8283. case 2:
  8284. fsiOPFLD.MedChrgitmType = "05"
  8285. break
  8286. case 3:
  8287. fsiOPFLD.MedChrgitmType = "03"
  8288. break
  8289. case 4:
  8290. fsiOPFLD.MedChrgitmType = "03"
  8291. break
  8292. case 5:
  8293. fsiOPFLD.MedChrgitmType = "08"
  8294. break
  8295. case 6:
  8296. fsiOPFLD.MedChrgitmType = "14"
  8297. break
  8298. case 7:
  8299. fsiOPFLD.MedChrgitmType = "14"
  8300. break
  8301. case 8:
  8302. fsiOPFLD.MedChrgitmType = "03"
  8303. break
  8304. case 9:
  8305. fsiOPFLD.MedChrgitmType = "14"
  8306. break
  8307. case 10:
  8308. fsiOPFLD.MedChrgitmType = "14"
  8309. break
  8310. case 11:
  8311. fsiOPFLD.MedChrgitmType = "06"
  8312. break
  8313. case 12:
  8314. fsiOPFLD.MedChrgitmType = "12"
  8315. break
  8316. case 13:
  8317. fsiOPFLD.MedChrgitmType = "01"
  8318. break
  8319. case 14:
  8320. fsiOPFLD.MedChrgitmType = "04"
  8321. break
  8322. case 15:
  8323. fsiOPFLD.MedChrgitmType = "14"
  8324. break
  8325. }
  8326. memo["hosp_appr_flag"] = "1"
  8327. memo["invoice_no"] = order.MdtrtId
  8328. memo["memo"] = "自费"
  8329. bytesData, _ := json.Marshal(memo)
  8330. fsiOPFLD.Memo = string(bytesData)
  8331. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8332. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8333. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8334. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8335. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8336. fsiOPFLD.BilgDeptName = department.Name
  8337. fsiOPFLD.BilgDeptCodg = department.Number
  8338. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8339. fsiOPFLD.BilgDrName = doctor.UserName
  8340. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8341. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8342. fsiOPFLD.MedChrgitmType = "08"
  8343. memo["hosp_appr_flag"] = "1"
  8344. memo["invoice_no"] = order.MdtrtId
  8345. memo["memo"] = "自费"
  8346. bytesData, _ := json.Marshal(memo)
  8347. fsiOPFLD.Memo = string(bytesData)
  8348. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8349. }
  8350. }
  8351. }
  8352. for _, items := range order_info_two {
  8353. memo := make(map[string]interface{})
  8354. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8355. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8356. fsiOPFLD.MedType = "14"
  8357. fsiOPFLD.BkkpSn = items.FeedetlSn
  8358. fsiOPFLD.FixmedinsCode = miConfig.Code
  8359. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8360. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8361. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8362. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8363. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8364. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8365. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8366. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8367. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8368. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8369. fsiOPFLD.BilgDeptName = department.Name
  8370. fsiOPFLD.BilgDeptCodg = department.Number
  8371. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8372. fsiOPFLD.BilgDrName = doctor.UserName
  8373. fsiOPFLD.MedChrgitmType = "09"
  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.AdviceId == 0 && items.ProjectId > 0 {
  8381. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8382. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8383. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8384. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8385. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8386. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8387. fsiOPFLD.BilgDeptName = department.Name
  8388. fsiOPFLD.BilgDeptCodg = department.Number
  8389. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8390. fsiOPFLD.BilgDrName = doctor.UserName
  8391. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8392. case 0:
  8393. break
  8394. case 1:
  8395. fsiOPFLD.MedChrgitmType = "14"
  8396. break
  8397. case 2:
  8398. fsiOPFLD.MedChrgitmType = "05"
  8399. break
  8400. case 3:
  8401. fsiOPFLD.MedChrgitmType = "03"
  8402. break
  8403. case 4:
  8404. fsiOPFLD.MedChrgitmType = "03"
  8405. break
  8406. case 5:
  8407. fsiOPFLD.MedChrgitmType = "08"
  8408. break
  8409. case 6:
  8410. fsiOPFLD.MedChrgitmType = "14"
  8411. break
  8412. case 7:
  8413. fsiOPFLD.MedChrgitmType = "14"
  8414. break
  8415. case 8:
  8416. fsiOPFLD.MedChrgitmType = "03"
  8417. break
  8418. case 9:
  8419. fsiOPFLD.MedChrgitmType = "14"
  8420. break
  8421. case 10:
  8422. fsiOPFLD.MedChrgitmType = "14"
  8423. break
  8424. case 11:
  8425. fsiOPFLD.MedChrgitmType = "06"
  8426. break
  8427. case 12:
  8428. fsiOPFLD.MedChrgitmType = "12"
  8429. break
  8430. case 13:
  8431. fsiOPFLD.MedChrgitmType = "01"
  8432. break
  8433. case 14:
  8434. fsiOPFLD.MedChrgitmType = "04"
  8435. break
  8436. case 15:
  8437. fsiOPFLD.MedChrgitmType = "14"
  8438. break
  8439. }
  8440. memo["hosp_appr_flag"] = "1"
  8441. memo["invoice_no"] = order.MdtrtId
  8442. memo["memo"] = "自费"
  8443. bytesData, _ := json.Marshal(memo)
  8444. fsiOPFLD.Memo = string(bytesData)
  8445. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8446. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8447. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8448. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8449. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8450. fsiOPFLD.BilgDeptName = department.Name
  8451. fsiOPFLD.BilgDeptCodg = department.Number
  8452. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8453. fsiOPFLD.BilgDrName = doctor.UserName
  8454. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8455. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8456. fsiOPFLD.MedChrgitmType = "08"
  8457. memo["hosp_appr_flag"] = "1"
  8458. memo["invoice_no"] = order.MdtrtId
  8459. memo["memo"] = "自费"
  8460. bytesData, _ := json.Marshal(memo)
  8461. fsiOPFLD.Memo = string(bytesData)
  8462. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8463. }
  8464. }
  8465. }
  8466. fmt.Println(fsiOPFLDs)
  8467. struct4201A.Fopfd = fsiOPFLDs
  8468. fmt.Println(struct4201A.Fopfd)
  8469. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8470. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8471. var res2 ResultSix
  8472. var respJSON2 map[string]interface{}
  8473. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. userJSONBytes2, _ := json.Marshal(respJSON2)
  8479. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8480. utils.ErrorLog("解析失败:%v", err)
  8481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8482. return
  8483. }
  8484. if res2.Infcode != 0 {
  8485. c.ServeSuccessJSON(map[string]interface{}{
  8486. "failed_code": -10,
  8487. "msg": res2.ErrMsg,
  8488. })
  8489. return
  8490. } else {
  8491. order.IsUploadOrderInfo = 1
  8492. service.UpdateOrder(order)
  8493. c.ServeSuccessJSON(map[string]interface{}{
  8494. "msg": "上传成功",
  8495. })
  8496. }
  8497. }
  8498. func (c *HisApiController) Get2505() {
  8499. admin_user_id, _ := c.GetInt64("admin_user_id")
  8500. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8501. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8502. 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)
  8503. }
  8504. func (c *HisApiController) Get4201A() {
  8505. order_id, _ := c.GetInt64("order_id")
  8506. admin_user_id, _ := c.GetInt64("admin_user_id")
  8507. order, _ := service.GetHisOrderByIDTwo(order_id)
  8508. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8509. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8510. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8511. //order_info = append(order_info, order_info_two...)
  8512. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8513. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8514. department, _ := service.GetDepartMentDetail(his.Departments)
  8515. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8516. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8517. if order.ID == 0 {
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8519. return
  8520. }
  8521. var struct4201A models.Struct4201A
  8522. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8523. for _, items := range order_info {
  8524. memo := make(map[string]interface{})
  8525. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8526. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8527. fsiOPFLD.MedType = "14"
  8528. fsiOPFLD.BkkpSn = items.FeedetlSn
  8529. fsiOPFLD.FixmedinsCode = miConfig.Code
  8530. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8531. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8532. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8533. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8534. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8535. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8536. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8537. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8538. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8539. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8540. fsiOPFLD.BilgDeptName = department.Name
  8541. fsiOPFLD.BilgDeptCodg = department.Number
  8542. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8543. fsiOPFLD.BilgDrName = doctor.UserName
  8544. fsiOPFLD.MedChrgitmType = "09"
  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.AdviceId == 0 && items.ProjectId > 0 {
  8552. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8553. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8554. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8555. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8556. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8557. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8558. fsiOPFLD.BilgDeptName = department.Name
  8559. fsiOPFLD.BilgDeptCodg = department.Number
  8560. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8561. fsiOPFLD.BilgDrName = doctor.UserName
  8562. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8563. case 0:
  8564. break
  8565. case 1:
  8566. fsiOPFLD.MedChrgitmType = "14"
  8567. break
  8568. case 2:
  8569. fsiOPFLD.MedChrgitmType = "05"
  8570. break
  8571. case 3:
  8572. fsiOPFLD.MedChrgitmType = "03"
  8573. break
  8574. case 4:
  8575. fsiOPFLD.MedChrgitmType = "03"
  8576. break
  8577. case 5:
  8578. fsiOPFLD.MedChrgitmType = "08"
  8579. break
  8580. case 6:
  8581. fsiOPFLD.MedChrgitmType = "14"
  8582. break
  8583. case 7:
  8584. fsiOPFLD.MedChrgitmType = "14"
  8585. break
  8586. case 8:
  8587. fsiOPFLD.MedChrgitmType = "03"
  8588. break
  8589. case 9:
  8590. fsiOPFLD.MedChrgitmType = "14"
  8591. break
  8592. case 10:
  8593. fsiOPFLD.MedChrgitmType = "14"
  8594. break
  8595. case 11:
  8596. fsiOPFLD.MedChrgitmType = "06"
  8597. break
  8598. case 12:
  8599. fsiOPFLD.MedChrgitmType = "12"
  8600. break
  8601. case 13:
  8602. fsiOPFLD.MedChrgitmType = "01"
  8603. break
  8604. case 14:
  8605. fsiOPFLD.MedChrgitmType = "04"
  8606. break
  8607. case 15:
  8608. fsiOPFLD.MedChrgitmType = "14"
  8609. break
  8610. }
  8611. memo["hosp_appr_flag"] = "1"
  8612. memo["invoice_no"] = order.MdtrtId
  8613. memo["memo"] = "自费"
  8614. bytesData, _ := json.Marshal(memo)
  8615. fsiOPFLD.Memo = string(bytesData)
  8616. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8617. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8618. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8619. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8620. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8621. fsiOPFLD.BilgDeptName = department.Name
  8622. fsiOPFLD.BilgDeptCodg = department.Number
  8623. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8624. fsiOPFLD.BilgDrName = doctor.UserName
  8625. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8626. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8627. fsiOPFLD.MedChrgitmType = "08"
  8628. memo["hosp_appr_flag"] = "1"
  8629. memo["invoice_no"] = order.MdtrtId
  8630. memo["memo"] = "自费"
  8631. bytesData, _ := json.Marshal(memo)
  8632. fsiOPFLD.Memo = string(bytesData)
  8633. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8634. }
  8635. }
  8636. }
  8637. for _, items := range order_info_two {
  8638. memo := make(map[string]interface{})
  8639. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8640. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8641. fsiOPFLD.MedType = "14"
  8642. fsiOPFLD.BkkpSn = items.FeedetlSn
  8643. fsiOPFLD.FixmedinsCode = miConfig.Code
  8644. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8645. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8646. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8647. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8648. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8649. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8650. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8651. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8652. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8653. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8654. fsiOPFLD.BilgDeptName = department.Name
  8655. fsiOPFLD.BilgDeptCodg = department.Number
  8656. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8657. fsiOPFLD.BilgDrName = doctor.UserName
  8658. fsiOPFLD.MedChrgitmType = "09"
  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.AdviceId == 0 && items.ProjectId > 0 {
  8666. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8667. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8668. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8669. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8670. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8671. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8672. fsiOPFLD.BilgDeptName = department.Name
  8673. fsiOPFLD.BilgDeptCodg = department.Number
  8674. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8675. fsiOPFLD.BilgDrName = doctor.UserName
  8676. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8677. case 0:
  8678. break
  8679. case 1:
  8680. fsiOPFLD.MedChrgitmType = "14"
  8681. break
  8682. case 2:
  8683. fsiOPFLD.MedChrgitmType = "05"
  8684. break
  8685. case 3:
  8686. fsiOPFLD.MedChrgitmType = "03"
  8687. break
  8688. case 4:
  8689. fsiOPFLD.MedChrgitmType = "03"
  8690. break
  8691. case 5:
  8692. fsiOPFLD.MedChrgitmType = "08"
  8693. break
  8694. case 6:
  8695. fsiOPFLD.MedChrgitmType = "14"
  8696. break
  8697. case 7:
  8698. fsiOPFLD.MedChrgitmType = "14"
  8699. break
  8700. case 8:
  8701. fsiOPFLD.MedChrgitmType = "03"
  8702. break
  8703. case 9:
  8704. fsiOPFLD.MedChrgitmType = "14"
  8705. break
  8706. case 10:
  8707. fsiOPFLD.MedChrgitmType = "14"
  8708. break
  8709. case 11:
  8710. fsiOPFLD.MedChrgitmType = "06"
  8711. break
  8712. case 12:
  8713. fsiOPFLD.MedChrgitmType = "12"
  8714. break
  8715. case 13:
  8716. fsiOPFLD.MedChrgitmType = "01"
  8717. break
  8718. case 14:
  8719. fsiOPFLD.MedChrgitmType = "04"
  8720. break
  8721. case 15:
  8722. fsiOPFLD.MedChrgitmType = "14"
  8723. break
  8724. }
  8725. memo["hosp_appr_flag"] = "1"
  8726. memo["invoice_no"] = order.MdtrtId
  8727. memo["memo"] = "自费"
  8728. bytesData, _ := json.Marshal(memo)
  8729. fsiOPFLD.Memo = string(bytesData)
  8730. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8731. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8732. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8733. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8734. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8735. fsiOPFLD.BilgDeptName = department.Name
  8736. fsiOPFLD.BilgDeptCodg = department.Number
  8737. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8738. fsiOPFLD.BilgDrName = doctor.UserName
  8739. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8740. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8741. fsiOPFLD.MedChrgitmType = "08"
  8742. memo["hosp_appr_flag"] = "1"
  8743. memo["invoice_no"] = order.MdtrtId
  8744. memo["memo"] = "自费"
  8745. bytesData, _ := json.Marshal(memo)
  8746. fsiOPFLD.Memo = string(bytesData)
  8747. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8748. }
  8749. }
  8750. }
  8751. fmt.Println(fsiOPFLDs)
  8752. struct4201A.Fopfd = fsiOPFLDs
  8753. fmt.Println(struct4201A.Fopfd)
  8754. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8755. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8756. var res2 ResultSix
  8757. var respJSON2 map[string]interface{}
  8758. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8761. return
  8762. }
  8763. userJSONBytes2, _ := json.Marshal(respJSON2)
  8764. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8765. utils.ErrorLog("解析失败:%v", err)
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. return
  8768. }
  8769. if res2.Infcode != 0 {
  8770. c.ServeSuccessJSON(map[string]interface{}{
  8771. "failed_code": -10,
  8772. "msg": res2.ErrMsg,
  8773. })
  8774. return
  8775. } else {
  8776. order.IsUploadOrderInfo = 1
  8777. service.UpdateOrder(order)
  8778. c.ServeSuccessJSON(map[string]interface{}{
  8779. "msg": "上传成功",
  8780. })
  8781. }
  8782. }
  8783. func (c *HisApiController) Get4202() {
  8784. order_id, _ := c.GetInt64("order_id")
  8785. admin_user_id, _ := c.GetInt64("admin_user_id")
  8786. order, _ := service.GetHisOrderByIDTwo(order_id)
  8787. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8788. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8789. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8790. if order.ID == 0 {
  8791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8792. return
  8793. }
  8794. var struct4202 models.Struct4202
  8795. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8796. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8797. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8798. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8799. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8800. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8801. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8802. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8803. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8804. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8805. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8806. var config []*models.HisXtDiagnoseConfig
  8807. for _, item := range diagnosis_ids {
  8808. id, _ := strconv.ParseInt(item, 10, 64)
  8809. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8810. config = append(config, &diagnosisConfig)
  8811. }
  8812. var tempDiaginfos []models.OwnPayPatnDiagListD
  8813. for index, item := range config {
  8814. if index == 0 {
  8815. var tempDiaginfo models.OwnPayPatnDiagListD
  8816. tempDiaginfo.InoutDiagType = "1"
  8817. tempDiaginfo.DiagCode = item.CountryCode
  8818. tempDiaginfo.DiagName = item.CountryContentName
  8819. tempDiaginfo.DiagType = "1"
  8820. tempDiaginfo.DiagSrtNo = "1"
  8821. tempDiaginfo.MaindiagFlag = "1"
  8822. tempDiaginfo.ValiFlag = "1"
  8823. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8824. } else {
  8825. var tempDiaginfo models.OwnPayPatnDiagListD
  8826. tempDiaginfo.DiagCode = item.CountryCode
  8827. tempDiaginfo.DiagName = item.CountryContentName
  8828. tempDiaginfo.DiagType = "2"
  8829. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8830. tempDiaginfo.MaindiagFlag = "0"
  8831. tempDiaginfo.ValiFlag = "1"
  8832. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8833. }
  8834. }
  8835. struct4202.ODiagListD = tempDiaginfos
  8836. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8837. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8838. var res2 ResultSix
  8839. var respJSON2 map[string]interface{}
  8840. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. userJSONBytes2, _ := json.Marshal(respJSON2)
  8846. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8847. utils.ErrorLog("解析失败:%v", err)
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8849. return
  8850. }
  8851. if res2.Infcode != 0 {
  8852. c.ServeSuccessJSON(map[string]interface{}{
  8853. "failed_code": -10,
  8854. "msg": res2.ErrMsg,
  8855. })
  8856. return
  8857. } else {
  8858. order.IsUploadDiagnose = 1
  8859. service.UpdateOrder(order)
  8860. c.ServeSuccessJSON(map[string]interface{}{
  8861. "msg": "上传成功",
  8862. })
  8863. }
  8864. }
  8865. func (c *HisApiController) Get4203() {
  8866. admin_user_id, _ := c.GetInt64("admin_user_id")
  8867. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8868. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8869. order_id, _ := c.GetInt64("order_id")
  8870. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8871. number := ""
  8872. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8873. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8874. if his.ID == 0 {
  8875. number = hospital.Number
  8876. } else {
  8877. number = his.Number
  8878. }
  8879. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8880. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8881. var res2 ResultSix
  8882. var respJSON2 map[string]interface{}
  8883. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. userJSONBytes2, _ := json.Marshal(respJSON2)
  8889. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8890. utils.ErrorLog("解析失败:%v", err)
  8891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8892. return
  8893. }
  8894. if res2.Infcode != 0 {
  8895. c.ServeSuccessJSON(map[string]interface{}{
  8896. "failed_code": -10,
  8897. "msg": res2.ErrMsg,
  8898. })
  8899. return
  8900. } else {
  8901. order.IsUploadSuccess = 1
  8902. service.UpdateOrderTwo(order)
  8903. c.ServeSuccessJSON(map[string]interface{}{
  8904. "msg": "上传成功",
  8905. })
  8906. }
  8907. }
  8908. func (c *HisApiController) Get4205() {
  8909. order_id, _ := c.GetInt64("order_id")
  8910. admin_user_id, _ := c.GetInt64("admin_user_id")
  8911. fapiao_code := c.GetString("fapiao_code")
  8912. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8913. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8914. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8915. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8916. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8917. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8918. //order_info = append(order_info, order_info_two...)
  8919. department, _ := service.GetDepartMentDetail(his.Departments)
  8920. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8921. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8922. if order.ID == 0 {
  8923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8924. return
  8925. }
  8926. var struct4201A models.Struct4201A
  8927. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8928. for _, items := range order_info {
  8929. memo := make(map[string]interface{})
  8930. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8931. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8932. fsiOPFLD.MedType = pre.MedType
  8933. fsiOPFLD.FixmedinsCode = miConfig.Code
  8934. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8935. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8936. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8937. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8938. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8939. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8940. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8941. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8942. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8943. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8944. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8945. fsiOPFLD.BilgDeptName = department.Name
  8946. fsiOPFLD.BilgDeptCodg = department.Number
  8947. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8948. fsiOPFLD.BilgDrName = doctor.UserName
  8949. fsiOPFLD.MedChrgitmType = "09"
  8950. memo["hosp_appr_flag"] = "1"
  8951. memo["invoice_no"] = fapiao_code
  8952. memo["memo"] = "自费"
  8953. bytesData, _ := json.Marshal(memo)
  8954. fsiOPFLD.Memo = string(bytesData)
  8955. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8956. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8957. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8958. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8959. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8960. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8961. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8962. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8963. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8964. fsiOPFLD.BilgDeptName = department.Name
  8965. fsiOPFLD.BilgDeptCodg = department.Number
  8966. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8967. fsiOPFLD.BilgDrName = doctor.UserName
  8968. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8969. case 0:
  8970. break
  8971. case 1:
  8972. fsiOPFLD.MedChrgitmType = "14"
  8973. break
  8974. case 2:
  8975. fsiOPFLD.MedChrgitmType = "05"
  8976. break
  8977. case 3:
  8978. fsiOPFLD.MedChrgitmType = "03"
  8979. break
  8980. case 4:
  8981. fsiOPFLD.MedChrgitmType = "03"
  8982. break
  8983. case 5:
  8984. fsiOPFLD.MedChrgitmType = "08"
  8985. break
  8986. case 6:
  8987. fsiOPFLD.MedChrgitmType = "14"
  8988. break
  8989. case 7:
  8990. fsiOPFLD.MedChrgitmType = "14"
  8991. break
  8992. case 8:
  8993. fsiOPFLD.MedChrgitmType = "03"
  8994. break
  8995. case 9:
  8996. fsiOPFLD.MedChrgitmType = "14"
  8997. break
  8998. case 10:
  8999. fsiOPFLD.MedChrgitmType = "14"
  9000. break
  9001. case 11:
  9002. fsiOPFLD.MedChrgitmType = "06"
  9003. break
  9004. case 12:
  9005. fsiOPFLD.MedChrgitmType = "12"
  9006. break
  9007. case 13:
  9008. fsiOPFLD.MedChrgitmType = "01"
  9009. break
  9010. case 14:
  9011. fsiOPFLD.MedChrgitmType = "04"
  9012. break
  9013. case 15:
  9014. fsiOPFLD.MedChrgitmType = "14"
  9015. break
  9016. }
  9017. memo["hosp_appr_flag"] = "1"
  9018. memo["invoice_no"] = fapiao_code
  9019. memo["memo"] = "自费"
  9020. bytesData, _ := json.Marshal(memo)
  9021. fsiOPFLD.Memo = string(bytesData)
  9022. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9023. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9024. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9025. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9026. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9027. fsiOPFLD.BilgDeptName = department.Name
  9028. fsiOPFLD.BilgDeptCodg = department.Number
  9029. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9030. fsiOPFLD.BilgDrName = doctor.UserName
  9031. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9032. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9033. fsiOPFLD.MedChrgitmType = "08"
  9034. memo["hosp_appr_flag"] = "1"
  9035. memo["invoice_no"] = fapiao_code
  9036. memo["memo"] = "自费"
  9037. bytesData, _ := json.Marshal(memo)
  9038. fsiOPFLD.Memo = string(bytesData)
  9039. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9040. }
  9041. }
  9042. }
  9043. for _, items := range order_info_two {
  9044. memo := make(map[string]interface{})
  9045. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9046. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9047. fsiOPFLD.MedType = pre.MedType
  9048. fsiOPFLD.BkkpSn = items.FeedetlSn
  9049. fsiOPFLD.FixmedinsCode = miConfig.Code
  9050. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9051. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9052. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9053. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9054. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9055. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9056. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9057. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9058. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9059. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9060. fsiOPFLD.BilgDeptName = department.Name
  9061. fsiOPFLD.BilgDeptCodg = department.Number
  9062. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9063. fsiOPFLD.BilgDrName = doctor.UserName
  9064. fsiOPFLD.MedChrgitmType = "09"
  9065. memo["hosp_appr_flag"] = "1"
  9066. memo["invoice_no"] = fapiao_code
  9067. memo["memo"] = "自费"
  9068. bytesData, _ := json.Marshal(memo)
  9069. fsiOPFLD.Memo = string(bytesData)
  9070. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9071. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9072. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9073. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9074. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9075. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9076. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9077. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9078. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9079. fsiOPFLD.BilgDeptName = department.Name
  9080. fsiOPFLD.BilgDeptCodg = department.Number
  9081. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9082. fsiOPFLD.BilgDrName = doctor.UserName
  9083. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9084. case 0:
  9085. break
  9086. case 1:
  9087. fsiOPFLD.MedChrgitmType = "14"
  9088. break
  9089. case 2:
  9090. fsiOPFLD.MedChrgitmType = "05"
  9091. break
  9092. case 3:
  9093. fsiOPFLD.MedChrgitmType = "03"
  9094. break
  9095. case 4:
  9096. fsiOPFLD.MedChrgitmType = "03"
  9097. break
  9098. case 5:
  9099. fsiOPFLD.MedChrgitmType = "08"
  9100. break
  9101. case 6:
  9102. fsiOPFLD.MedChrgitmType = "14"
  9103. break
  9104. case 7:
  9105. fsiOPFLD.MedChrgitmType = "14"
  9106. break
  9107. case 8:
  9108. fsiOPFLD.MedChrgitmType = "03"
  9109. break
  9110. case 9:
  9111. fsiOPFLD.MedChrgitmType = "14"
  9112. break
  9113. case 10:
  9114. fsiOPFLD.MedChrgitmType = "14"
  9115. break
  9116. case 11:
  9117. fsiOPFLD.MedChrgitmType = "06"
  9118. break
  9119. case 12:
  9120. fsiOPFLD.MedChrgitmType = "12"
  9121. break
  9122. case 13:
  9123. fsiOPFLD.MedChrgitmType = "01"
  9124. break
  9125. case 14:
  9126. fsiOPFLD.MedChrgitmType = "04"
  9127. break
  9128. case 15:
  9129. fsiOPFLD.MedChrgitmType = "14"
  9130. break
  9131. }
  9132. memo["hosp_appr_flag"] = "1"
  9133. memo["invoice_no"] = fapiao_code
  9134. memo["memo"] = "自费"
  9135. bytesData, _ := json.Marshal(memo)
  9136. fsiOPFLD.Memo = string(bytesData)
  9137. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9138. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9139. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9140. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9141. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9142. fsiOPFLD.BilgDeptName = department.Name
  9143. fsiOPFLD.BilgDeptCodg = department.Number
  9144. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9145. fsiOPFLD.BilgDrName = doctor.UserName
  9146. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9147. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9148. fsiOPFLD.MedChrgitmType = "08"
  9149. memo["hosp_appr_flag"] = "1"
  9150. memo["invoice_no"] = fapiao_code
  9151. memo["memo"] = "自费"
  9152. bytesData, _ := json.Marshal(memo)
  9153. fsiOPFLD.Memo = string(bytesData)
  9154. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9155. }
  9156. }
  9157. }
  9158. fmt.Println(fsiOPFLDs)
  9159. struct4201A.Fopfd = fsiOPFLDs
  9160. fmt.Println(struct4201A.Fopfd)
  9161. var struct4202 models.Struct4202
  9162. timeLayout := "2006-01-02 15:04:05"
  9163. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9164. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9165. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9166. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9167. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9168. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9169. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9170. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9171. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9172. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9173. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9174. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9175. var config []*models.HisXtDiagnoseConfig
  9176. for _, item := range diagnosis_ids {
  9177. id, _ := strconv.ParseInt(item, 10, 64)
  9178. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9179. config = append(config, &diagnosisConfig)
  9180. }
  9181. var tempDiaginfos []models.OwnPayPatnDiagListD
  9182. for index, item := range config {
  9183. if index == 0 {
  9184. var tempDiaginfo models.OwnPayPatnDiagListD
  9185. tempDiaginfo.InoutDiagType = "1"
  9186. tempDiaginfo.DiagCode = item.CountryCode
  9187. tempDiaginfo.DiagName = item.CountryContentName
  9188. tempDiaginfo.DiagType = "1"
  9189. tempDiaginfo.DiagSrtNo = "1"
  9190. tempDiaginfo.MaindiagFlag = "1"
  9191. tempDiaginfo.ValiFlag = "1"
  9192. tempDiaginfo.DiagDrName = doctor.UserName
  9193. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9194. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9195. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9196. } else {
  9197. var tempDiaginfo models.OwnPayPatnDiagListD
  9198. tempDiaginfo.DiagCode = item.CountryCode
  9199. tempDiaginfo.DiagName = item.CountryContentName
  9200. tempDiaginfo.DiagType = "2"
  9201. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9202. tempDiaginfo.MaindiagFlag = "0"
  9203. tempDiaginfo.ValiFlag = "1"
  9204. tempDiaginfo.DiagDrName = doctor.UserName
  9205. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9206. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9207. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9208. }
  9209. }
  9210. struct4202.ODiagListD = tempDiaginfos
  9211. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9212. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9213. var res2 ResultSix
  9214. var respJSON2 map[string]interface{}
  9215. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9218. return
  9219. }
  9220. userJSONBytes2, _ := json.Marshal(respJSON2)
  9221. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9222. utils.ErrorLog("解析失败:%v", err)
  9223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9224. return
  9225. }
  9226. if res2.Infcode != 0 {
  9227. c.ServeSuccessJSON(map[string]interface{}{
  9228. "failed_code": -10,
  9229. "msg": res2.ErrMsg,
  9230. })
  9231. return
  9232. } else {
  9233. order.IsUploadDiagnose = 1
  9234. order.IsUploadOrderInfo = 1
  9235. service.UpdateOrderTwo(order)
  9236. c.ServeSuccessJSON(map[string]interface{}{
  9237. "msg": "上传成功",
  9238. })
  9239. }
  9240. }
  9241. func (c *HisApiController) Get4207() {
  9242. admin_user_id, _ := c.GetInt64("admin_user_id")
  9243. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9244. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9245. order_id, _ := c.GetInt64("order_id")
  9246. order, _ := service.GetHisOrderByIDTwo(order_id)
  9247. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9248. var struct4207 models.Struct4207
  9249. struct4207.PageNum = "1"
  9250. struct4207.PageSize = "1000"
  9251. struct4207.FixmedinsCode = miConfig.Code
  9252. struct4207.FixmedinsMdtrtID = order.Number
  9253. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9254. saveLog(result, requestLog, "4207", "查询")
  9255. var res2 ResultSix
  9256. var respJSON2 map[string]interface{}
  9257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9260. return
  9261. }
  9262. userJSONBytes2, _ := json.Marshal(respJSON2)
  9263. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9264. utils.ErrorLog("解析失败:%v", err)
  9265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9266. return
  9267. }
  9268. if res2.Infcode != 0 {
  9269. c.ServeSuccessJSON(map[string]interface{}{
  9270. "failed_code": -10,
  9271. "msg": res2.ErrMsg,
  9272. })
  9273. return
  9274. } else {
  9275. c.ServeSuccessJSON(map[string]interface{}{
  9276. "msg": "查询成功",
  9277. })
  9278. }
  9279. }
  9280. func (c *HisApiController) Get4208() {
  9281. admin_user_id, _ := c.GetInt64("admin_user_id")
  9282. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9283. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9284. order_id, _ := c.GetInt64("order_id")
  9285. order, _ := service.GetHisOrderByIDTwo(order_id)
  9286. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9287. var struct4208 models.Struct4208
  9288. struct4208.PageNum = "1"
  9289. struct4208.PageSize = "1000"
  9290. struct4208.PsnCertType = "01"
  9291. struct4208.Certno = his.Certno
  9292. struct4208.MedType = order.MedType
  9293. struct4208.PsnName = his.Name
  9294. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9295. saveLog(result, requestLog, "4208", "查询")
  9296. var res2 ResultSix
  9297. var respJSON2 map[string]interface{}
  9298. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9301. return
  9302. }
  9303. userJSONBytes2, _ := json.Marshal(respJSON2)
  9304. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9305. utils.ErrorLog("解析失败:%v", err)
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. if res2.Infcode != 0 {
  9310. c.ServeSuccessJSON(map[string]interface{}{
  9311. "failed_code": -10,
  9312. "msg": res2.ErrMsg,
  9313. })
  9314. return
  9315. } else {
  9316. c.ServeSuccessJSON(map[string]interface{}{
  9317. "msg": "查询成功",
  9318. })
  9319. }
  9320. }
  9321. func (c *HisApiController) Get4209() {
  9322. admin_user_id, _ := c.GetInt64("admin_user_id")
  9323. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9324. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9325. order_id, _ := c.GetInt64("order_id")
  9326. order, _ := service.GetHisOrderByIDTwo(order_id)
  9327. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9328. var struct4209 models.Struct4209
  9329. struct4209.FixmedinsMdtrtID = order.Number
  9330. struct4209.FixmedinsCode = miConfig.Code
  9331. struct4209.PageSize = "1000"
  9332. struct4209.PageNum = "1"
  9333. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9334. saveLog(result, requestLog, "4209", "查询")
  9335. var res2 ResultSix
  9336. var respJSON2 map[string]interface{}
  9337. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. userJSONBytes2, _ := json.Marshal(respJSON2)
  9343. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9344. utils.ErrorLog("解析失败:%v", err)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. if res2.Infcode != 0 {
  9349. c.ServeSuccessJSON(map[string]interface{}{
  9350. "failed_code": -10,
  9351. "msg": res2.ErrMsg,
  9352. })
  9353. return
  9354. } else {
  9355. c.ServeSuccessJSON(map[string]interface{}{
  9356. "msg": "查询成功",
  9357. })
  9358. }
  9359. }
  9360. type Result3101 struct {
  9361. Infcode string `json:"infcode"`
  9362. InfRefmsgid string `json:"inf_refmsgid"`
  9363. RefmsgTime string `json:"refmsg_time"`
  9364. RespondTime string `json:"respond_time"`
  9365. Enctype string `json:"enctype"`
  9366. Signtype string `json:"signtype"`
  9367. ErrMsg string `json:"err_msg"`
  9368. Output struct {
  9369. Result []struct {
  9370. JudgeResultDetailDtos []struct {
  9371. VolaItemType string `json:"vola_item_type"`
  9372. MdtrtID string `json:"mdtrt_id"`
  9373. JrdID string `json:"jrd_id"`
  9374. PatnID string `json:"patn_id"`
  9375. RxID string `json:"rx_id"`
  9376. VolaAmt interface{} `json:"vola_amt"`
  9377. } `json:"judge_result_detail_dtos"`
  9378. RuleID string `json:"rule_id"`
  9379. VolaEvid string `json:"vola_evid"`
  9380. MdtrtID string `json:"mdtrt_id"`
  9381. RuleName string `json:"rule_name"`
  9382. VolaAmtStas string `json:"vola_amt_stas"`
  9383. JrID string `json:"jr_id"`
  9384. PatnID string `json:"patn_id"`
  9385. SevDeg string `json:"sev_deg"`
  9386. VolaAmt float64 `json:"vola_amt"`
  9387. VolaBhvrType string `json:"vola_bhvr_type"`
  9388. VolaCont string `json:"vola_cont"`
  9389. } `json:"result"`
  9390. } `json:"output"`
  9391. }
  9392. type Resultgd3101 struct {
  9393. Infcode int64 `json:"infcode"`
  9394. InfRefmsgid string `json:"inf_refmsgid"`
  9395. RefmsgTime string `json:"refmsg_time"`
  9396. RespondTime string `json:"respond_time"`
  9397. Enctype string `json:"enctype"`
  9398. Signtype string `json:"signtype"`
  9399. ErrMsg string `json:"err_msg"`
  9400. Output struct {
  9401. Result []struct {
  9402. JudgeResultDetailDtos []struct {
  9403. VolaItemType string `json:"vola_item_type"`
  9404. MdtrtID string `json:"mdtrt_id"`
  9405. JrdID string `json:"jrd_id"`
  9406. PatnID string `json:"patn_id"`
  9407. RxID string `json:"rx_id"`
  9408. VolaAmt interface{} `json:"vola_amt"`
  9409. } `json:"judge_result_detail_dtos"`
  9410. RuleID string `json:"rule_id"`
  9411. VolaEvid string `json:"vola_evid"`
  9412. MdtrtID string `json:"mdtrt_id"`
  9413. RuleName string `json:"rule_name"`
  9414. VolaAmtStas string `json:"vola_amt_stas"`
  9415. JrID string `json:"jr_id"`
  9416. PatnID string `json:"patn_id"`
  9417. SevDeg string `json:"sev_deg"`
  9418. VolaAmt float64 `json:"vola_amt"`
  9419. VolaBhvrType string `json:"vola_bhvr_type"`
  9420. VolaCont string `json:"vola_cont"`
  9421. } `json:"result"`
  9422. } `json:"output"`
  9423. }
  9424. func (c *HisApiController) ReadEleToken() {
  9425. admin_user_id, _ := c.GetInt64("admin_user_id")
  9426. his_patient_id, _ := c.GetInt64("his_patient_id")
  9427. adminUser := c.GetAdminUserInfo()
  9428. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9429. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9430. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9431. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9432. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9433. if len(tokens) > 0 {
  9434. c.ServeSuccessJSON(map[string]interface{}{
  9435. "msg": "读取成功",
  9436. })
  9437. } else {
  9438. c.ServeSuccessJSON(map[string]interface{}{
  9439. "failed_code": -10,
  9440. "msg": "读取失败",
  9441. })
  9442. }
  9443. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9444. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9445. if len(tokens) > 0 {
  9446. c.ServeSuccessJSON(map[string]interface{}{
  9447. "msg": "读取成功",
  9448. })
  9449. } else {
  9450. c.ServeSuccessJSON(map[string]interface{}{
  9451. "failed_code": -10,
  9452. "msg": "读取失败",
  9453. })
  9454. }
  9455. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9456. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9457. if len(tokens) > 0 {
  9458. c.ServeSuccessJSON(map[string]interface{}{
  9459. "msg": "读取成功",
  9460. })
  9461. } else {
  9462. c.ServeSuccessJSON(map[string]interface{}{
  9463. "failed_code": -10,
  9464. "msg": "读取失败",
  9465. })
  9466. }
  9467. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9468. var api string
  9469. 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 +
  9470. "&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"
  9471. resp, requestErr := http.Get(api)
  9472. if requestErr != nil {
  9473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9474. }
  9475. body, ioErr := ioutil.ReadAll(resp.Body)
  9476. if ioErr != nil {
  9477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. }
  9480. var respJSON map[string]interface{}
  9481. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. return
  9485. }
  9486. var status string
  9487. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9488. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9489. var token string
  9490. var res ResultTwo //1101结果
  9491. var res10265 ResultTwo10265 //1101结果
  9492. if status == "0" { //读卡成功
  9493. var card_info string //卡信息
  9494. var busi_card_info string
  9495. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9496. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9497. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9498. fmt.Println(card_info)
  9499. fmt.Println(busi_card_info)
  9500. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9501. result, _ := json.Marshal(respJSON)
  9502. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9503. utils.ErrorLog("解析失败:%v", err)
  9504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9505. return
  9506. }
  9507. res.ErrMsg = res10265.ErrMsg
  9508. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9509. res.Infcode = infocode
  9510. res.Output = res10265.Output
  9511. res.InfRefmsgid = res10265.InfRefmsgid
  9512. if res.Infcode == 0 {
  9513. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9514. if err == gorm.ErrRecordNotFound {
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9516. return
  9517. } else if err != nil {
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9519. return
  9520. } else {
  9521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9523. infoStr := string(Iinfos)
  9524. idetinfoStr := string(Idetinfos)
  9525. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9526. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9527. psn := &models.HisPsn{
  9528. PsnNo: res.Output.Baseinfo.PsnNo,
  9529. PatientId: patient.ID,
  9530. Certno: res.Output.Baseinfo.Certno,
  9531. Gend: res.Output.Baseinfo.Gend,
  9532. Naty: res.Output.Baseinfo.Naty,
  9533. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9534. PsnName: res.Output.Baseinfo.PsnName,
  9535. Age: float64(age),
  9536. Brdy: b,
  9537. Idetinfo: idetinfoStr,
  9538. Insuinfo: infoStr,
  9539. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9540. CardInfo: card_info,
  9541. VerifyNumber: token,
  9542. IdCardType: 4,
  9543. }
  9544. var rf []*ResultFive
  9545. json.Unmarshal([]byte(infoStr), &rf)
  9546. var insutypes []*ResultFive
  9547. var insutype string
  9548. var is390 int = 0
  9549. var is310 int = 0
  9550. for _, item := range rf {
  9551. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9552. insutypes = append(insutypes, item)
  9553. }
  9554. }
  9555. if len(insutypes) == 1 {
  9556. insutype = insutypes[0].Insutype
  9557. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9558. } else {
  9559. for _, i := range insutypes {
  9560. if i.Insutype == "390" {
  9561. is390 = 1
  9562. }
  9563. if i.Insutype == "310" {
  9564. is310 = 1
  9565. }
  9566. }
  9567. }
  9568. if is390 == 1 {
  9569. insutype = "390"
  9570. }
  9571. if is310 == 1 {
  9572. insutype = "310"
  9573. }
  9574. if len(insutypes) == 0 {
  9575. insutype = "310"
  9576. }
  9577. service.CreateHisPsn(psn)
  9578. c.ServeSuccessJSON(map[string]interface{}{
  9579. "patient": patient,
  9580. "number": token,
  9581. "insutype": insutype,
  9582. })
  9583. }
  9584. } else {
  9585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9586. return
  9587. }
  9588. } else { //读卡失败
  9589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9590. return
  9591. }
  9592. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9593. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9594. if len(errMsg) == 0 {
  9595. type ELeData struct {
  9596. Data struct {
  9597. IdNo string `json:"idNo"`
  9598. IdType string `json:"idType"`
  9599. UserName string `json:"userName"`
  9600. EcToken string `json:"ecToken"`
  9601. InsuOrg string `json:"insuOrg"`
  9602. Gender string `json:"gender"`
  9603. Birthday string `json:"birthday"`
  9604. Nationality string `json:"nationality"`
  9605. Email string `json:"email"`
  9606. Extra string `json:"extra"`
  9607. } `json:"data"`
  9608. Code int `json:"code"`
  9609. Message string `json:"message"`
  9610. }
  9611. var ele ELeData
  9612. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9613. if err != nil {
  9614. utils.ErrorLog("解析失败:%v", err)
  9615. }
  9616. token := ele.Data.EcToken
  9617. if len(token) > 0 {
  9618. psn := &models.HisPsn{
  9619. PsnNo: his.PsnNo,
  9620. Age: 0,
  9621. PatientId: his.PatientId,
  9622. Certno: his.Certno,
  9623. Brdy: his.Brdy,
  9624. Gend: his.Gend,
  9625. Naty: his.Naty,
  9626. PsnCertType: his.PsnCertType,
  9627. PsnName: his.PsnName,
  9628. Idetinfo: his.Idetinfo,
  9629. Insuinfo: his.Iinfo,
  9630. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9631. CardInfo: outPutInfo,
  9632. VerifyNumber: token,
  9633. }
  9634. service.CreateHisPsn(psn)
  9635. }
  9636. if len(token) > 0 {
  9637. c.ServeSuccessJSON(map[string]interface{}{
  9638. "msg": "读取成功",
  9639. })
  9640. } else {
  9641. c.ServeSuccessJSON(map[string]interface{}{
  9642. "failed_code": -10,
  9643. "msg": "读取失败",
  9644. })
  9645. }
  9646. }
  9647. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9648. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9649. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9650. type ELeData struct {
  9651. Data struct {
  9652. IdNo string `json:"idNo"`
  9653. IdType string `json:"idType"`
  9654. UserName string `json:"userName"`
  9655. EcToken string `json:"ecToken"`
  9656. InsuOrg string `json:"insuOrg"`
  9657. Gender string `json:"gender"`
  9658. Birthday string `json:"birthday"`
  9659. Nationality string `json:"nationality"`
  9660. Email string `json:"email"`
  9661. Extra string `json:"extra"`
  9662. } `json:"data"`
  9663. Code int `json:"code"`
  9664. Message string `json:"message"`
  9665. }
  9666. var ele ELeData
  9667. err := json.Unmarshal([]byte(result), &ele)
  9668. if err != nil {
  9669. utils.ErrorLog("解析失败:%v", err)
  9670. }
  9671. token := ele.Data.EcToken
  9672. token = Remove0000(token)
  9673. fmt.Println(ele.Data.UserName)
  9674. 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)
  9675. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9676. var res ResultTwo
  9677. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9678. utils.ErrorLog("解析失败:%v", err)
  9679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9680. return
  9681. }
  9682. if res.Infcode == 0 {
  9683. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9684. if err == gorm.ErrRecordNotFound {
  9685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9686. return
  9687. } else if err != nil {
  9688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9689. return
  9690. } else {
  9691. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9692. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9693. infoStr := string(Iinfos)
  9694. idetinfoStr := string(Idetinfos)
  9695. psn := &models.HisPsn{
  9696. PsnNo: res.Output.Baseinfo.PsnNo,
  9697. PatientId: patient.ID,
  9698. Certno: res.Output.Baseinfo.Certno,
  9699. Gend: res.Output.Baseinfo.Gend,
  9700. Naty: res.Output.Baseinfo.Naty,
  9701. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9702. PsnName: res.Output.Baseinfo.PsnName,
  9703. Idetinfo: idetinfoStr,
  9704. Insuinfo: infoStr,
  9705. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9706. CardInfo: "",
  9707. VerifyNumber: token,
  9708. }
  9709. service.CreateHisPsn(psn)
  9710. c.ServeSuccessJSON(map[string]interface{}{
  9711. "patient": patient,
  9712. "number": token,
  9713. })
  9714. }
  9715. } else {
  9716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9717. return
  9718. }
  9719. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9720. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9721. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9722. type ELeData struct {
  9723. Data struct {
  9724. IdNo string `json:"idNo"`
  9725. IdType string `json:"idType"`
  9726. UserName string `json:"userName"`
  9727. EcToken string `json:"ecToken"`
  9728. InsuOrg string `json:"insuOrg"`
  9729. Gender string `json:"gender"`
  9730. Birthday string `json:"birthday"`
  9731. Nationality string `json:"nationality"`
  9732. Email string `json:"email"`
  9733. Extra string `json:"extra"`
  9734. } `json:"data"`
  9735. Code int `json:"code"`
  9736. Message string `json:"message"`
  9737. }
  9738. var ele ELeData
  9739. err := json.Unmarshal([]byte(result), &ele)
  9740. if err != nil {
  9741. utils.ErrorLog("解析失败:%v", err)
  9742. }
  9743. token := ele.Data.EcToken
  9744. token = Remove0000(token)
  9745. fmt.Println(ele.Data.UserName)
  9746. 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)
  9747. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9748. var res ResultTwo
  9749. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9750. utils.ErrorLog("解析失败:%v", err)
  9751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9752. return
  9753. }
  9754. if res.Infcode == 0 {
  9755. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9756. if err == gorm.ErrRecordNotFound {
  9757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9758. return
  9759. } else if err != nil {
  9760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9761. return
  9762. } else {
  9763. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9764. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9765. infoStr := string(Iinfos)
  9766. idetinfoStr := string(Idetinfos)
  9767. psn := &models.HisPsn{
  9768. PsnNo: res.Output.Baseinfo.PsnNo,
  9769. PatientId: patient.ID,
  9770. Certno: res.Output.Baseinfo.Certno,
  9771. Gend: res.Output.Baseinfo.Gend,
  9772. Naty: res.Output.Baseinfo.Naty,
  9773. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9774. PsnName: res.Output.Baseinfo.PsnName,
  9775. Idetinfo: idetinfoStr,
  9776. Insuinfo: infoStr,
  9777. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9778. CardInfo: "",
  9779. VerifyNumber: token,
  9780. }
  9781. service.CreateHisPsn(psn)
  9782. c.ServeSuccessJSON(map[string]interface{}{
  9783. "patient": patient,
  9784. "number": token,
  9785. })
  9786. }
  9787. } else {
  9788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9789. return
  9790. }
  9791. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9792. //if initFlag == 0 {
  9793. //c.TestGetJiangXiBasBaseInit()
  9794. //}
  9795. //if initEleFlag == 0 {
  9796. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9797. //}
  9798. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9799. utils.ErrorLog("解析失败:%v", json_result)
  9800. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9801. type ELeData struct {
  9802. Data struct {
  9803. IdNo string `json:"idNo"`
  9804. IdType string `json:"idType"`
  9805. UserName string `json:"userName"`
  9806. EcToken string `json:"ecToken"`
  9807. InsuOrg string `json:"insuOrg"`
  9808. Gender string `json:"gender"`
  9809. Birthday string `json:"birthday"`
  9810. Nationality string `json:"nationality"`
  9811. Email string `json:"email"`
  9812. Extra string `json:"extra"`
  9813. } `json:"data"`
  9814. Code int `json:"code"`
  9815. Message string `json:"message"`
  9816. }
  9817. var ele ELeData
  9818. err := json.Unmarshal([]byte(json_result), &ele)
  9819. if err != nil {
  9820. utils.ErrorLog("解析失败:%v", err)
  9821. }
  9822. token := ele.Data.EcToken
  9823. token = Remove0000(token)
  9824. //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)
  9825. 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)
  9826. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9827. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9828. var res ResultTwo
  9829. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9830. utils.ErrorLog("解析失败:%v", err)
  9831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9832. return
  9833. }
  9834. if res.Infcode == 0 {
  9835. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9836. if err == gorm.ErrRecordNotFound {
  9837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9838. return
  9839. } else if err != nil {
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9841. return
  9842. } else {
  9843. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9844. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9845. infoStr := string(Iinfos)
  9846. idetinfoStr := string(Idetinfos)
  9847. psn := &models.HisPsn{
  9848. PsnNo: res.Output.Baseinfo.PsnNo,
  9849. PatientId: patient.ID,
  9850. Certno: res.Output.Baseinfo.Certno,
  9851. Gend: res.Output.Baseinfo.Gend,
  9852. Naty: res.Output.Baseinfo.Naty,
  9853. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9854. PsnName: res.Output.Baseinfo.PsnName,
  9855. Idetinfo: idetinfoStr,
  9856. Insuinfo: infoStr,
  9857. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9858. CardInfo: "",
  9859. VerifyNumber: token,
  9860. InsuplcAdmdvs: ele.Data.InsuOrg,
  9861. }
  9862. service.CreateHisPsn(psn)
  9863. c.ServeSuccessJSON(map[string]interface{}{
  9864. "patient": patient,
  9865. "number": token,
  9866. })
  9867. }
  9868. } else {
  9869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9870. return
  9871. }
  9872. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9873. res := c.GetoleInfo()
  9874. if res.Infcode == 0 {
  9875. var result string
  9876. if res.Output.MdtrtCertType == "01" {
  9877. 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)
  9878. } else if res.Output.MdtrtCertType == "02" {
  9879. 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)
  9880. } else if res.Output.MdtrtCertType == "03" {
  9881. 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)
  9882. }
  9883. var dat map[string]interface{}
  9884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9885. fmt.Println(dat)
  9886. } else {
  9887. fmt.Println(err)
  9888. }
  9889. userJSONBytes, _ := json.Marshal(dat)
  9890. var res2 ResultTwo
  9891. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9892. utils.ErrorLog("解析失败:%v", err)
  9893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9894. return
  9895. }
  9896. if res2.Infcode == 0 {
  9897. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9898. if err == gorm.ErrRecordNotFound {
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9900. return
  9901. } else if err != nil {
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9903. return
  9904. } else {
  9905. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9906. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9907. infoStr := string(Iinfos)
  9908. idetinfoStr := string(Idetinfos)
  9909. var rf []*ResultFive
  9910. json.Unmarshal([]byte(infoStr), &rf)
  9911. var insutypes []*ResultFive
  9912. var insutype string
  9913. var is390 int = 0
  9914. var is310 int = 0
  9915. //var insuplc_admdvs string
  9916. for _, item := range rf {
  9917. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9918. insutypes = append(insutypes, item)
  9919. }
  9920. }
  9921. if len(insutypes) == 1 {
  9922. insutype = insutypes[0].Insutype
  9923. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9924. } else {
  9925. for _, i := range insutypes {
  9926. if i.Insutype == "390" {
  9927. is390 = 1
  9928. }
  9929. if i.Insutype == "310" {
  9930. is310 = 1
  9931. }
  9932. }
  9933. }
  9934. if is390 == 1 {
  9935. insutype = "390"
  9936. }
  9937. if is310 == 1 {
  9938. insutype = "310"
  9939. }
  9940. if len(insutypes) == 0 {
  9941. insutype = "310"
  9942. }
  9943. psn := &models.HisPsn{
  9944. PsnNo: res2.Output.Baseinfo.PsnNo,
  9945. PatientId: patient.ID,
  9946. Certno: res2.Output.Baseinfo.Certno,
  9947. Gend: res2.Output.Baseinfo.Gend,
  9948. Naty: res2.Output.Baseinfo.Naty,
  9949. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9950. PsnName: res2.Output.Baseinfo.PsnName,
  9951. Idetinfo: idetinfoStr,
  9952. Insuinfo: infoStr,
  9953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9954. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9955. VerifyNumber: res.Output.EcToken,
  9956. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9957. }
  9958. service.CreateHisPsn(psn)
  9959. c.ServeSuccessJSON(map[string]interface{}{
  9960. "patient": patient,
  9961. "number": res.Output.CardNo,
  9962. "insutype": insutype,
  9963. })
  9964. }
  9965. } else {
  9966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9967. return
  9968. }
  9969. } else {
  9970. c.ServeSuccessJSON(map[string]interface{}{
  9971. "failed_code": -10,
  9972. "msg": res.ErrMsg,
  9973. })
  9974. }
  9975. } else {
  9976. //if initFlag == 0 {
  9977. // c.TestGetBasBaseInit()
  9978. //}
  9979. //token := c.GetEleBaseInfo()
  9980. //token = Remove0000(token)
  9981. type ELeData struct {
  9982. Code string `json:"code"`
  9983. Data struct {
  9984. Aac002 string `json:"aac002"`
  9985. Aaz500 string `json:"aaz500"`
  9986. ActCardNo string `json:"actCardNo"`
  9987. Bab520 string `json:"bab520"`
  9988. Bkz543 string `json:"bkz543"`
  9989. BusinessType string `json:"businessType"`
  9990. CertfCodg string `json:"certfCodg"`
  9991. EcIndexNo string `json:"ecIndexNo"`
  9992. EcToken string `json:"ecToken"`
  9993. ID0000 string `json:"id0000"`
  9994. IDNo string `json:"idNo"`
  9995. IDType string `json:"idType"`
  9996. Idcode string `json:"idcode"`
  9997. IdentityToken string `json:"identity_token"`
  9998. InsuOrg string `json:"insuOrg"`
  9999. OfficeID string `json:"officeId"`
  10000. OfficeName string `json:"officeName"`
  10001. OperatorID string `json:"operatorId"`
  10002. OperatorName string `json:"operatorName"`
  10003. OrgID string `json:"orgId"`
  10004. UserName string `json:"userName"`
  10005. } `json:"data"`
  10006. Infno interface{} `json:"infno"`
  10007. Message string `json:"message"`
  10008. OrgID string `json:"orgId"`
  10009. TransType string `json:"transType"`
  10010. }
  10011. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10012. fmt.Println(result)
  10013. outPutInfo := Remove0000(result)
  10014. fmt.Println(outPutInfo)
  10015. var ele ELeData
  10016. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10017. if err != nil {
  10018. utils.ErrorLog("解析失败:%v", err)
  10019. }
  10020. token := ele.Data.EcToken
  10021. var result2 string
  10022. var requestLog2 string
  10023. if len(token) > 0 {
  10024. if strings.Contains(ele.Data.IDNo, "HKG") {
  10025. 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)
  10026. } else {
  10027. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10028. }
  10029. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10030. var res ResultTwo
  10031. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10032. utils.ErrorLog("解析失败:%v", err)
  10033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10034. return
  10035. }
  10036. if res.Infcode == 0 {
  10037. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10038. if err == gorm.ErrRecordNotFound {
  10039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10040. return
  10041. } else if err != nil {
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10043. return
  10044. } else {
  10045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10047. infoStr := string(Iinfos)
  10048. idetinfoStr := string(Idetinfos)
  10049. psn := &models.HisPsn{
  10050. PsnNo: res.Output.Baseinfo.PsnNo,
  10051. PatientId: patient.ID,
  10052. Certno: res.Output.Baseinfo.Certno,
  10053. Gend: res.Output.Baseinfo.Gend,
  10054. Naty: res.Output.Baseinfo.Naty,
  10055. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10056. PsnName: res.Output.Baseinfo.PsnName,
  10057. Idetinfo: idetinfoStr,
  10058. Insuinfo: infoStr,
  10059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10060. CardInfo: "",
  10061. VerifyNumber: token,
  10062. }
  10063. service.CreateHisPsn(psn)
  10064. c.ServeSuccessJSON(map[string]interface{}{
  10065. "msg": "读取成功",
  10066. })
  10067. }
  10068. } else {
  10069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10070. return
  10071. }
  10072. } else {
  10073. c.ServeSuccessJSON(map[string]interface{}{
  10074. "failed_code": -10,
  10075. "msg": "读取失败",
  10076. })
  10077. }
  10078. }
  10079. }
  10080. func (c *HisApiController) ReadEleFace() {
  10081. admin_user_id, _ := c.GetInt64("admin_user_id")
  10082. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10083. adminUser := c.GetAdminUserInfo()
  10084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10085. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10086. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10087. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10088. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10089. if len(tokens) > 0 {
  10090. c.ServeSuccessJSON(map[string]interface{}{
  10091. "msg": "读取成功",
  10092. })
  10093. } else {
  10094. c.ServeSuccessJSON(map[string]interface{}{
  10095. "failed_code": -10,
  10096. "msg": "读取失败",
  10097. })
  10098. }
  10099. }
  10100. }
  10101. func (c *HisApiController) Get9001() {
  10102. adminUser := c.GetAdminUserInfo()
  10103. admin_user_id, _ := c.GetInt64("admin_user_id")
  10104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10105. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10106. if miConfig.MdtrtareaAdmvs == "350500" {
  10107. service.GetFjAuthorizationInfo(miConfig.Code)
  10108. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10109. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10110. var dat map[string]interface{}
  10111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10112. fmt.Println(dat)
  10113. } else {
  10114. fmt.Println(err)
  10115. }
  10116. userJSONBytes, _ := json.Marshal(dat)
  10117. var res models.Result9001
  10118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10119. utils.ErrorLog("解析失败:%v", err)
  10120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10121. return
  10122. }
  10123. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10124. fmt.Println(miConfig.SecretKey)
  10125. var res models.Result9001Two
  10126. 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 +
  10127. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10128. resp, requestErr := http.Get(api)
  10129. if requestErr != nil {
  10130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10131. return
  10132. }
  10133. body, ioErr := ioutil.ReadAll(resp.Body)
  10134. if ioErr != nil {
  10135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10137. return
  10138. }
  10139. var respJSON map[string]interface{}
  10140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10146. if status == "0" {
  10147. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10148. c.ServeSuccessJSON(map[string]interface{}{
  10149. "failed_code": -10,
  10150. "msg": err_msg,
  10151. })
  10152. return
  10153. }
  10154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10155. result, _ := json.Marshal(respJSON)
  10156. fmt.Println("log")
  10157. fmt.Println(string(result))
  10158. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10159. utils.ErrorLog("解析失败:%v", err)
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10161. return
  10162. }
  10163. if res.Infcode == 0 {
  10164. sign := models.HisSignIn{
  10165. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10166. SignNo: res.Output.Signinoutb.SignNo,
  10167. SignTime: "",
  10168. Ctime: time.Now().Unix(),
  10169. Mtime: time.Now().Unix(),
  10170. Status: 1,
  10171. InputLog: "",
  10172. OutputLog: "",
  10173. FixmedinsCode: miConfig.Code,
  10174. }
  10175. err := service.CreateSignIn(&sign)
  10176. if err == nil {
  10177. c.ServeSuccessJSON(map[string]interface{}{
  10178. "msg": "签到成功",
  10179. })
  10180. }
  10181. } else {
  10182. c.ServeSuccessJSON(map[string]interface{}{
  10183. "failed_code": -10,
  10184. "msg": res.ErrMsg,
  10185. })
  10186. return
  10187. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10188. //return
  10189. }
  10190. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10191. fmt.Println(miConfig.SecretKey)
  10192. var res models.Result9001Two
  10193. 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 +
  10194. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10195. resp, requestErr := http.Get(api)
  10196. if requestErr != nil {
  10197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10198. return
  10199. }
  10200. body, ioErr := ioutil.ReadAll(resp.Body)
  10201. if ioErr != nil {
  10202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10204. return
  10205. }
  10206. var respJSON map[string]interface{}
  10207. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10210. return
  10211. }
  10212. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10213. if status == "0" {
  10214. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10215. c.ServeSuccessJSON(map[string]interface{}{
  10216. "failed_code": -10,
  10217. "msg": err_msg,
  10218. })
  10219. return
  10220. }
  10221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10222. result, _ := json.Marshal(respJSON)
  10223. fmt.Println("log")
  10224. fmt.Println(string(result))
  10225. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10226. utils.ErrorLog("解析失败:%v", err)
  10227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10228. return
  10229. }
  10230. if res.Infcode == 0 {
  10231. sign := models.HisSignIn{
  10232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10233. SignNo: res.Output.Signinoutb.SignNo,
  10234. SignTime: "",
  10235. Ctime: time.Now().Unix(),
  10236. Mtime: time.Now().Unix(),
  10237. Status: 1,
  10238. InputLog: "",
  10239. OutputLog: "",
  10240. FixmedinsCode: miConfig.Code,
  10241. }
  10242. err := service.CreateSignIn(&sign)
  10243. if err == nil {
  10244. c.ServeSuccessJSON(map[string]interface{}{
  10245. "msg": "签到成功",
  10246. })
  10247. }
  10248. } else {
  10249. c.ServeSuccessJSON(map[string]interface{}{
  10250. "failed_code": -10,
  10251. "msg": res.ErrMsg,
  10252. })
  10253. return
  10254. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10255. //return
  10256. }
  10257. } else {
  10258. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10259. var dat map[string]interface{}
  10260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10261. fmt.Println(dat)
  10262. } else {
  10263. fmt.Println(err)
  10264. }
  10265. userJSONBytes, _ := json.Marshal(dat)
  10266. var res models.Result9001
  10267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10268. utils.ErrorLog("解析失败:%v", err)
  10269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10270. return
  10271. }
  10272. if res.Infcode == 0 {
  10273. sign := models.HisSignIn{
  10274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10275. SignNo: res.Output.Signinoutb.SignNo,
  10276. SignTime: res.Output.Signinoutb.SignTime,
  10277. Ctime: time.Now().Unix(),
  10278. Mtime: time.Now().Unix(),
  10279. Status: 1,
  10280. InputLog: "",
  10281. OutputLog: "",
  10282. FixmedinsCode: miConfig.Code,
  10283. }
  10284. err := service.CreateSignIn(&sign)
  10285. if err == nil {
  10286. c.ServeSuccessJSON(map[string]interface{}{
  10287. "msg": "签到成功",
  10288. })
  10289. }
  10290. }
  10291. }
  10292. }
  10293. 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) {
  10294. var res Result3101
  10295. adminUser := c.GetAdminUserInfo()
  10296. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10297. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10299. //record_time := c.GetString("record_time")
  10300. //trig_scen := c.GetString("trig_scen")
  10301. timeLayout := "2006-01-02"
  10302. loc, _ := time.LoadLocation("Local")
  10303. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10304. if err != nil {
  10305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10306. return res
  10307. }
  10308. recordDateTime := theTime.Unix()
  10309. var patientPrescription models.HisPrescriptionInfo
  10310. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10311. //if patientPrescription.ID == 0 {
  10312. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10313. //}
  10314. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10315. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10316. //
  10317. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10318. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10319. var pp models.PublicParams
  10320. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10321. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10322. pp.FixmedinsName = miConfig.OrgName
  10323. pp.FixmedinsCode = miConfig.Code
  10324. pp.RequestUrl = miConfig.Url
  10325. pp.Cainfo = miConfig.Cainfo
  10326. pp.SecretKey = miConfig.SecretKey
  10327. pp.AccessKey = miConfig.AccessKey
  10328. pp.OpterName = roles.UserName
  10329. var config []*models.HisXtDiagnoseConfig
  10330. for _, item := range diagnosis_ids {
  10331. id, _ := strconv.ParseInt(item, 10, 64)
  10332. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10333. config = append(config, &diagnosisConfig)
  10334. }
  10335. var pd models.PatientDtos
  10336. pd.PatnID = his.PsnNo
  10337. pd.PatnName = his.Name
  10338. pd.Gend = his.Gend
  10339. pd.Brdy = his.Brdy
  10340. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10341. pd.CurrMdtrtID = his.Number
  10342. var fed models.FsiEncounterDtos
  10343. fed.MdtrtID = his.Number
  10344. fed.MedinsID = miConfig.Code
  10345. fed.MedinsName = miConfig.OrgName
  10346. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10347. fed.MedMdtrtType = "1"
  10348. fed.MedinsType = "1"
  10349. fed.MedinsLv = "11"
  10350. tm := time.Unix(his.RecordDate, 0)
  10351. s_tm := tm.Format("2006-01-02 15:04:05")
  10352. fed.AdmDate = s_tm
  10353. fed.DscgDate = s_tm
  10354. fed.DscgMainDiseCodg = config[0].CountryCode
  10355. fed.DscgMainDiseName = config[0].CountryContentName
  10356. //诊断信息
  10357. var fdds []*models.FsiDiagnoseDtos
  10358. for index, item := range config {
  10359. if index == 0 {
  10360. var fdd models.FsiDiagnoseDtos
  10361. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10362. fdd.InoutDiseType = "1"
  10363. fdd.MaindiseFlag = "1"
  10364. fdd.DiseDate = s_tm
  10365. fdd.DiasSrtNo = "1"
  10366. fdd.DiseName = item.CountryContentName
  10367. fdd.DiseCodg = item.CountryCode
  10368. fdds = append(fdds, &fdd)
  10369. } else {
  10370. var fdd models.FsiDiagnoseDtos
  10371. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10372. fdd.InoutDiseType = "1"
  10373. fdd.MaindiseFlag = "1"
  10374. fdd.DiseDate = s_tm
  10375. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10376. fdd.DiseName = item.CountryContentName
  10377. fdd.DiseCodg = item.CountryCode
  10378. fdds = append(fdds, &fdd)
  10379. }
  10380. }
  10381. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10382. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10383. fed.AdmDeptName = de.Name
  10384. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10385. fed.DscgDeptName = de.Name
  10386. fed.MedMdtrtType = "1"
  10387. fed.MedType = "11"
  10388. //if his.Insutype == "390" {
  10389. // fed.MedType = "1402"
  10390. //} else {
  10391. // fed.MedType = "9933"
  10392. //}
  10393. var orders []*models.FsiOrderDtos
  10394. if trig_scen == "2" {
  10395. //处方医嘱信息
  10396. for _, item := range prescriptions {
  10397. for _, subItem := range item.HisDoctorAdviceInfo {
  10398. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10399. var order models.FsiOrderDtos
  10400. order.RxID = strconv.FormatInt(item.ID, 10)
  10401. order.Rxno = strconv.FormatInt(item.ID, 10)
  10402. order.LongDrordFlag = "0"
  10403. order.HilistType = "1"
  10404. order.ChrgType = "1"
  10405. order.DrordBhvr = "-"
  10406. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10407. order.HosplistName = subItem.BaseDrugLib.DrugName
  10408. order.HilistLv = "1"
  10409. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10410. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10411. order.HosplistName = subItem.BaseDrugLib.DrugName
  10412. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10413. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10414. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  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. for _, subItem := range item.HisPrescriptionProject {
  10431. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10432. var order models.FsiOrderDtos
  10433. order.RxID = strconv.FormatInt(item.ID, 10)
  10434. order.Rxno = strconv.FormatInt(item.ID, 10)
  10435. order.LongDrordFlag = "0"
  10436. order.HilistType = "1"
  10437. order.ChrgType = "1"
  10438. order.DrordBhvr = "-"
  10439. order.HilistCode = subItem.HisProject.MedicalCode
  10440. order.HosplistName = subItem.HisProject.ProjectName
  10441. order.HilistLv = "1"
  10442. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10443. order.HosplistCode = subItem.HisProject.MedicalCode
  10444. order.HosplistName = subItem.HisProject.ProjectName
  10445. order.Cnt = subItem.Count
  10446. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10447. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10448. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10449. order.OwnpayAmt = ""
  10450. order.SelfpayAmt = ""
  10451. order.Spec = ""
  10452. order.SpecUnt = ""
  10453. order.DrordBegnDate = s_tm
  10454. order.DrordStopDate = ""
  10455. order.DrordDrCodg = doctor_info.DoctorNumber
  10456. order.DrordDeptName = department.Name
  10457. order.DrordDeptCodg = department.Number
  10458. order.DrordDrName = doctor_info.UserName
  10459. order.DrordDrProfttl = "234"
  10460. order.CurrDrordFlag = "1"
  10461. orders = append(orders, &order)
  10462. }
  10463. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10464. var order models.FsiOrderDtos
  10465. order.RxID = strconv.FormatInt(item.ID, 10)
  10466. order.Rxno = strconv.FormatInt(item.ID, 10)
  10467. order.LongDrordFlag = "0"
  10468. order.HilistType = "1"
  10469. order.ChrgType = "1"
  10470. order.DrordBhvr = "-"
  10471. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10472. order.HosplistName = subItem.GoodInfo.GoodName
  10473. order.HilistLv = "1"
  10474. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10475. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10476. order.HosplistName = subItem.GoodInfo.GoodName
  10477. order.Cnt = subItem.Count
  10478. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10479. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10480. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10481. order.OwnpayAmt = ""
  10482. order.SelfpayAmt = ""
  10483. order.Spec = ""
  10484. order.SpecUnt = ""
  10485. order.DrordBegnDate = s_tm
  10486. order.DrordStopDate = ""
  10487. order.DrordDrCodg = doctor_info.DoctorNumber
  10488. order.DrordDeptName = department.Name
  10489. order.DrordDeptCodg = department.Number
  10490. order.DrordDrName = doctor_info.UserName
  10491. order.DrordDrProfttl = "234"
  10492. order.CurrDrordFlag = "1"
  10493. orders = append(orders, &order)
  10494. }
  10495. }
  10496. }
  10497. //处方医嘱信息
  10498. }
  10499. fed.MatnStas = "0"
  10500. fed.MedfeeSumamt = "0"
  10501. fed.OwnpayAmt = "0"
  10502. fed.SelfpayAmt = "0"
  10503. fed.AcctPayamt = "0"
  10504. fed.MaAmt = "0"
  10505. fed.HifpPayamt = "0"
  10506. fed.SetlTotlnum = "1"
  10507. fed.Insutype = his.Insutype
  10508. fed.ReimFlag = "0"
  10509. fed.OutSetlFlag = "0"
  10510. var fopd []*models.FsiOperationDtosData
  10511. data := make(map[string]interface{})
  10512. data["fed"] = fed
  10513. data["fdd"] = fdds
  10514. data["fod"] = orders
  10515. data["pd"] = pd
  10516. data["pp"] = pp
  10517. data["fopd"] = fopd
  10518. data["trig_scen"] = trig_scen
  10519. fmt.Println(data)
  10520. fmt.Println(fed)
  10521. fmt.Println(fdds)
  10522. fmt.Println(orders)
  10523. fmt.Println(pd)
  10524. fmt.Println(pp)
  10525. fmt.Println(fopd)
  10526. client := &http.Client{}
  10527. bytesData, _ := json.Marshal(data)
  10528. var req *http.Request
  10529. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10530. if miConfig.MdtrtareaAdmvs == "320921" {
  10531. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10532. } else {
  10533. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10534. }
  10535. resp, _ := client.Do(req)
  10536. defer resp.Body.Close()
  10537. body, ioErr := ioutil.ReadAll(resp.Body)
  10538. if ioErr != nil {
  10539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10541. return res
  10542. }
  10543. var respJSON map[string]interface{}
  10544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10547. return res
  10548. }
  10549. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10550. fmt.Println(respJSON)
  10551. result, _ := json.Marshal(respJSON)
  10552. fmt.Println(result)
  10553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10554. utils.ErrorLog("解析失败:%v", err)
  10555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10556. return res
  10557. }
  10558. return res
  10559. } else {
  10560. //if miConfig.MdtrtareaAdmvs == "441202" {
  10561. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10562. saveLog(output, input, "3101", "事前")
  10563. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10564. utils.ErrorLog("解析失败:%v", err)
  10565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10566. return
  10567. }
  10568. return res
  10569. //}
  10570. }
  10571. }
  10572. 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) {
  10573. adminUser := c.GetAdminUserInfo()
  10574. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10575. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10577. //record_time := c.GetString("record_time")
  10578. //trig_scen := c.GetString("trig_scen")
  10579. timeLayout := "2006-01-02"
  10580. loc, _ := time.LoadLocation("Local")
  10581. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10582. if err != nil {
  10583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10584. return res
  10585. }
  10586. recordDateTime := theTime.Unix()
  10587. var patientPrescription models.HisPrescriptionInfo
  10588. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10589. if patientPrescription.ID == 0 {
  10590. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10591. }
  10592. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10593. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10594. //
  10595. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10596. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10597. var pp models.PublicParams
  10598. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10599. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10600. pp.FixmedinsName = miConfig.OrgName
  10601. pp.FixmedinsCode = miConfig.Code
  10602. pp.RequestUrl = miConfig.Url
  10603. pp.Cainfo = miConfig.Cainfo
  10604. pp.SecretKey = miConfig.SecretKey
  10605. pp.AccessKey = miConfig.AccessKey
  10606. pp.OpterName = roles.UserName
  10607. var config []*models.HisXtDiagnoseConfig
  10608. for _, item := range diagnosis_ids {
  10609. id, _ := strconv.ParseInt(item, 10, 64)
  10610. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10611. config = append(config, &diagnosisConfig)
  10612. }
  10613. var pd models.PatientDtos
  10614. pd.PatnID = his.PsnNo
  10615. pd.PatnName = his.Name
  10616. pd.Gend = his.Gend
  10617. pd.Brdy = his.Brdy
  10618. pd.Poolarea = his.InsuplcAdmdvs
  10619. pd.CurrMdtrtID = his.Number
  10620. var fed models.FsiEncounterDtos
  10621. fed.MdtrtID = his.Number
  10622. fed.MedinsID = miConfig.Code
  10623. fed.MedinsName = miConfig.OrgName
  10624. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10625. fed.MedMdtrtType = "1"
  10626. fed.MedinsType = "1"
  10627. fed.MedinsLv = "11"
  10628. tm := time.Unix(his.RecordDate, 0)
  10629. s_tm := tm.Format("2006-01-02 15:04:05")
  10630. fed.AdmDate = s_tm
  10631. fed.DscgDate = s_tm
  10632. fed.DscgMainDiseCodg = config[0].CountryCode
  10633. fed.DscgMainDiseName = config[0].CountryContentName
  10634. //诊断信息
  10635. var fdds []*models.FsiDiagnoseDtos
  10636. for index, item := range config {
  10637. if index == 0 {
  10638. var fdd models.FsiDiagnoseDtos
  10639. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10640. fdd.InoutDiseType = "1"
  10641. fdd.MaindiseFlag = "1"
  10642. fdd.DiseDate = s_tm
  10643. fdd.DiasSrtNo = "1"
  10644. fdd.DiseName = item.CountryContentName
  10645. fdd.DiseCodg = item.CountryCode
  10646. fdds = append(fdds, &fdd)
  10647. } else {
  10648. var fdd models.FsiDiagnoseDtos
  10649. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10650. fdd.InoutDiseType = "1"
  10651. fdd.MaindiseFlag = "1"
  10652. fdd.DiseDate = s_tm
  10653. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10654. fdd.DiseName = item.CountryContentName
  10655. fdd.DiseCodg = item.CountryCode
  10656. fdds = append(fdds, &fdd)
  10657. }
  10658. }
  10659. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10660. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10661. fed.AdmDeptName = department.Name
  10662. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10663. fed.DscgDeptName = department.Name
  10664. fed.MedMdtrtType = "1"
  10665. fed.MedType = "11"
  10666. //if his.Insutype == "390" {
  10667. // fed.MedType = "1402"
  10668. //} else {
  10669. // fed.MedType = "9933"
  10670. //}
  10671. var orders []*models.FsiOrderDtos
  10672. if trig_scen == "2" {
  10673. //处方医嘱信息
  10674. for _, item := range prescriptions {
  10675. for _, subItem := range item.HisDoctorAdviceInfo {
  10676. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10677. var order models.FsiOrderDtos
  10678. order.RxID = strconv.FormatInt(item.ID, 10)
  10679. order.Rxno = strconv.FormatInt(item.ID, 10)
  10680. order.LongDrordFlag = "0"
  10681. order.HilistType = "1"
  10682. order.ChrgType = "1"
  10683. order.DrordBhvr = "-"
  10684. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10685. order.HosplistName = subItem.BaseDrugLib.DrugName
  10686. order.HilistLv = "1"
  10687. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10688. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10689. order.HosplistName = subItem.BaseDrugLib.DrugName
  10690. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10692. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  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. for _, subItem := range item.HisPrescriptionProject {
  10709. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10710. var order models.FsiOrderDtos
  10711. order.RxID = strconv.FormatInt(item.ID, 10)
  10712. order.Rxno = strconv.FormatInt(item.ID, 10)
  10713. order.LongDrordFlag = "0"
  10714. order.HilistType = "1"
  10715. order.ChrgType = "1"
  10716. order.DrordBhvr = "-"
  10717. order.HilistCode = subItem.HisProject.MedicalCode
  10718. order.HosplistName = subItem.HisProject.ProjectName
  10719. order.HilistLv = "1"
  10720. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10721. order.HosplistCode = subItem.HisProject.MedicalCode
  10722. order.HosplistName = subItem.HisProject.ProjectName
  10723. order.Cnt = subItem.Count
  10724. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10725. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10726. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10727. order.OwnpayAmt = ""
  10728. order.SelfpayAmt = ""
  10729. order.Spec = ""
  10730. order.SpecUnt = ""
  10731. order.DrordBegnDate = s_tm
  10732. order.DrordStopDate = ""
  10733. order.DrordDrCodg = doctor_info.DoctorNumber
  10734. order.DrordDeptName = department.Name
  10735. order.DrordDeptCodg = department.Number
  10736. order.DrordDrName = doctor_info.UserName
  10737. order.DrordDrProfttl = "234"
  10738. order.CurrDrordFlag = "1"
  10739. orders = append(orders, &order)
  10740. }
  10741. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10742. var order models.FsiOrderDtos
  10743. order.RxID = strconv.FormatInt(item.ID, 10)
  10744. order.Rxno = strconv.FormatInt(item.ID, 10)
  10745. order.LongDrordFlag = "0"
  10746. order.HilistType = "1"
  10747. order.ChrgType = "1"
  10748. order.DrordBhvr = "-"
  10749. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10750. order.HosplistName = subItem.GoodInfo.GoodName
  10751. order.HilistLv = "1"
  10752. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10753. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10754. order.HosplistName = subItem.GoodInfo.GoodName
  10755. order.Cnt = subItem.Count
  10756. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10757. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10758. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10759. order.OwnpayAmt = ""
  10760. order.SelfpayAmt = ""
  10761. order.Spec = ""
  10762. order.SpecUnt = ""
  10763. order.DrordBegnDate = s_tm
  10764. order.DrordStopDate = ""
  10765. order.DrordDrCodg = doctor_info.DoctorNumber
  10766. order.DrordDeptName = department.Name
  10767. order.DrordDeptCodg = department.Number
  10768. order.DrordDrName = doctor_info.UserName
  10769. order.DrordDrProfttl = "234"
  10770. order.CurrDrordFlag = "1"
  10771. orders = append(orders, &order)
  10772. }
  10773. }
  10774. }
  10775. //处方医嘱信息
  10776. }
  10777. fed.MatnStas = "0"
  10778. fed.MedfeeSumamt = "0"
  10779. fed.OwnpayAmt = "0"
  10780. fed.SelfpayAmt = "0"
  10781. fed.AcctPayamt = "0"
  10782. fed.MaAmt = "0"
  10783. fed.HifpPayamt = "0"
  10784. fed.SetlTotlnum = "1"
  10785. fed.Insutype = his.Insutype
  10786. fed.ReimFlag = "0"
  10787. fed.OutSetlFlag = "0"
  10788. var fopd []*models.FsiOperationDtosData
  10789. data := make(map[string]interface{})
  10790. data["fed"] = fed
  10791. data["fdd"] = fdds
  10792. data["fod"] = orders
  10793. data["pd"] = pd
  10794. data["pp"] = pp
  10795. data["fopd"] = fopd
  10796. data["trig_scen"] = trig_scen
  10797. fmt.Println(data)
  10798. fmt.Println(fed)
  10799. fmt.Println(fdds)
  10800. fmt.Println(orders)
  10801. fmt.Println(pd)
  10802. fmt.Println(pp)
  10803. fmt.Println(fopd)
  10804. client := &http.Client{}
  10805. bytesData, _ := json.Marshal(data)
  10806. var req *http.Request
  10807. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10808. if miConfig.MdtrtareaAdmvs == "320921" {
  10809. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10810. } else {
  10811. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10812. }
  10813. resp, _ := client.Do(req)
  10814. defer resp.Body.Close()
  10815. body, ioErr := ioutil.ReadAll(resp.Body)
  10816. if ioErr != nil {
  10817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10819. return res
  10820. }
  10821. var respJSON map[string]interface{}
  10822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10825. return res
  10826. }
  10827. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10828. fmt.Println(respJSON)
  10829. result, _ := json.Marshal(respJSON)
  10830. fmt.Println(result)
  10831. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10832. utils.ErrorLog("解析失败:%v", err)
  10833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10834. return res
  10835. }
  10836. return res
  10837. } else {
  10838. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10839. saveLog(output, input, "3101", "事前")
  10840. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10841. utils.ErrorLog("解析失败:%v", err)
  10842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10843. return
  10844. }
  10845. return res
  10846. }
  10847. return res
  10848. }
  10849. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10850. ////patient_id, _ := c.GetInt64("patient_id")
  10851. //order_id, _ := c.GetInt64("order_id")
  10852. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10853. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10854. //trig_scen := c.GetString("trig_scen")
  10855. adminUser := c.GetAdminUserInfo()
  10856. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10857. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10858. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10859. record_time := c.GetString("record_time")
  10860. order, _ := service.GetHisOrderByID(order_id)
  10861. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10862. timeLayout := "2006-01-02"
  10863. loc, _ := time.LoadLocation("Local")
  10864. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10865. if err != nil {
  10866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10867. return
  10868. }
  10869. recordDateTime := theTime.Unix()
  10870. var patientPrescription models.HisPrescriptionInfo
  10871. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10872. if patientPrescription.ID == 0 {
  10873. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10874. }
  10875. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10876. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10877. //
  10878. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10879. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10880. var pp models.PublicParams
  10881. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10882. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10883. pp.FixmedinsName = miConfig.OrgName
  10884. pp.FixmedinsCode = miConfig.Code
  10885. pp.RequestUrl = miConfig.Url
  10886. pp.Cainfo = miConfig.Cainfo
  10887. pp.SecretKey = miConfig.SecretKey
  10888. pp.AccessKey = miConfig.AccessKey
  10889. pp.OpterName = roles.UserName
  10890. var config []*models.HisXtDiagnoseConfig
  10891. for _, item := range diagnosis_ids {
  10892. id, _ := strconv.ParseInt(item, 10, 64)
  10893. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10894. config = append(config, &diagnosisConfig)
  10895. }
  10896. var pd models.PatientDtos
  10897. pd.PatnID = his.PsnNo
  10898. pd.PatnName = his.Name
  10899. pd.Gend = his.Gend
  10900. pd.Brdy = psn_info.Brdy
  10901. pd.Poolarea = his.InsuplcAdmdvs
  10902. pd.CurrMdtrtID = his.Number
  10903. var fed models.FsiEncounterDtos
  10904. fed.MdtrtID = his.Number
  10905. fed.MedinsID = miConfig.Code
  10906. fed.MedinsName = miConfig.OrgName
  10907. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10908. fed.MedMdtrtType = "1"
  10909. fed.MedinsType = "1"
  10910. fed.MedinsLv = "11"
  10911. tm := time.Unix(his.RecordDate, 0)
  10912. s_tm := tm.Format("2006-01-02 15:04:05")
  10913. fed.AdmDate = s_tm
  10914. fed.DscgDate = s_tm
  10915. fed.DscgMainDiseCodg = config[0].CountryCode
  10916. fed.DscgMainDiseName = config[0].CountryContentName
  10917. //诊断信息
  10918. var fdds []*models.FsiDiagnoseDtos
  10919. for index, item := range config {
  10920. if index == 0 {
  10921. var fdd models.FsiDiagnoseDtos
  10922. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10923. fdd.InoutDiseType = "1"
  10924. fdd.MaindiseFlag = "1"
  10925. fdd.DiseDate = s_tm
  10926. fdd.DiasSrtNo = "1"
  10927. fdd.DiseName = item.CountryContentName
  10928. fdd.DiseCodg = item.CountryCode
  10929. fdds = append(fdds, &fdd)
  10930. } else {
  10931. var fdd models.FsiDiagnoseDtos
  10932. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10933. fdd.InoutDiseType = "1"
  10934. fdd.MaindiseFlag = "1"
  10935. fdd.DiseDate = s_tm
  10936. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10937. fdd.DiseName = item.CountryContentName
  10938. fdd.DiseCodg = item.CountryCode
  10939. fdds = append(fdds, &fdd)
  10940. }
  10941. }
  10942. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10943. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10944. fed.AdmDeptName = department.Name
  10945. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10946. fed.DscgDeptName = department.Name
  10947. fed.MedType = order.MedType
  10948. //处方医嘱信息
  10949. var orders []*models.FsiOrderDtos
  10950. //for _, item := range prescriptions {
  10951. // for _, subItem := range item.HisDoctorAdviceInfo {
  10952. // var order models.FsiOrderDtos
  10953. // order.RxID = strconv.FormatInt(item.ID, 10)
  10954. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10955. // order.LongDrordFlag = "0"
  10956. // order.HilistType = "1"
  10957. // order.ChrgType = "1"
  10958. // order.DrordBhvr = "-"
  10959. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10960. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10961. // order.HilistLv = "1"
  10962. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10963. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10964. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10965. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10966. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10967. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10968. // order.OwnpayAmt = ""
  10969. // order.SelfpayAmt = ""
  10970. // order.Spec = ""
  10971. // order.SpecUnt = ""
  10972. // order.DrordBegnDate = s_tm
  10973. // order.DrordStopDate = ""
  10974. // order.DrordDrCodg = "1"
  10975. // order.DrordDeptName = department.Name
  10976. // order.DrordDrCodg = "1"
  10977. // order.DrordDrName = doctor_info.UserName
  10978. // order.DrordDrProfttl = ""
  10979. // order.CurrDrordFlag = "1"
  10980. // orders = append(orders, &order)
  10981. // }
  10982. // for _, subItem := range item.HisPrescriptionProject {
  10983. // if subItem.Type == 2 {
  10984. // var order models.FsiOrderDtos
  10985. // order.RxID = strconv.FormatInt(item.ID, 10)
  10986. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10987. // order.LongDrordFlag = "0"
  10988. // order.HilistType = "1"
  10989. // order.ChrgType = "1"
  10990. // order.DrordBhvr = "-"
  10991. // order.HilistCode = subItem.HisProject.MedicalCode
  10992. // order.HosplistName = subItem.HisProject.ProjectName
  10993. // order.HilistLv = "1"
  10994. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10995. // order.HosplistCode = subItem.HisProject.MedicalCode
  10996. // order.HosplistName = subItem.HisProject.ProjectName
  10997. // order.Cnt = subItem.Count
  10998. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10999. //
  11000. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11001. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11002. // order.OwnpayAmt = ""
  11003. // order.SelfpayAmt = ""
  11004. // order.Spec = ""
  11005. // order.SpecUnt = ""
  11006. // order.DrordBegnDate = s_tm
  11007. // order.DrordStopDate = ""
  11008. // order.DrordDrCodg = "1"
  11009. // order.DrordDeptName = department.Name
  11010. // order.DrordDrCodg = "1"
  11011. // order.DrordDrName = doctor_info.UserName
  11012. // order.DrordDrProfttl = ""
  11013. // order.CurrDrordFlag = "1"
  11014. // orders = append(orders, &order)
  11015. //
  11016. // }
  11017. // if subItem.Type == 3 {
  11018. //
  11019. // var order models.FsiOrderDtos
  11020. // order.RxID = strconv.FormatInt(item.ID, 10)
  11021. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11022. // order.LongDrordFlag = "0"
  11023. // order.HilistType = "1"
  11024. // order.ChrgType = "1"
  11025. // order.DrordBhvr = "-"
  11026. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11027. // order.HosplistName = subItem.GoodInfo.GoodName
  11028. // order.HilistLv = "1"
  11029. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11030. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11031. // order.HosplistName = subItem.GoodInfo.GoodName
  11032. // order.Cnt = subItem.Count
  11033. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11034. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11035. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11036. // order.OwnpayAmt = ""
  11037. // order.SelfpayAmt = ""
  11038. // order.Spec = ""
  11039. // order.SpecUnt = ""
  11040. // order.DrordBegnDate = s_tm
  11041. // order.DrordStopDate = ""
  11042. // order.DrordDrCodg = "1"
  11043. // order.DrordDeptName = department.Name
  11044. // order.DrordDrCodg = "1"
  11045. // order.DrordDrName = doctor_info.UserName
  11046. // order.DrordDrProfttl = ""
  11047. // order.CurrDrordFlag = "1"
  11048. // orders = append(orders, &order)
  11049. //
  11050. // }
  11051. // }
  11052. //}
  11053. for _, item := range prescriptions {
  11054. for _, subItem := range item.HisDoctorAdviceInfo {
  11055. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11056. var order models.FsiOrderDtos
  11057. order.RxID = strconv.FormatInt(item.ID, 10)
  11058. order.Rxno = strconv.FormatInt(item.ID, 10)
  11059. order.LongDrordFlag = "0"
  11060. order.HilistType = "1"
  11061. order.ChrgType = "1"
  11062. order.DrordBhvr = "-"
  11063. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11064. order.HosplistName = subItem.BaseDrugLib.DrugName
  11065. order.HilistLv = "1"
  11066. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11067. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11068. order.HosplistName = subItem.BaseDrugLib.DrugName
  11069. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11070. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11071. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  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. for _, subItem := range item.HisPrescriptionProject {
  11088. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11089. var order models.FsiOrderDtos
  11090. order.RxID = strconv.FormatInt(item.ID, 10)
  11091. order.Rxno = strconv.FormatInt(item.ID, 10)
  11092. order.LongDrordFlag = "0"
  11093. order.HilistType = "1"
  11094. order.ChrgType = "1"
  11095. order.DrordBhvr = "-"
  11096. order.HilistCode = subItem.HisProject.MedicalCode
  11097. order.HosplistName = subItem.HisProject.ProjectName
  11098. order.HilistLv = "1"
  11099. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11100. order.HosplistCode = subItem.HisProject.MedicalCode
  11101. order.HosplistName = subItem.HisProject.ProjectName
  11102. order.Cnt = subItem.Count
  11103. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11104. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11105. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11106. order.OwnpayAmt = ""
  11107. order.SelfpayAmt = ""
  11108. order.Spec = ""
  11109. order.SpecUnt = ""
  11110. order.DrordBegnDate = s_tm
  11111. order.DrordStopDate = ""
  11112. order.DrordDrCodg = doctor_info.DoctorNumber
  11113. order.DrordDeptName = department.Name
  11114. order.DrordDeptCodg = department.Number
  11115. order.DrordDrName = doctor_info.UserName
  11116. order.DrordDrProfttl = "234"
  11117. order.CurrDrordFlag = "1"
  11118. orders = append(orders, &order)
  11119. }
  11120. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11121. var order models.FsiOrderDtos
  11122. order.RxID = strconv.FormatInt(item.ID, 10)
  11123. order.Rxno = strconv.FormatInt(item.ID, 10)
  11124. order.LongDrordFlag = "0"
  11125. order.HilistType = "1"
  11126. order.ChrgType = "1"
  11127. order.DrordBhvr = "0"
  11128. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11129. order.HosplistName = subItem.GoodInfo.GoodName
  11130. order.HilistLv = "1"
  11131. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11132. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11133. order.HosplistName = subItem.GoodInfo.GoodName
  11134. order.Cnt = subItem.Count
  11135. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11136. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11137. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11138. order.OwnpayAmt = ""
  11139. order.SelfpayAmt = ""
  11140. order.Spec = ""
  11141. order.SpecUnt = ""
  11142. order.DrordBegnDate = s_tm
  11143. order.DrordStopDate = ""
  11144. order.DrordDrCodg = doctor_info.DoctorNumber
  11145. order.DrordDeptName = department.Name
  11146. order.DrordDeptCodg = department.Number
  11147. order.DrordDrName = doctor_info.UserName
  11148. order.DrordDrProfttl = "234"
  11149. order.CurrDrordFlag = "1"
  11150. orders = append(orders, &order)
  11151. }
  11152. }
  11153. }
  11154. //处方医嘱信息
  11155. fed.MatnStas = "0"
  11156. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11157. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11158. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11159. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11160. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11161. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11162. fed.SetlTotlnum = "1"
  11163. fed.Insutype = his.Insutype
  11164. fed.ReimFlag = "0"
  11165. fed.OutSetlFlag = "0"
  11166. var fopd []*models.FsiOperationDtosData
  11167. data := make(map[string]interface{})
  11168. data["fed"] = fed
  11169. data["fdd"] = fdds
  11170. data["fod"] = orders
  11171. data["pd"] = pd
  11172. data["pp"] = pp
  11173. data["fopd"] = fopd
  11174. data["trig_scen"] = trig_scen
  11175. client := &http.Client{}
  11176. bytesData, _ := json.Marshal(data)
  11177. var req *http.Request
  11178. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11179. if miConfig.MdtrtareaAdmvs == "320921" {
  11180. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11181. } else {
  11182. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11183. }
  11184. resp, _ := client.Do(req)
  11185. defer resp.Body.Close()
  11186. body, ioErr := ioutil.ReadAll(resp.Body)
  11187. if ioErr != nil {
  11188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11190. return res
  11191. }
  11192. var respJSON map[string]interface{}
  11193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11196. return res
  11197. }
  11198. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11199. result, _ := json.Marshal(respJSON)
  11200. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11201. utils.ErrorLog("解析失败:%v", err)
  11202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11203. return res
  11204. }
  11205. return res
  11206. } else {
  11207. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11208. saveLog(output, input, "3102", "事中")
  11209. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11210. utils.ErrorLog("解析失败:%v", err)
  11211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11212. return
  11213. }
  11214. return res
  11215. }
  11216. return res
  11217. }
  11218. 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) {
  11219. var res Resultgd3101
  11220. adminUser := c.GetAdminUserInfo()
  11221. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11222. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11224. //record_time := c.GetString("record_time")
  11225. //trig_scen := c.GetString("trig_scen")
  11226. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11227. //psn_info, _ := service.GetPatientId(patient_id)
  11228. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11229. timeLayout := "2006-01-02"
  11230. loc, _ := time.LoadLocation("Local")
  11231. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11232. if err != nil {
  11233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11234. return res
  11235. }
  11236. recordDateTime := theTime.Unix()
  11237. var patientPrescription models.HisPrescriptionInfo
  11238. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11239. //if patientPrescription.ID == 0 {
  11240. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11241. //}
  11242. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11243. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11244. //
  11245. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11246. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11247. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11248. var pp models.PublicParams
  11249. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11250. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11251. pp.FixmedinsName = miConfig.OrgName
  11252. pp.FixmedinsCode = miConfig.Code
  11253. pp.RequestUrl = miConfig.Url
  11254. pp.Cainfo = miConfig.Cainfo
  11255. pp.SecretKey = miConfig.SecretKey
  11256. pp.AccessKey = miConfig.AccessKey
  11257. pp.OpterName = roles.UserName
  11258. var config []*models.HisXtDiagnoseConfig
  11259. for _, item := range diagnosis_ids {
  11260. id, _ := strconv.ParseInt(item, 10, 64)
  11261. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11262. config = append(config, &diagnosisConfig)
  11263. }
  11264. var pd models.PatientDtos
  11265. pd.PatnID = his.PsnNo
  11266. pd.PatnName = his.Name
  11267. pd.Gend = his.Gend
  11268. pd.Brdy = str
  11269. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11270. pd.CurrMdtrtID = his.Number
  11271. var fed models.FsiEncounterDtos
  11272. fed.MdtrtID = his.Number
  11273. fed.MedinsID = miConfig.Code
  11274. fed.MedinsName = miConfig.OrgName
  11275. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11276. fed.MedMdtrtType = "1"
  11277. fed.MedinsType = "1"
  11278. fed.MedinsLv = "11"
  11279. tm := time.Unix(his.RecordDate, 0)
  11280. s_tm := tm.Format("2006-01-02 15:04:05")
  11281. fed.AdmDate = s_tm
  11282. fed.DscgDate = s_tm
  11283. fed.DscgMainDiseCodg = config[0].CountryCode
  11284. fed.DscgMainDiseName = config[0].CountryContentName
  11285. //诊断信息
  11286. var fdds []*models.FsiDiagnoseDtos
  11287. for index, item := range config {
  11288. if index == 0 {
  11289. var fdd models.FsiDiagnoseDtos
  11290. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11291. fdd.InoutDiseType = "1"
  11292. fdd.MaindiseFlag = "1"
  11293. fdd.DiseDate = s_tm
  11294. fdd.DiasSrtNo = "1"
  11295. fdd.DiseName = item.CountryContentName
  11296. fdd.DiseCodg = item.CountryCode
  11297. fdds = append(fdds, &fdd)
  11298. } else {
  11299. var fdd models.FsiDiagnoseDtos
  11300. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11301. fdd.InoutDiseType = "1"
  11302. fdd.MaindiseFlag = "1"
  11303. fdd.DiseDate = s_tm
  11304. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11305. fdd.DiseName = item.CountryContentName
  11306. fdd.DiseCodg = item.CountryCode
  11307. fdds = append(fdds, &fdd)
  11308. }
  11309. }
  11310. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11311. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11312. fed.AdmDeptName = de.Name
  11313. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11314. fed.DscgDeptName = de.Name
  11315. fed.MedMdtrtType = "1"
  11316. fed.MedType = "11"
  11317. //if his.Insutype == "390" {
  11318. // fed.MedType = "1402"
  11319. //} else {
  11320. // fed.MedType = "9933"
  11321. //}
  11322. var orders []*models.FsiOrderDtos
  11323. if trig_scen == "2" {
  11324. //处方医嘱信息
  11325. for _, item := range prescriptions {
  11326. for _, subItem := range item.HisDoctorAdviceInfo {
  11327. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11328. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11329. var order models.FsiOrderDtos
  11330. order.RxID = strconv.FormatInt(item.ID, 10)
  11331. order.Rxno = strconv.FormatInt(item.ID, 10)
  11332. order.LongDrordFlag = "0"
  11333. order.HilistType = "1"
  11334. order.ChrgType = "1"
  11335. order.DrordBhvr = "0"
  11336. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11337. order.HosplistName = subItem.BaseDrugLib.DrugName
  11338. order.HilistLv = "1"
  11339. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11340. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11341. order.HosplistName = subItem.BaseDrugLib.DrugName
  11342. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11343. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11344. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11345. order.OwnpayAmt = ""
  11346. order.SelfpayAmt = ""
  11347. order.Spec = spec
  11348. order.SpecUnt = subItem.PrescribingNumberUnit
  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. for _, subItem := range item.HisPrescriptionProject {
  11361. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11362. var order models.FsiOrderDtos
  11363. order.RxID = strconv.FormatInt(item.ID, 10)
  11364. order.Rxno = strconv.FormatInt(item.ID, 10)
  11365. order.LongDrordFlag = "0"
  11366. order.HilistType = "1"
  11367. order.ChrgType = "1"
  11368. order.DrordBhvr = "0"
  11369. order.HilistCode = subItem.HisProject.MedicalCode
  11370. order.HosplistName = subItem.HisProject.ProjectName
  11371. order.HilistLv = "1"
  11372. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11373. order.HosplistCode = subItem.HisProject.MedicalCode
  11374. order.HosplistName = subItem.HisProject.ProjectName
  11375. order.Cnt = subItem.Count
  11376. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11377. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11378. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11379. order.OwnpayAmt = ""
  11380. order.SelfpayAmt = ""
  11381. order.Spec = subItem.Unit
  11382. order.SpecUnt = subItem.Unit
  11383. order.DrordBegnDate = s_tm
  11384. order.DrordStopDate = ""
  11385. order.DrordDrCodg = doctor_info.DoctorNumber
  11386. order.DrordDeptName = department.Name
  11387. order.DrordDeptCodg = department.Number
  11388. order.DrordDrName = doctor_info.UserName
  11389. order.DrordDrProfttl = "234"
  11390. order.CurrDrordFlag = "1"
  11391. orders = append(orders, &order)
  11392. }
  11393. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11394. var order models.FsiOrderDtos
  11395. order.RxID = strconv.FormatInt(item.ID, 10)
  11396. order.Rxno = strconv.FormatInt(item.ID, 10)
  11397. order.LongDrordFlag = "0"
  11398. order.HilistType = "1"
  11399. order.ChrgType = "1"
  11400. order.DrordBhvr = "0"
  11401. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11402. order.HosplistName = subItem.GoodInfo.GoodName
  11403. order.HilistLv = "1"
  11404. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11405. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11406. order.HosplistName = subItem.GoodInfo.GoodName
  11407. order.Cnt = subItem.Count
  11408. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11409. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11410. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11411. order.OwnpayAmt = ""
  11412. order.SelfpayAmt = ""
  11413. order.Spec = subItem.GoodInfo.SpecificationName
  11414. order.SpecUnt = subItem.Unit
  11415. order.DrordBegnDate = s_tm
  11416. order.DrordStopDate = ""
  11417. order.DrordDrCodg = doctor_info.DoctorNumber
  11418. order.DrordDeptName = department.Name
  11419. order.DrordDeptCodg = department.Number
  11420. order.DrordDrName = doctor_info.UserName
  11421. order.DrordDrProfttl = "234"
  11422. order.CurrDrordFlag = "1"
  11423. orders = append(orders, &order)
  11424. }
  11425. }
  11426. }
  11427. //处方医嘱信息
  11428. }
  11429. fed.MatnStas = "0"
  11430. fed.MedfeeSumamt = "0"
  11431. fed.OwnpayAmt = "0"
  11432. fed.SelfpayAmt = "0"
  11433. fed.AcctPayamt = "0"
  11434. fed.MaAmt = "0"
  11435. fed.HifpPayamt = "0"
  11436. fed.SetlTotlnum = "1"
  11437. fed.Insutype = his.Insutype
  11438. fed.ReimFlag = "0"
  11439. fed.OutSetlFlag = "0"
  11440. var fopd []*models.FsiOperationDtosData
  11441. data := make(map[string]interface{})
  11442. data["fed"] = fed
  11443. data["fdd"] = fdds
  11444. data["fod"] = orders
  11445. data["pd"] = pd
  11446. data["pp"] = pp
  11447. data["fopd"] = fopd
  11448. data["trig_scen"] = trig_scen
  11449. fmt.Println(data)
  11450. fmt.Println(fed)
  11451. fmt.Println(fdds)
  11452. fmt.Println(orders)
  11453. fmt.Println(pd)
  11454. fmt.Println(pp)
  11455. fmt.Println(fopd)
  11456. client := &http.Client{}
  11457. bytesData, _ := json.Marshal(data)
  11458. var req *http.Request
  11459. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11460. if miConfig.MdtrtareaAdmvs == "320921" {
  11461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11462. } else {
  11463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11464. }
  11465. resp, _ := client.Do(req)
  11466. defer resp.Body.Close()
  11467. body, ioErr := ioutil.ReadAll(resp.Body)
  11468. if ioErr != nil {
  11469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11471. return res
  11472. }
  11473. var respJSON map[string]interface{}
  11474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11477. return res
  11478. }
  11479. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11480. fmt.Println(respJSON)
  11481. result, _ := json.Marshal(respJSON)
  11482. fmt.Println(result)
  11483. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11484. utils.ErrorLog("解析失败:%v", err)
  11485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11486. return res
  11487. }
  11488. return res
  11489. } else {
  11490. //if miConfig.MdtrtareaAdmvs == "441202" {
  11491. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11492. saveLog(output, input, "3101", "事前")
  11493. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11494. utils.ErrorLog("解析失败:%v", err)
  11495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11496. return
  11497. }
  11498. return res
  11499. //}
  11500. }
  11501. }
  11502. 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) {
  11503. adminUser := c.GetAdminUserInfo()
  11504. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11505. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11506. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11507. //record_time := c.GetString("record_time")
  11508. //trig_scen := c.GetString("trig_scen")
  11509. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11510. timeLayout := "2006-01-02"
  11511. loc, _ := time.LoadLocation("Local")
  11512. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11513. if err != nil {
  11514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11515. return res
  11516. }
  11517. recordDateTime := theTime.Unix()
  11518. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11519. var patientPrescription models.HisPrescriptionInfo
  11520. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11521. if patientPrescription.ID == 0 {
  11522. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11523. }
  11524. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11525. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11526. //
  11527. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11528. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11529. var pp models.PublicParams
  11530. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11531. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11532. pp.FixmedinsName = miConfig.OrgName
  11533. pp.FixmedinsCode = miConfig.Code
  11534. pp.RequestUrl = miConfig.Url
  11535. pp.Cainfo = miConfig.Cainfo
  11536. pp.SecretKey = miConfig.SecretKey
  11537. pp.AccessKey = miConfig.AccessKey
  11538. pp.OpterName = roles.UserName
  11539. var config []*models.HisXtDiagnoseConfig
  11540. for _, item := range diagnosis_ids {
  11541. id, _ := strconv.ParseInt(item, 10, 64)
  11542. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11543. config = append(config, &diagnosisConfig)
  11544. }
  11545. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11546. var pd models.PatientDtos
  11547. pd.PatnID = his.PsnNo
  11548. pd.PatnName = his.Name
  11549. pd.Gend = his.Gend
  11550. pd.Brdy = str
  11551. pd.Poolarea = his.InsuplcAdmdvs
  11552. pd.CurrMdtrtID = his.Number
  11553. var fed models.FsiEncounterDtos
  11554. fed.MdtrtID = his.Number
  11555. fed.MedinsID = miConfig.Code
  11556. fed.MedinsName = miConfig.OrgName
  11557. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11558. fed.MedMdtrtType = "1"
  11559. fed.MedinsType = "1"
  11560. fed.MedinsLv = "11"
  11561. tm := time.Unix(his.RecordDate, 0)
  11562. s_tm := tm.Format("2006-01-02 15:04:05")
  11563. fed.AdmDate = s_tm
  11564. fed.DscgDate = s_tm
  11565. fed.DscgMainDiseCodg = config[0].CountryCode
  11566. fed.DscgMainDiseName = config[0].CountryContentName
  11567. //诊断信息
  11568. var fdds []*models.FsiDiagnoseDtos
  11569. for index, item := range config {
  11570. if index == 0 {
  11571. var fdd models.FsiDiagnoseDtos
  11572. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11573. fdd.InoutDiseType = "1"
  11574. fdd.MaindiseFlag = "1"
  11575. fdd.DiseDate = s_tm
  11576. fdd.DiasSrtNo = "1"
  11577. fdd.DiseName = item.CountryContentName
  11578. fdd.DiseCodg = item.CountryCode
  11579. fdds = append(fdds, &fdd)
  11580. } else {
  11581. var fdd models.FsiDiagnoseDtos
  11582. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11583. fdd.InoutDiseType = "1"
  11584. fdd.MaindiseFlag = "1"
  11585. fdd.DiseDate = s_tm
  11586. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11587. fdd.DiseName = item.CountryContentName
  11588. fdd.DiseCodg = item.CountryCode
  11589. fdds = append(fdds, &fdd)
  11590. }
  11591. }
  11592. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11593. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11594. fed.AdmDeptName = department.Name
  11595. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11596. fed.DscgDeptName = department.Name
  11597. fed.MedMdtrtType = "1"
  11598. fed.MedType = "11"
  11599. //if his.Insutype == "390" {
  11600. // fed.MedType = "1402"
  11601. //} else {
  11602. // fed.MedType = "9933"
  11603. //}
  11604. var orders []*models.FsiOrderDtos
  11605. if trig_scen == "2" {
  11606. //处方医嘱信息
  11607. for _, item := range prescriptions {
  11608. for _, subItem := range item.HisDoctorAdviceInfo {
  11609. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11610. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11611. var order models.FsiOrderDtos
  11612. order.RxID = strconv.FormatInt(item.ID, 10)
  11613. order.Rxno = strconv.FormatInt(item.ID, 10)
  11614. order.LongDrordFlag = "0"
  11615. order.HilistType = "1"
  11616. order.ChrgType = "1"
  11617. order.DrordBhvr = "0"
  11618. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11619. order.HosplistName = subItem.BaseDrugLib.DrugName
  11620. order.HilistLv = "1"
  11621. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11622. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11623. order.HosplistName = subItem.BaseDrugLib.DrugName
  11624. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11626. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11627. order.OwnpayAmt = ""
  11628. order.SelfpayAmt = ""
  11629. order.Spec = spec
  11630. order.SpecUnt = subItem.PrescribingNumberUnit
  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. for _, subItem := range item.HisPrescriptionProject {
  11643. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11644. var order models.FsiOrderDtos
  11645. order.RxID = strconv.FormatInt(item.ID, 10)
  11646. order.Rxno = strconv.FormatInt(item.ID, 10)
  11647. order.LongDrordFlag = "0"
  11648. order.HilistType = "1"
  11649. order.ChrgType = "1"
  11650. order.DrordBhvr = "0"
  11651. order.HilistCode = subItem.HisProject.MedicalCode
  11652. order.HosplistName = subItem.HisProject.ProjectName
  11653. order.HilistLv = "1"
  11654. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11655. order.HosplistCode = subItem.HisProject.MedicalCode
  11656. order.HosplistName = subItem.HisProject.ProjectName
  11657. order.Cnt = subItem.Count
  11658. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11659. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11660. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11661. order.OwnpayAmt = ""
  11662. order.SelfpayAmt = ""
  11663. order.Spec = subItem.Unit
  11664. order.SpecUnt = subItem.Unit
  11665. order.DrordBegnDate = s_tm
  11666. order.DrordStopDate = ""
  11667. order.DrordDrCodg = doctor_info.DoctorNumber
  11668. order.DrordDeptName = department.Name
  11669. order.DrordDeptCodg = department.Number
  11670. order.DrordDrName = doctor_info.UserName
  11671. order.DrordDrProfttl = "234"
  11672. order.CurrDrordFlag = "1"
  11673. orders = append(orders, &order)
  11674. }
  11675. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11676. var order models.FsiOrderDtos
  11677. order.RxID = strconv.FormatInt(item.ID, 10)
  11678. order.Rxno = strconv.FormatInt(item.ID, 10)
  11679. order.LongDrordFlag = "0"
  11680. order.HilistType = "1"
  11681. order.ChrgType = "1"
  11682. order.DrordBhvr = "0"
  11683. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11684. order.HosplistName = subItem.GoodInfo.GoodName
  11685. order.HilistLv = "1"
  11686. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11687. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11688. order.HosplistName = subItem.GoodInfo.GoodName
  11689. order.Cnt = subItem.Count
  11690. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11691. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11692. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11693. order.OwnpayAmt = ""
  11694. order.SelfpayAmt = ""
  11695. order.Spec = subItem.GoodInfo.SpecificationName
  11696. order.SpecUnt = subItem.Unit
  11697. order.DrordBegnDate = s_tm
  11698. order.DrordStopDate = ""
  11699. order.DrordDrCodg = doctor_info.DoctorNumber
  11700. order.DrordDeptName = department.Name
  11701. order.DrordDeptCodg = department.Number
  11702. order.DrordDrName = doctor_info.UserName
  11703. order.DrordDrProfttl = "234"
  11704. order.CurrDrordFlag = "1"
  11705. orders = append(orders, &order)
  11706. }
  11707. }
  11708. }
  11709. //处方医嘱信息
  11710. }
  11711. fed.MatnStas = "0"
  11712. fed.MedfeeSumamt = "0"
  11713. fed.OwnpayAmt = "0"
  11714. fed.SelfpayAmt = "0"
  11715. fed.AcctPayamt = "0"
  11716. fed.MaAmt = "0"
  11717. fed.HifpPayamt = "0"
  11718. fed.SetlTotlnum = "1"
  11719. fed.Insutype = his.Insutype
  11720. fed.ReimFlag = "0"
  11721. fed.OutSetlFlag = "0"
  11722. var fopd []*models.FsiOperationDtosData
  11723. data := make(map[string]interface{})
  11724. data["fed"] = fed
  11725. data["fdd"] = fdds
  11726. data["fod"] = orders
  11727. data["pd"] = pd
  11728. data["pp"] = pp
  11729. data["fopd"] = fopd
  11730. data["trig_scen"] = trig_scen
  11731. fmt.Println(data)
  11732. fmt.Println(fed)
  11733. fmt.Println(fdds)
  11734. fmt.Println(orders)
  11735. fmt.Println(pd)
  11736. fmt.Println(pp)
  11737. fmt.Println(fopd)
  11738. client := &http.Client{}
  11739. bytesData, _ := json.Marshal(data)
  11740. var req *http.Request
  11741. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11742. if miConfig.MdtrtareaAdmvs == "320921" {
  11743. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11744. } else {
  11745. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11746. }
  11747. resp, _ := client.Do(req)
  11748. defer resp.Body.Close()
  11749. body, ioErr := ioutil.ReadAll(resp.Body)
  11750. if ioErr != nil {
  11751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11753. return res
  11754. }
  11755. var respJSON map[string]interface{}
  11756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11759. return res
  11760. }
  11761. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11762. fmt.Println(respJSON)
  11763. result, _ := json.Marshal(respJSON)
  11764. fmt.Println(result)
  11765. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11766. utils.ErrorLog("解析失败:%v", err)
  11767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11768. return res
  11769. }
  11770. return res
  11771. } else {
  11772. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11773. saveLog(output, input, "3101", "事前")
  11774. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11775. utils.ErrorLog("解析失败:%v", err)
  11776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11777. return
  11778. }
  11779. return res
  11780. }
  11781. return res
  11782. }
  11783. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11784. ////patient_id, _ := c.GetInt64("patient_id")
  11785. //order_id, _ := c.GetInt64("order_id")
  11786. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11787. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11788. //trig_scen := c.GetString("trig_scen")
  11789. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11790. //utils.ErrorLog("解析失败:%v", psn_info)
  11791. adminUser := c.GetAdminUserInfo()
  11792. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11793. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11794. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11795. record_time := c.GetString("record_time")
  11796. order, _ := service.GetHisOrderByID(order_id)
  11797. timeLayout := "2006-01-02"
  11798. loc, _ := time.LoadLocation("Local")
  11799. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11800. if err != nil {
  11801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11802. return
  11803. }
  11804. recordDateTime := theTime.Unix()
  11805. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11806. var patientPrescription models.HisPrescriptionInfo
  11807. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11808. if patientPrescription.ID == 0 {
  11809. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11810. }
  11811. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11812. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11813. //
  11814. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11815. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11816. var pp models.PublicParams
  11817. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11818. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11819. pp.FixmedinsName = miConfig.OrgName
  11820. pp.FixmedinsCode = miConfig.Code
  11821. pp.RequestUrl = miConfig.Url
  11822. pp.Cainfo = miConfig.Cainfo
  11823. pp.SecretKey = miConfig.SecretKey
  11824. pp.AccessKey = miConfig.AccessKey
  11825. pp.OpterName = roles.UserName
  11826. var config []*models.HisXtDiagnoseConfig
  11827. for _, item := range diagnosis_ids {
  11828. id, _ := strconv.ParseInt(item, 10, 64)
  11829. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11830. config = append(config, &diagnosisConfig)
  11831. }
  11832. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11833. var pd models.PatientDtos
  11834. pd.PatnID = his.PsnNo
  11835. pd.PatnName = his.Name
  11836. pd.Gend = his.Gend
  11837. pd.Brdy = str
  11838. pd.Poolarea = his.InsuplcAdmdvs
  11839. pd.CurrMdtrtID = his.Number
  11840. var fed models.FsiEncounterDtos
  11841. fed.MdtrtID = his.Number
  11842. fed.MedinsID = miConfig.Code
  11843. fed.MedinsName = miConfig.OrgName
  11844. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11845. fed.MedMdtrtType = "1"
  11846. fed.MedinsType = "1"
  11847. fed.MedinsLv = "11"
  11848. tm := time.Unix(his.RecordDate, 0)
  11849. s_tm := tm.Format("2006-01-02 15:04:05")
  11850. fed.AdmDate = s_tm
  11851. fed.DscgDate = s_tm
  11852. fed.DscgMainDiseCodg = config[0].CountryCode
  11853. fed.DscgMainDiseName = config[0].CountryContentName
  11854. //诊断信息
  11855. var fdds []*models.FsiDiagnoseDtos
  11856. for index, item := range config {
  11857. if index == 0 {
  11858. var fdd models.FsiDiagnoseDtos
  11859. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11860. fdd.InoutDiseType = "1"
  11861. fdd.MaindiseFlag = "1"
  11862. fdd.DiseDate = s_tm
  11863. fdd.DiasSrtNo = "1"
  11864. fdd.DiseName = item.CountryContentName
  11865. fdd.DiseCodg = item.CountryCode
  11866. fdds = append(fdds, &fdd)
  11867. } else {
  11868. var fdd models.FsiDiagnoseDtos
  11869. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11870. fdd.InoutDiseType = "1"
  11871. fdd.MaindiseFlag = "1"
  11872. fdd.DiseDate = s_tm
  11873. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11874. fdd.DiseName = item.CountryContentName
  11875. fdd.DiseCodg = item.CountryCode
  11876. fdds = append(fdds, &fdd)
  11877. }
  11878. }
  11879. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11880. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11881. fed.AdmDeptName = department.Name
  11882. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11883. fed.DscgDeptName = department.Name
  11884. fed.MedType = order.MedType
  11885. //处方医嘱信息
  11886. var orders []*models.FsiOrderDtos
  11887. //for _, item := range prescriptions {
  11888. // for _, subItem := range item.HisDoctorAdviceInfo {
  11889. // var order models.FsiOrderDtos
  11890. // order.RxID = strconv.FormatInt(item.ID, 10)
  11891. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11892. // order.LongDrordFlag = "0"
  11893. // order.HilistType = "1"
  11894. // order.ChrgType = "1"
  11895. // order.DrordBhvr = "-"
  11896. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11897. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11898. // order.HilistLv = "1"
  11899. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11900. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11901. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11902. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11903. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11904. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11905. // order.OwnpayAmt = ""
  11906. // order.SelfpayAmt = ""
  11907. // order.Spec = ""
  11908. // order.SpecUnt = ""
  11909. // order.DrordBegnDate = s_tm
  11910. // order.DrordStopDate = ""
  11911. // order.DrordDrCodg = "1"
  11912. // order.DrordDeptName = department.Name
  11913. // order.DrordDrCodg = "1"
  11914. // order.DrordDrName = doctor_info.UserName
  11915. // order.DrordDrProfttl = ""
  11916. // order.CurrDrordFlag = "1"
  11917. // orders = append(orders, &order)
  11918. // }
  11919. // for _, subItem := range item.HisPrescriptionProject {
  11920. // if subItem.Type == 2 {
  11921. // var order models.FsiOrderDtos
  11922. // order.RxID = strconv.FormatInt(item.ID, 10)
  11923. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11924. // order.LongDrordFlag = "0"
  11925. // order.HilistType = "1"
  11926. // order.ChrgType = "1"
  11927. // order.DrordBhvr = "-"
  11928. // order.HilistCode = subItem.HisProject.MedicalCode
  11929. // order.HosplistName = subItem.HisProject.ProjectName
  11930. // order.HilistLv = "1"
  11931. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11932. // order.HosplistCode = subItem.HisProject.MedicalCode
  11933. // order.HosplistName = subItem.HisProject.ProjectName
  11934. // order.Cnt = subItem.Count
  11935. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11936. //
  11937. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11938. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11939. // order.OwnpayAmt = ""
  11940. // order.SelfpayAmt = ""
  11941. // order.Spec = ""
  11942. // order.SpecUnt = ""
  11943. // order.DrordBegnDate = s_tm
  11944. // order.DrordStopDate = ""
  11945. // order.DrordDrCodg = "1"
  11946. // order.DrordDeptName = department.Name
  11947. // order.DrordDrCodg = "1"
  11948. // order.DrordDrName = doctor_info.UserName
  11949. // order.DrordDrProfttl = ""
  11950. // order.CurrDrordFlag = "1"
  11951. // orders = append(orders, &order)
  11952. //
  11953. // }
  11954. // if subItem.Type == 3 {
  11955. //
  11956. // var order models.FsiOrderDtos
  11957. // order.RxID = strconv.FormatInt(item.ID, 10)
  11958. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11959. // order.LongDrordFlag = "0"
  11960. // order.HilistType = "1"
  11961. // order.ChrgType = "1"
  11962. // order.DrordBhvr = "-"
  11963. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11964. // order.HosplistName = subItem.GoodInfo.GoodName
  11965. // order.HilistLv = "1"
  11966. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11967. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11968. // order.HosplistName = subItem.GoodInfo.GoodName
  11969. // order.Cnt = subItem.Count
  11970. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11971. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11972. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11973. // order.OwnpayAmt = ""
  11974. // order.SelfpayAmt = ""
  11975. // order.Spec = ""
  11976. // order.SpecUnt = ""
  11977. // order.DrordBegnDate = s_tm
  11978. // order.DrordStopDate = ""
  11979. // order.DrordDrCodg = "1"
  11980. // order.DrordDeptName = department.Name
  11981. // order.DrordDrCodg = "1"
  11982. // order.DrordDrName = doctor_info.UserName
  11983. // order.DrordDrProfttl = ""
  11984. // order.CurrDrordFlag = "1"
  11985. // orders = append(orders, &order)
  11986. //
  11987. // }
  11988. // }
  11989. //}
  11990. for _, item := range prescriptions {
  11991. for _, subItem := range item.HisDoctorAdviceInfo {
  11992. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11993. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11994. var order models.FsiOrderDtos
  11995. order.RxID = strconv.FormatInt(item.ID, 10)
  11996. order.Rxno = strconv.FormatInt(item.ID, 10)
  11997. order.LongDrordFlag = "0"
  11998. order.HilistType = "1"
  11999. order.ChrgType = "1"
  12000. order.DrordBhvr = "0"
  12001. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12002. order.HosplistName = subItem.BaseDrugLib.DrugName
  12003. order.HilistLv = "1"
  12004. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12005. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12006. order.HosplistName = subItem.BaseDrugLib.DrugName
  12007. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12008. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12009. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12010. order.OwnpayAmt = ""
  12011. order.SelfpayAmt = ""
  12012. order.Spec = spec
  12013. order.SpecUnt = subItem.PrescribingNumberUnit
  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. for _, subItem := range item.HisPrescriptionProject {
  12026. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12027. var order models.FsiOrderDtos
  12028. order.RxID = strconv.FormatInt(item.ID, 10)
  12029. order.Rxno = strconv.FormatInt(item.ID, 10)
  12030. order.LongDrordFlag = "0"
  12031. order.HilistType = "1"
  12032. order.ChrgType = "1"
  12033. order.DrordBhvr = "0"
  12034. order.HilistCode = subItem.HisProject.MedicalCode
  12035. order.HosplistName = subItem.HisProject.ProjectName
  12036. order.HilistLv = "1"
  12037. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12038. order.HosplistCode = subItem.HisProject.MedicalCode
  12039. order.HosplistName = subItem.HisProject.ProjectName
  12040. order.Cnt = subItem.Count
  12041. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12042. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12043. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12044. order.OwnpayAmt = ""
  12045. order.SelfpayAmt = ""
  12046. order.Spec = subItem.Unit
  12047. order.SpecUnt = subItem.Unit
  12048. order.DrordBegnDate = s_tm
  12049. order.DrordStopDate = ""
  12050. order.DrordDrCodg = doctor_info.DoctorNumber
  12051. order.DrordDeptName = department.Name
  12052. order.DrordDeptCodg = department.Number
  12053. order.DrordDrName = doctor_info.UserName
  12054. order.DrordDrProfttl = "234"
  12055. order.CurrDrordFlag = "1"
  12056. orders = append(orders, &order)
  12057. }
  12058. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12059. var order models.FsiOrderDtos
  12060. order.RxID = strconv.FormatInt(item.ID, 10)
  12061. order.Rxno = strconv.FormatInt(item.ID, 10)
  12062. order.LongDrordFlag = "0"
  12063. order.HilistType = "1"
  12064. order.ChrgType = "1"
  12065. order.DrordBhvr = "0"
  12066. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12067. order.HosplistName = subItem.GoodInfo.GoodName
  12068. order.HilistLv = "1"
  12069. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12070. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12071. order.HosplistName = subItem.GoodInfo.GoodName
  12072. order.Cnt = subItem.Count
  12073. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12074. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12075. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12076. order.OwnpayAmt = ""
  12077. order.SelfpayAmt = ""
  12078. order.Spec = subItem.GoodInfo.SpecificationName
  12079. order.SpecUnt = subItem.Unit
  12080. order.DrordBegnDate = s_tm
  12081. order.DrordStopDate = ""
  12082. order.DrordDrCodg = doctor_info.DoctorNumber
  12083. order.DrordDeptName = department.Name
  12084. order.DrordDeptCodg = department.Number
  12085. order.DrordDrName = doctor_info.UserName
  12086. order.DrordDrProfttl = "234"
  12087. order.CurrDrordFlag = "1"
  12088. orders = append(orders, &order)
  12089. }
  12090. }
  12091. }
  12092. //处方医嘱信息
  12093. fed.MatnStas = "0"
  12094. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12095. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12096. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12097. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12098. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12099. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12100. fed.SetlTotlnum = "1"
  12101. fed.Insutype = his.Insutype
  12102. fed.ReimFlag = "0"
  12103. fed.OutSetlFlag = "0"
  12104. var fopd []*models.FsiOperationDtosData
  12105. data := make(map[string]interface{})
  12106. data["fed"] = fed
  12107. data["fdd"] = fdds
  12108. data["fod"] = orders
  12109. data["pd"] = pd
  12110. data["pp"] = pp
  12111. data["fopd"] = fopd
  12112. data["trig_scen"] = trig_scen
  12113. client := &http.Client{}
  12114. bytesData, _ := json.Marshal(data)
  12115. var req *http.Request
  12116. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12117. if miConfig.MdtrtareaAdmvs == "320921" {
  12118. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12119. } else {
  12120. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12121. }
  12122. resp, _ := client.Do(req)
  12123. defer resp.Body.Close()
  12124. body, ioErr := ioutil.ReadAll(resp.Body)
  12125. if ioErr != nil {
  12126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12128. return res
  12129. }
  12130. var respJSON map[string]interface{}
  12131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12134. return res
  12135. }
  12136. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12137. result, _ := json.Marshal(respJSON)
  12138. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12139. utils.ErrorLog("解析失败:%v", err)
  12140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12141. return res
  12142. }
  12143. return res
  12144. } else {
  12145. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12146. saveLog(output, input, "3102", "事中")
  12147. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12148. utils.ErrorLog("解析失败:%v", err)
  12149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12150. return
  12151. }
  12152. return res
  12153. }
  12154. return res
  12155. }
  12156. func (c *HisApiController) Check() {
  12157. psn_no := c.GetString("psn_no")
  12158. in := c.GetString("in")
  12159. mt := c.GetString("mt")
  12160. baseParams := models.BaseParams{
  12161. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12162. FixmedinsCode: "H15049901371",
  12163. InsuplcAdmdvs: "150499",
  12164. MdtrtareaAdmvs: "150499",
  12165. OrgName: "赤峰费森血液透析中心",
  12166. Doctor: "1111",
  12167. }
  12168. service.Gdyb2001(baseParams, psn_no, in, mt)
  12169. }
  12170. func (c *HisApiController) GetPsnNcdsInfo() {
  12171. admin_user_id, _ := c.GetInt64("admin_user_id")
  12172. patient_id, _ := c.GetInt64("patient_id")
  12173. //id, _ := c.GetInt64("id")
  12174. adminUser := c.GetAdminUserInfo()
  12175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12176. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12177. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12178. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12179. //psn_record, _ := service.GetP(id)
  12180. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12181. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12182. //
  12183. //if psn_record.ID == 0 {
  12184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12185. // return
  12186. //}
  12187. var res Result5301
  12188. var res10265 Result5301For10265
  12189. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12190. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12191. var api string
  12192. if miConfig.MdtrtareaAdmvs == "320921" {
  12193. 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 +
  12194. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12195. } else {
  12196. 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 +
  12197. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12198. }
  12199. resp, requestErr := http.Get(api)
  12200. if requestErr != nil {
  12201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12202. return
  12203. }
  12204. body, ioErr := ioutil.ReadAll(resp.Body)
  12205. if ioErr != nil {
  12206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12208. return
  12209. }
  12210. var respJSON map[string]interface{}
  12211. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. return
  12215. }
  12216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12217. result, _ := json.Marshal(respJSON)
  12218. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12219. utils.ErrorLog("解析失败:%v", err)
  12220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12221. return
  12222. }
  12223. res.ErrMsg = res10265.ErrMsg
  12224. res.Output = res10265.Output
  12225. res.InfRefmsgid = res10265.InfRefmsgid
  12226. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12227. res.Infcode = infocode
  12228. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12229. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12230. var api string
  12231. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12232. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12233. resp, requestErr := http.Get(api)
  12234. if requestErr != nil {
  12235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12236. return
  12237. }
  12238. body, ioErr := ioutil.ReadAll(resp.Body)
  12239. if ioErr != nil {
  12240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12242. return
  12243. }
  12244. var respJSON map[string]interface{}
  12245. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12248. return
  12249. }
  12250. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12251. if status == "0" {
  12252. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12253. c.ServeSuccessJSON(map[string]interface{}{
  12254. "failed_code": -10,
  12255. "msg": err_msg,
  12256. })
  12257. return
  12258. }
  12259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12260. result, _ := json.Marshal(respJSON)
  12261. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12262. utils.ErrorLog("解析失败:%v", err)
  12263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12264. return
  12265. }
  12266. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12267. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12268. var api string
  12269. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12270. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12271. resp, requestErr := http.Get(api)
  12272. if requestErr != nil {
  12273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12274. return
  12275. }
  12276. body, ioErr := ioutil.ReadAll(resp.Body)
  12277. if ioErr != nil {
  12278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12280. return
  12281. }
  12282. var respJSON map[string]interface{}
  12283. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12286. return
  12287. }
  12288. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12289. if status == "0" {
  12290. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12291. c.ServeSuccessJSON(map[string]interface{}{
  12292. "failed_code": -10,
  12293. "msg": err_msg,
  12294. })
  12295. return
  12296. }
  12297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12298. result, _ := json.Marshal(respJSON)
  12299. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12300. utils.ErrorLog("解析失败:%v", err)
  12301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12302. return
  12303. }
  12304. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12305. p, _ := service.GetHisPatientById(patient_id)
  12306. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12307. var dat map[string]interface{}
  12308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12309. fmt.Println(dat)
  12310. } else {
  12311. fmt.Println(err)
  12312. }
  12313. userJSONBytes, _ := json.Marshal(dat)
  12314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12315. utils.ErrorLog("解析失败:%v", err)
  12316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12317. return
  12318. }
  12319. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12320. p, _ := service.GetHisPatientById(patient_id)
  12321. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12322. var dat map[string]interface{}
  12323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12324. fmt.Println(dat)
  12325. } else {
  12326. fmt.Println(err)
  12327. }
  12328. userJSONBytes, _ := json.Marshal(dat)
  12329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12330. utils.ErrorLog("解析失败:%v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12335. p, _ := service.GetHisPatientById(patient_id)
  12336. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12337. var dat map[string]interface{}
  12338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12339. fmt.Println(dat)
  12340. } else {
  12341. fmt.Println(err)
  12342. }
  12343. userJSONBytes, _ := json.Marshal(dat)
  12344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12345. utils.ErrorLog("解析失败:%v", err)
  12346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12347. return
  12348. }
  12349. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12350. p, _ := service.GetHisPatientById(patient_id)
  12351. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12352. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12353. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12354. resp, requestErr := http.Get(api)
  12355. if requestErr != nil {
  12356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12357. return
  12358. }
  12359. body, ioErr := ioutil.ReadAll(resp.Body)
  12360. if ioErr != nil {
  12361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12363. return
  12364. }
  12365. var respJSON map[string]interface{}
  12366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12369. return
  12370. }
  12371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12372. result, _ := json.Marshal(respJSON)
  12373. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12374. utils.ErrorLog("解析失败:%v", err)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12379. p, _ := service.GetHisPatientById(patient_id)
  12380. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12381. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12382. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12383. resp, requestErr := http.Get(api)
  12384. if requestErr != nil {
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12386. return
  12387. }
  12388. body, ioErr := ioutil.ReadAll(resp.Body)
  12389. if ioErr != nil {
  12390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12392. return
  12393. }
  12394. var respJSON map[string]interface{}
  12395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12398. return
  12399. }
  12400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12401. result, _ := json.Marshal(respJSON)
  12402. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12403. utils.ErrorLog("解析失败:%v", err)
  12404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12405. return
  12406. }
  12407. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12408. p, _ := service.GetHisPatientById(patient_id)
  12409. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12410. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12411. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12412. resp, requestErr := http.Get(api)
  12413. if requestErr != nil {
  12414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12415. return
  12416. }
  12417. body, ioErr := ioutil.ReadAll(resp.Body)
  12418. if ioErr != nil {
  12419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12421. return
  12422. }
  12423. var respJSON map[string]interface{}
  12424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12427. return
  12428. }
  12429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12430. result, _ := json.Marshal(respJSON)
  12431. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12432. utils.ErrorLog("解析失败:%v", err)
  12433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12434. return
  12435. }
  12436. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12437. p, _ := service.GetHisPatientById(patient_id)
  12438. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12439. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12440. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12441. resp, requestErr := http.Get(api)
  12442. if requestErr != nil {
  12443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12444. return
  12445. }
  12446. body, ioErr := ioutil.ReadAll(resp.Body)
  12447. if ioErr != nil {
  12448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12450. return
  12451. }
  12452. var respJSON map[string]interface{}
  12453. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12456. return
  12457. }
  12458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12459. result, _ := json.Marshal(respJSON)
  12460. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12461. utils.ErrorLog("解析失败:%v", err)
  12462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12463. return
  12464. }
  12465. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12466. p, _ := service.GetHisPatientById(patient_id)
  12467. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12468. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12469. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12470. resp, requestErr := http.Get(api)
  12471. if requestErr != nil {
  12472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12473. return
  12474. }
  12475. body, ioErr := ioutil.ReadAll(resp.Body)
  12476. if ioErr != nil {
  12477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12479. return
  12480. }
  12481. var respJSON map[string]interface{}
  12482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12485. return
  12486. }
  12487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12488. result, _ := json.Marshal(respJSON)
  12489. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12490. utils.ErrorLog("解析失败:%v", err)
  12491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12492. return
  12493. }
  12494. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12495. p, _ := service.GetHisPatientById(patient_id)
  12496. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12497. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12498. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12499. resp, requestErr := http.Get(api)
  12500. if requestErr != nil {
  12501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12502. return
  12503. }
  12504. body, ioErr := ioutil.ReadAll(resp.Body)
  12505. if ioErr != nil {
  12506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12508. return
  12509. }
  12510. var respJSON map[string]interface{}
  12511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12514. return
  12515. }
  12516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12517. result, _ := json.Marshal(respJSON)
  12518. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12519. utils.ErrorLog("解析失败:%v", err)
  12520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12521. return
  12522. }
  12523. } else {
  12524. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12525. var dat map[string]interface{}
  12526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12527. fmt.Println(dat)
  12528. } else {
  12529. fmt.Println(err)
  12530. }
  12531. userJSONBytes, _ := json.Marshal(dat)
  12532. if miConfig.Code == "H15049901371" {
  12533. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12534. utils.ErrorLog("解析失败:%v", err)
  12535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12536. return
  12537. }
  12538. res.InfRefmsgid = res10265.InfRefmsgid
  12539. res.Output = res10265.Output
  12540. res.ErrMsg = res10265.ErrMsg
  12541. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12542. res.Infcode = infocode
  12543. } else {
  12544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12545. utils.ErrorLog("解析失败:%v", err)
  12546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. return
  12548. }
  12549. }
  12550. }
  12551. if res.Infcode == 0 {
  12552. c.ServeSuccessJSON(map[string]interface{}{
  12553. "result": res.Output.Result,
  12554. })
  12555. }
  12556. }
  12557. func (c *HisApiController) CheckInsutype() {
  12558. his_patient_id, _ := c.GetInt64("his_patient_id")
  12559. admin_user_id, _ := c.GetInt64("admin_user_id")
  12560. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12561. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12563. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12564. var dat map[string]interface{}
  12565. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12566. fmt.Println(dat)
  12567. } else {
  12568. fmt.Println(err)
  12569. }
  12570. userJSONBytes, _ := json.Marshal(dat)
  12571. var res Result90100
  12572. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12573. utils.ErrorLog("解析失败:%v", err)
  12574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12575. return
  12576. }
  12577. if res.Infcode != 0 {
  12578. c.ServeSuccessJSON(map[string]interface{}{
  12579. "failed_code": -10,
  12580. "msg": res.ErrMsg,
  12581. })
  12582. return
  12583. } else {
  12584. fmt.Println(res)
  12585. }
  12586. }
  12587. func (c *HisApiController) CheckCardPWD() {
  12588. card_pwd := c.GetString("card_pwd")
  12589. his_patient_id, _ := c.GetInt64("his_patient_id")
  12590. admin_user_id, _ := c.GetInt64("admin_user_id")
  12591. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12592. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12593. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12594. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12595. bas := strings.Split(psn.CardInfo, "|")
  12596. basNumber := bas[2]
  12597. if psn.InsuplcAdmdvs[:4] == "4403" {
  12598. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12599. var dat map[string]interface{}
  12600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12601. fmt.Println(dat)
  12602. } else {
  12603. fmt.Println(err)
  12604. }
  12605. userJSONBytes, _ := json.Marshal(dat)
  12606. var res Result90991
  12607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12608. utils.ErrorLog("解析失败:%v", err)
  12609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12610. return
  12611. }
  12612. if res.Infcode != 0 {
  12613. c.ServeSuccessJSON(map[string]interface{}{
  12614. "failed_code": -10,
  12615. "msg": res.ErrMsg,
  12616. })
  12617. return
  12618. } else {
  12619. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12620. var msg string
  12621. switch res.Output.Result.CardStat {
  12622. case "00":
  12623. msg = "未激活"
  12624. break
  12625. case "10":
  12626. msg = "激活"
  12627. break
  12628. case "20":
  12629. msg = "窗口挂失"
  12630. break
  12631. case "21":
  12632. msg = "电话挂失"
  12633. break
  12634. case "22":
  12635. msg = "单位网上申报挂失"
  12636. break
  12637. case "23":
  12638. msg = "保健办挂失"
  12639. break
  12640. case "24":
  12641. msg = "个人网上挂失"
  12642. break
  12643. case "25":
  12644. msg = "网上服务大厅挂失"
  12645. break
  12646. case "30":
  12647. msg = "注销"
  12648. break
  12649. case "40":
  12650. msg = "回收"
  12651. break
  12652. case "99":
  12653. msg = "制卡中(无效卡)"
  12654. break
  12655. }
  12656. c.ServeSuccessJSON(map[string]interface{}{
  12657. "failed_code": -10,
  12658. "msg": msg,
  12659. })
  12660. return
  12661. } else {
  12662. c.ServeSuccessJSON(map[string]interface{}{
  12663. "msg": "校验成功",
  12664. })
  12665. return
  12666. }
  12667. }
  12668. } else {
  12669. c.ServeSuccessJSON(map[string]interface{}{
  12670. "msg": "校验成功",
  12671. })
  12672. return
  12673. }
  12674. }
  12675. func (c *HisApiController) CheckCardPWDTwo() {
  12676. //card_pwd := c.GetString("card_pwd")
  12677. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12678. admin_user_id, _ := c.GetInt64("admin_user_id")
  12679. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12680. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12681. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12682. var dat map[string]interface{}
  12683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12684. fmt.Println(dat)
  12685. } else {
  12686. fmt.Println(err)
  12687. }
  12688. userJSONBytes, _ := json.Marshal(dat)
  12689. var res Result90991
  12690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12691. utils.ErrorLog("解析失败:%v", err)
  12692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12693. return
  12694. }
  12695. if res.Infcode != 0 {
  12696. c.ServeSuccessJSON(map[string]interface{}{
  12697. "failed_code": -10,
  12698. "msg": res.ErrMsg,
  12699. })
  12700. return
  12701. } else {
  12702. if res.Output.Result.SscnoCheckStat == "0" {
  12703. var msg string
  12704. switch res.Output.Result.CardStat {
  12705. case "00":
  12706. msg = "未激活"
  12707. break
  12708. case "10":
  12709. msg = "激活"
  12710. break
  12711. case "20":
  12712. msg = "窗口挂失"
  12713. break
  12714. case "21":
  12715. msg = "电话挂失"
  12716. break
  12717. case "22":
  12718. msg = "单位网上申报挂失"
  12719. break
  12720. case "23":
  12721. msg = "保健办挂失"
  12722. break
  12723. case "24":
  12724. msg = "个人网上挂失"
  12725. break
  12726. case "25":
  12727. msg = "网上服务大厅挂失"
  12728. break
  12729. case "30":
  12730. msg = "注销"
  12731. break
  12732. case "40":
  12733. msg = "回收"
  12734. break
  12735. case "99":
  12736. msg = "制卡中(无效卡)"
  12737. break
  12738. }
  12739. c.ServeSuccessJSON(map[string]interface{}{
  12740. "failed_code": -10,
  12741. "msg": msg,
  12742. })
  12743. return
  12744. } else {
  12745. c.ServeSuccessJSON(map[string]interface{}{
  12746. "msg": "校验成功",
  12747. })
  12748. return
  12749. }
  12750. }
  12751. }
  12752. type ELeCertData struct {
  12753. Data struct {
  12754. Extra string `json:"extra"`
  12755. IDNo string `json:"idNo"`
  12756. IDType string `json:"idType"`
  12757. EcToken string `json:"ecToken"`
  12758. InsuOrg string `json:"insuOrg"`
  12759. UserName string `json:"userName"`
  12760. EcIndexNo string `json:"ecIndexNo"`
  12761. Gender string `json:"gender"`
  12762. Birthday string `json:"birthday"`
  12763. Nationality string `json:"nationality"`
  12764. Email string `json:"email"`
  12765. } `json:"OutData"`
  12766. }
  12767. func (c *HisApiController) ReadCard() {
  12768. id_card_type, _ := c.GetInt64("id_card_type")
  12769. admin_user_id, _ := c.GetInt64("admin_user_id")
  12770. certificates, _ := c.GetInt64("certificates")
  12771. //
  12772. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12773. id_card_no := c.GetString("id_card_no")
  12774. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12775. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12776. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12777. switch id_card_type {
  12778. case 1:
  12779. if miConfig.MdtrtareaAdmvs == "421300" {
  12780. var res ResultTwo
  12781. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12782. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12783. "&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)
  12784. resp, requestErr := http.Get(api)
  12785. if requestErr != nil {
  12786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12787. return
  12788. }
  12789. body, ioErr := ioutil.ReadAll(resp.Body)
  12790. if ioErr != nil {
  12791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12793. return
  12794. }
  12795. var respJSON map[string]interface{}
  12796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12799. return
  12800. }
  12801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12802. result, _ := json.Marshal(respJSON)
  12803. fmt.Println("log")
  12804. fmt.Println(string(result))
  12805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12806. utils.ErrorLog("解析失败:%v", err)
  12807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12808. return
  12809. }
  12810. if res.Infcode == 0 {
  12811. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12812. if err == gorm.ErrRecordNotFound {
  12813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12814. return
  12815. } else if err != nil {
  12816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12817. return
  12818. } else {
  12819. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12820. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12821. infoStr := string(Iinfos)
  12822. idetinfoStr := string(Idetinfos)
  12823. var rf []*ResultFive
  12824. json.Unmarshal([]byte(infoStr), &rf)
  12825. var insutypes []*ResultFive
  12826. var insutype string
  12827. var is390 int = 0
  12828. var is310 int = 0
  12829. for _, item := range rf {
  12830. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12831. insutypes = append(insutypes, item)
  12832. }
  12833. }
  12834. if len(insutypes) == 1 {
  12835. insutype = insutypes[0].Insutype
  12836. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12837. } else {
  12838. for _, i := range insutypes {
  12839. if i.Insutype == "390" {
  12840. is390 = 1
  12841. }
  12842. if i.Insutype == "310" {
  12843. is310 = 1
  12844. }
  12845. }
  12846. }
  12847. if is390 == 1 {
  12848. insutype = "390"
  12849. }
  12850. if is310 == 1 {
  12851. insutype = "310"
  12852. }
  12853. if len(insutypes) == 0 {
  12854. insutype = "390"
  12855. }
  12856. var insuplc_admdvs string
  12857. for _, item := range rf {
  12858. if item.Insutype == insutype {
  12859. insuplc_admdvs = item.InsuplcAdmdvs
  12860. }
  12861. }
  12862. if strings.Contains(insuplc_admdvs, "4213") {
  12863. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12864. }
  12865. psn := &models.HisPsn{
  12866. PsnNo: res.Output.Baseinfo.PsnNo,
  12867. PatientId: patient.ID,
  12868. Certno: res.Output.Baseinfo.Certno,
  12869. Gend: res.Output.Baseinfo.Gend,
  12870. Naty: res.Output.Baseinfo.Naty,
  12871. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12872. PsnName: res.Output.Baseinfo.PsnName,
  12873. Idetinfo: idetinfoStr,
  12874. Insuinfo: infoStr,
  12875. InsuplcAdmdvs: insuplc_admdvs,
  12876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12877. }
  12878. service.CreateHisPsn(psn)
  12879. c.ServeSuccessJSON(map[string]interface{}{
  12880. "patient": patient,
  12881. "number": res.Output.Baseinfo.Certno,
  12882. })
  12883. }
  12884. } else {
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12886. return
  12887. }
  12888. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12889. var res ResultTwo
  12890. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12891. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12892. "&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)
  12893. resp, requestErr := http.Get(api)
  12894. if requestErr != nil {
  12895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12896. return
  12897. }
  12898. body, ioErr := ioutil.ReadAll(resp.Body)
  12899. if ioErr != nil {
  12900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12902. return
  12903. }
  12904. var respJSON map[string]interface{}
  12905. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12908. return
  12909. }
  12910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12911. result, _ := json.Marshal(respJSON)
  12912. fmt.Println("log")
  12913. fmt.Println(string(result))
  12914. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12915. utils.ErrorLog("解析失败:%v", err)
  12916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12917. return
  12918. }
  12919. if res.Infcode == 0 {
  12920. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12921. if err == gorm.ErrRecordNotFound {
  12922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12923. return
  12924. } else if err != nil {
  12925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12926. return
  12927. } else {
  12928. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12929. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12930. infoStr := string(Iinfos)
  12931. idetinfoStr := string(Idetinfos)
  12932. psn := &models.HisPsn{
  12933. PsnNo: res.Output.Baseinfo.PsnNo,
  12934. PatientId: patient.ID,
  12935. Certno: res.Output.Baseinfo.Certno,
  12936. Gend: res.Output.Baseinfo.Gend,
  12937. Naty: res.Output.Baseinfo.Naty,
  12938. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12939. PsnName: res.Output.Baseinfo.PsnName,
  12940. Idetinfo: idetinfoStr,
  12941. Insuinfo: infoStr,
  12942. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12943. }
  12944. service.CreateHisPsn(psn)
  12945. var rf []*ResultFive
  12946. json.Unmarshal([]byte(infoStr), &rf)
  12947. var insutypes []*ResultFive
  12948. var insutype string
  12949. var is390 int = 0
  12950. var is310 int = 0
  12951. for _, item := range rf {
  12952. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12953. insutypes = append(insutypes, item)
  12954. }
  12955. }
  12956. if len(insutypes) == 1 {
  12957. insutype = insutypes[0].Insutype
  12958. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12959. } else {
  12960. for _, i := range insutypes {
  12961. if i.Insutype == "390" {
  12962. is390 = 1
  12963. }
  12964. if i.Insutype == "310" {
  12965. is310 = 1
  12966. }
  12967. }
  12968. }
  12969. if is390 == 1 {
  12970. insutype = "390"
  12971. }
  12972. if is310 == 1 {
  12973. insutype = "310"
  12974. }
  12975. if len(insutypes) == 0 {
  12976. insutype = "310"
  12977. }
  12978. c.ServeSuccessJSON(map[string]interface{}{
  12979. "patient": patient,
  12980. "number": res.Output.Baseinfo.Certno,
  12981. "insutype": insutype,
  12982. })
  12983. }
  12984. } else {
  12985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12986. return
  12987. }
  12988. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12989. var res ResultTwo
  12990. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12991. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12992. "&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)
  12993. resp, requestErr := http.Get(api)
  12994. if requestErr != nil {
  12995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12996. return
  12997. }
  12998. body, ioErr := ioutil.ReadAll(resp.Body)
  12999. if ioErr != nil {
  13000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13002. return
  13003. }
  13004. var respJSON map[string]interface{}
  13005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13008. return
  13009. }
  13010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13011. result, _ := json.Marshal(respJSON)
  13012. fmt.Println("log")
  13013. fmt.Println(string(result))
  13014. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13015. utils.ErrorLog("解析失败:%v", err)
  13016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13017. return
  13018. }
  13019. if res.Infcode == 0 {
  13020. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13021. if err == gorm.ErrRecordNotFound {
  13022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13023. return
  13024. } else if err != nil {
  13025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13026. return
  13027. } else {
  13028. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13029. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13030. infoStr := string(Iinfos)
  13031. idetinfoStr := string(Idetinfos)
  13032. var rf []*ResultFive
  13033. json.Unmarshal([]byte(infoStr), &rf)
  13034. var insutypes []*ResultFive
  13035. var insutype string
  13036. var is390 int = 0
  13037. var is310 int = 0
  13038. for _, item := range rf {
  13039. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13040. insutypes = append(insutypes, item)
  13041. }
  13042. }
  13043. if len(insutypes) == 1 {
  13044. insutype = insutypes[0].Insutype
  13045. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13046. } else {
  13047. for _, i := range insutypes {
  13048. if i.Insutype == "390" {
  13049. is390 = 1
  13050. }
  13051. if i.Insutype == "310" {
  13052. is310 = 1
  13053. }
  13054. }
  13055. }
  13056. if is390 == 1 {
  13057. insutype = "390"
  13058. }
  13059. if is310 == 1 {
  13060. insutype = "310"
  13061. }
  13062. if len(insutypes) == 0 {
  13063. insutype = "390"
  13064. }
  13065. var insuplc_admdvs string
  13066. for _, item := range rf {
  13067. if item.Insutype == insutype {
  13068. insuplc_admdvs = item.InsuplcAdmdvs
  13069. }
  13070. }
  13071. psn := &models.HisPsn{
  13072. PsnNo: res.Output.Baseinfo.PsnNo,
  13073. PatientId: patient.ID,
  13074. Certno: res.Output.Baseinfo.Certno,
  13075. Gend: res.Output.Baseinfo.Gend,
  13076. Naty: res.Output.Baseinfo.Naty,
  13077. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13078. PsnName: res.Output.Baseinfo.PsnName,
  13079. Idetinfo: idetinfoStr,
  13080. Insuinfo: infoStr,
  13081. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13082. InsuplcAdmdvs: insuplc_admdvs,
  13083. }
  13084. service.CreateHisPsn(psn)
  13085. for _, item := range rf {
  13086. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13087. insutypes = append(insutypes, item)
  13088. }
  13089. }
  13090. if len(insutypes) == 1 {
  13091. insutype = insutypes[0].Insutype
  13092. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13093. } else {
  13094. for _, i := range insutypes {
  13095. if i.Insutype == "390" {
  13096. is390 = 1
  13097. }
  13098. if i.Insutype == "310" {
  13099. is310 = 1
  13100. }
  13101. }
  13102. }
  13103. if is390 == 1 {
  13104. insutype = "390"
  13105. }
  13106. if is310 == 1 {
  13107. insutype = "310"
  13108. }
  13109. if len(insutypes) == 0 {
  13110. insutype = "310"
  13111. }
  13112. c.ServeSuccessJSON(map[string]interface{}{
  13113. "patient": patient,
  13114. "number": res.Output.Baseinfo.Certno,
  13115. "insutype": insutype,
  13116. })
  13117. }
  13118. } else {
  13119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13120. return
  13121. }
  13122. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13123. var res ResultTwo
  13124. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13125. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13126. "&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)
  13127. resp, requestErr := http.Get(api)
  13128. if requestErr != nil {
  13129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13130. return
  13131. }
  13132. body, ioErr := ioutil.ReadAll(resp.Body)
  13133. if ioErr != nil {
  13134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13136. return
  13137. }
  13138. var respJSON map[string]interface{}
  13139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13142. return
  13143. }
  13144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13145. result, _ := json.Marshal(respJSON)
  13146. fmt.Println("log")
  13147. fmt.Println(string(result))
  13148. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13149. utils.ErrorLog("解析失败:%v", err)
  13150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13151. return
  13152. }
  13153. if res.Infcode == 0 {
  13154. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13155. if err == gorm.ErrRecordNotFound {
  13156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13157. return
  13158. } else if err != nil {
  13159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13160. return
  13161. } else {
  13162. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13163. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13164. infoStr := string(Iinfos)
  13165. idetinfoStr := string(Idetinfos)
  13166. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13167. psn := &models.HisPsn{
  13168. PsnNo: res.Output.Baseinfo.PsnNo,
  13169. PatientId: patient.ID,
  13170. Certno: res.Output.Baseinfo.Certno,
  13171. Brdy: b,
  13172. Age: float64(age),
  13173. Gend: res.Output.Baseinfo.Gend,
  13174. Naty: res.Output.Baseinfo.Naty,
  13175. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13176. PsnName: res.Output.Baseinfo.PsnName,
  13177. Idetinfo: idetinfoStr,
  13178. Insuinfo: infoStr,
  13179. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13180. }
  13181. service.CreateHisPsn(psn)
  13182. var rf []*ResultFive
  13183. json.Unmarshal([]byte(infoStr), &rf)
  13184. var insutypes []*ResultFive
  13185. var insutype string
  13186. var is390 int = 0
  13187. var is310 int = 0
  13188. for _, item := range rf {
  13189. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13190. insutypes = append(insutypes, item)
  13191. }
  13192. }
  13193. if len(insutypes) == 1 {
  13194. insutype = insutypes[0].Insutype
  13195. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13196. } else {
  13197. for _, i := range insutypes {
  13198. if i.Insutype == "390" {
  13199. is390 = 1
  13200. }
  13201. if i.Insutype == "310" {
  13202. is310 = 1
  13203. }
  13204. }
  13205. }
  13206. if is390 == 1 {
  13207. insutype = "390"
  13208. }
  13209. if is310 == 1 {
  13210. insutype = "310"
  13211. }
  13212. if len(insutypes) == 0 {
  13213. insutype = "310"
  13214. }
  13215. c.ServeSuccessJSON(map[string]interface{}{
  13216. "patient": patient,
  13217. "number": res.Output.Baseinfo.Certno,
  13218. "insutype": insutype,
  13219. })
  13220. }
  13221. } else {
  13222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13223. return
  13224. }
  13225. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13226. var api string
  13227. if miConfig.MdtrtareaAdmvs == "320921" {
  13228. 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 +
  13229. "&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
  13230. fmt.Println(api)
  13231. } else {
  13232. 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 +
  13233. "&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)
  13234. }
  13235. resp, requestErr := http.Get(api)
  13236. if requestErr != nil {
  13237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13238. return
  13239. }
  13240. body, ioErr := ioutil.ReadAll(resp.Body)
  13241. if ioErr != nil {
  13242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13244. return
  13245. }
  13246. var respJSON map[string]interface{}
  13247. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13250. return
  13251. }
  13252. var status string
  13253. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13254. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13255. //console.log()
  13256. fmt.Println("type===")
  13257. fmt.Println(card_type)
  13258. var token string
  13259. var res ResultTwo //1101结果
  13260. var res10265 ResultTwo10265 //1101结果
  13261. var card_info string //卡信息
  13262. var busi_card_info string
  13263. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13264. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13265. if status == "0" { //读卡成功
  13266. if card_type == "1" {
  13267. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13268. result, _ := json.Marshal(respJSON)
  13269. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13270. utils.ErrorLog("解析失败:%v", err)
  13271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13272. return
  13273. }
  13274. res.ErrMsg = res10265.ErrMsg
  13275. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13276. res.Infcode = infocode
  13277. res.Output = res10265.Output
  13278. res.InfRefmsgid = res10265.InfRefmsgid
  13279. } else {
  13280. //var card_info string //卡信息
  13281. //var busi_card_info string
  13282. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13283. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13284. //fmt.Println(card_info)
  13285. //fmt.Println(busi_card_info)
  13286. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13287. result, _ := json.Marshal(respJSON)
  13288. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13289. utils.ErrorLog("解析失败:%v", err)
  13290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13291. return
  13292. }
  13293. res.ErrMsg = res10265.ErrMsg
  13294. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13295. res.Infcode = infocode
  13296. res.Output = res10265.Output
  13297. res.InfRefmsgid = res10265.InfRefmsgid
  13298. }
  13299. if res.Infcode == 0 {
  13300. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13301. if err == gorm.ErrRecordNotFound {
  13302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13303. return
  13304. } else if err != nil {
  13305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13306. return
  13307. } else {
  13308. if card_type == "1" {
  13309. bas := strings.Split(card_info, "|")
  13310. basNumber := bas[2]
  13311. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13312. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13313. infoStr := string(Iinfos)
  13314. idetinfoStr := string(Idetinfos)
  13315. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13316. psn := &models.HisPsn{
  13317. PsnNo: res.Output.Baseinfo.PsnNo,
  13318. PatientId: patient.ID,
  13319. Certno: res.Output.Baseinfo.Certno,
  13320. Brdy: b,
  13321. Age: float64(age),
  13322. Gend: res.Output.Baseinfo.Gend,
  13323. Naty: res.Output.Baseinfo.Naty,
  13324. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13325. PsnName: res.Output.Baseinfo.PsnName,
  13326. Idetinfo: idetinfoStr,
  13327. Insuinfo: infoStr,
  13328. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13329. CardInfo: card_info,
  13330. VerifyNumber: busi_card_info,
  13331. }
  13332. service.CreateHisPsn(psn)
  13333. var rf []*ResultFive
  13334. json.Unmarshal([]byte(infoStr), &rf)
  13335. var insutypes []*ResultFive
  13336. var insutype string
  13337. var is390 int = 0
  13338. var is310 int = 0
  13339. for _, item := range rf {
  13340. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13341. insutypes = append(insutypes, item)
  13342. }
  13343. }
  13344. if len(insutypes) == 1 {
  13345. insutype = insutypes[0].Insutype
  13346. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13347. } else {
  13348. for _, i := range insutypes {
  13349. if i.Insutype == "390" {
  13350. is390 = 1
  13351. }
  13352. if i.Insutype == "310" {
  13353. is310 = 1
  13354. }
  13355. }
  13356. }
  13357. if is390 == 1 {
  13358. insutype = "390"
  13359. }
  13360. if is310 == 1 {
  13361. insutype = "310"
  13362. }
  13363. if len(insutypes) == 0 {
  13364. insutype = "310"
  13365. }
  13366. c.ServeSuccessJSON(map[string]interface{}{
  13367. "patient": patient,
  13368. "number": basNumber,
  13369. "insutype": insutype,
  13370. })
  13371. } else {
  13372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13374. infoStr := string(Iinfos)
  13375. idetinfoStr := string(Idetinfos)
  13376. psn := &models.HisPsn{
  13377. PsnNo: res.Output.Baseinfo.PsnNo,
  13378. PatientId: patient.ID,
  13379. Certno: res.Output.Baseinfo.Certno,
  13380. Gend: res.Output.Baseinfo.Gend,
  13381. Naty: res.Output.Baseinfo.Naty,
  13382. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13383. PsnName: res.Output.Baseinfo.PsnName,
  13384. Idetinfo: idetinfoStr,
  13385. Insuinfo: infoStr,
  13386. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13387. CardInfo: card_info,
  13388. VerifyNumber: token,
  13389. }
  13390. service.CreateHisPsn(psn)
  13391. c.ServeSuccessJSON(map[string]interface{}{
  13392. "patient": patient,
  13393. "number": token,
  13394. })
  13395. }
  13396. }
  13397. } else {
  13398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13399. return
  13400. }
  13401. } else { //读卡失败
  13402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13403. return
  13404. }
  13405. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13406. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13407. cardnum = DeleteExtraSpaceTwo(cardnum)
  13408. cardCode = DeleteExtraSpaceTwo(cardCode)
  13409. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13410. name = DeleteExtraSpaceTwo(name)
  13411. errmsg = DeleteExtraSpaceTwo(errmsg)
  13412. cardnum = Remove0000(cardnum)
  13413. cardCode = Remove0000(cardCode)
  13414. id_card_no = Remove0000(id_card_no)
  13415. name = Remove0000(name)
  13416. errmsg = Remove0000(errmsg)
  13417. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13418. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13419. //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)
  13420. //fmt.Println(result2)
  13421. //fmt.Println(requestLog2)
  13422. //fmt.Println(errMsgLog2)
  13423. 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)
  13424. saveLog(result, requestLog, "1101", "获取人员信息")
  13425. fmt.Println(errMsgLog)
  13426. if len(errMsgLog) > 0 {
  13427. } else {
  13428. var dat map[string]interface{}
  13429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13430. fmt.Println(dat)
  13431. } else {
  13432. fmt.Println(err)
  13433. }
  13434. userJSONBytes, _ := json.Marshal(dat)
  13435. var res ResultTwo
  13436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13437. utils.ErrorLog("解析失败:%v", err)
  13438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13439. return
  13440. }
  13441. res.ErrMsg = errMsgLog
  13442. if res.Infcode == 0 {
  13443. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13444. if err == gorm.ErrRecordNotFound {
  13445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13446. return
  13447. } else if err != nil {
  13448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13449. return
  13450. } else {
  13451. fmt.Println(res)
  13452. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13453. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13454. infoStr := string(Iinfos)
  13455. idetinfoStr := string(Idetinfos)
  13456. var rf []*ResultFive
  13457. json.Unmarshal([]byte(infoStr), &rf)
  13458. var insutypes []*ResultFive
  13459. var insutype string
  13460. var is390 int = 0
  13461. var is310 int = 0
  13462. for _, item := range rf {
  13463. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13464. insutypes = append(insutypes, item)
  13465. }
  13466. }
  13467. if len(insutypes) == 1 {
  13468. insutype = insutypes[0].Insutype
  13469. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13470. } else {
  13471. for _, i := range insutypes {
  13472. if i.Insutype == "390" {
  13473. is390 = 1
  13474. }
  13475. if i.Insutype == "310" {
  13476. is310 = 1
  13477. }
  13478. }
  13479. }
  13480. if is390 == 1 {
  13481. insutype = "390"
  13482. }
  13483. if is310 == 1 {
  13484. insutype = "310"
  13485. }
  13486. if len(insutypes) == 0 {
  13487. insutype = "390"
  13488. }
  13489. var insuplc_admdvs string
  13490. for _, item := range rf {
  13491. if item.Insutype == insutype {
  13492. insuplc_admdvs = item.InsuplcAdmdvs
  13493. }
  13494. }
  13495. psn := &models.HisPsn{
  13496. PsnNo: res.Output.Baseinfo.PsnNo,
  13497. PatientId: patient.ID,
  13498. Certno: res.Output.Baseinfo.Certno,
  13499. Gend: res.Output.Baseinfo.Gend,
  13500. Naty: res.Output.Baseinfo.Naty,
  13501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13502. PsnName: res.Output.Baseinfo.PsnName,
  13503. Idetinfo: idetinfoStr,
  13504. Insuinfo: infoStr,
  13505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13506. CardInfo: basStr,
  13507. VerifyNumber: "",
  13508. InsuplcAdmdvs: insuplc_admdvs,
  13509. }
  13510. service.CreateHisPsn(psn)
  13511. c.ServeSuccessJSON(map[string]interface{}{
  13512. "patient": patient,
  13513. "number": cardnum,
  13514. "insutype": insutype,
  13515. })
  13516. }
  13517. } else {
  13518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13519. return
  13520. }
  13521. }
  13522. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13523. fmt.Println(initFlag)
  13524. fmt.Println("initFlag")
  13525. if initFlag == 0 {
  13526. c.TestGetJiangXiBasBaseInit()
  13527. }
  13528. basStr := c.GetBasBaseInfo()
  13529. if len(basStr) == 0 {
  13530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13531. return
  13532. }
  13533. fmt.Println(basStr)
  13534. bas := strings.Split(basStr, "|")
  13535. basNumber := bas[1]
  13536. fmt.Println(basNumber)
  13537. card_sn := bas[3]
  13538. fmt.Println(card_sn)
  13539. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13540. 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)
  13541. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13542. var dat map[string]interface{}
  13543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13544. fmt.Println(dat)
  13545. } else {
  13546. fmt.Println(err)
  13547. }
  13548. userJSONBytes, _ := json.Marshal(dat)
  13549. var res ResultTwo
  13550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13551. utils.ErrorLog("解析失败:%v", err)
  13552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13553. return
  13554. }
  13555. if res.Infcode == 0 {
  13556. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13557. if err == gorm.ErrRecordNotFound {
  13558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13559. return
  13560. } else if err != nil {
  13561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13562. return
  13563. } else {
  13564. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13565. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13566. infoStr := string(Iinfos)
  13567. idetinfoStr := string(Idetinfos)
  13568. var rf []*ResultFive
  13569. json.Unmarshal([]byte(infoStr), &rf)
  13570. var insutypes []*ResultFive
  13571. var insutype string
  13572. var is390 int = 0
  13573. var is310 int = 0
  13574. var insuplc_admdvs string
  13575. for _, item := range rf {
  13576. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13577. insutypes = append(insutypes, item)
  13578. }
  13579. }
  13580. if len(insutypes) == 1 {
  13581. insutype = insutypes[0].Insutype
  13582. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13583. } else {
  13584. for _, i := range insutypes {
  13585. if i.Insutype == "390" {
  13586. is390 = 1
  13587. }
  13588. if i.Insutype == "310" {
  13589. is310 = 1
  13590. }
  13591. }
  13592. }
  13593. if is390 == 1 {
  13594. insutype = "390"
  13595. }
  13596. if is310 == 1 {
  13597. insutype = "310"
  13598. }
  13599. if len(insutypes) == 0 {
  13600. insutype = "310"
  13601. }
  13602. for _, item := range rf {
  13603. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13604. insuplc_admdvs = item.InsuplcAdmdvs
  13605. }
  13606. }
  13607. psn := &models.HisPsn{
  13608. PsnNo: res.Output.Baseinfo.PsnNo,
  13609. PatientId: patient.ID,
  13610. Certno: res.Output.Baseinfo.Certno,
  13611. Gend: res.Output.Baseinfo.Gend,
  13612. Naty: res.Output.Baseinfo.Naty,
  13613. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13614. PsnName: res.Output.Baseinfo.PsnName,
  13615. Idetinfo: idetinfoStr,
  13616. Insuinfo: infoStr,
  13617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13618. CardInfo: basStr,
  13619. InsuplcAdmdvs: insuplc_admdvs,
  13620. VerifyNumber: "",
  13621. }
  13622. service.CreateHisPsn(psn)
  13623. c.ServeSuccessJSON(map[string]interface{}{
  13624. "patient": patient,
  13625. "number": basNumber,
  13626. "insutype": insutype,
  13627. })
  13628. }
  13629. } else {
  13630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13631. return
  13632. }
  13633. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13634. basStr := c.GetBasBaseInfo22222()
  13635. fmt.Println(basStr)
  13636. if len(basStr) == 0 {
  13637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13638. return
  13639. }
  13640. fmt.Println(basStr)
  13641. bas := strings.Split(basStr, "|")
  13642. basNumber := bas[2] //卡号
  13643. card_sn := bas[3] //
  13644. id_card_No := bas[1] //卡号
  13645. fmt.Println(basNumber)
  13646. fmt.Println(card_sn)
  13647. fmt.Println(id_card_No)
  13648. var patient service.Patients
  13649. if len(id_card_No) == 0 {
  13650. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13651. } else {
  13652. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13653. }
  13654. 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)
  13655. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13656. var dat map[string]interface{}
  13657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13658. fmt.Println(dat)
  13659. } else {
  13660. fmt.Println(err)
  13661. }
  13662. userJSONBytes, _ := json.Marshal(dat)
  13663. var res ResultTwo
  13664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13665. utils.ErrorLog("解析失败:%v", err)
  13666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13667. return
  13668. }
  13669. if res.Infcode == 0 {
  13670. var pateint2 service.Patients
  13671. var err error
  13672. if len(id_card_No) == 0 {
  13673. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13674. } else {
  13675. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13676. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13677. }
  13678. if err == gorm.ErrRecordNotFound {
  13679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13680. return
  13681. } else if err != nil {
  13682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13683. return
  13684. } else {
  13685. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13686. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13687. infoStr := string(Iinfos)
  13688. idetinfoStr := string(Idetinfos)
  13689. var rf []*ResultFive
  13690. json.Unmarshal([]byte(infoStr), &rf)
  13691. var insutypes []*ResultFive
  13692. var insutype string
  13693. var is390 int = 0
  13694. var is310 int = 0
  13695. var insuplc_admdvs string
  13696. for _, item := range rf {
  13697. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13698. insutypes = append(insutypes, item)
  13699. }
  13700. }
  13701. if len(insutypes) == 1 {
  13702. insutype = insutypes[0].Insutype
  13703. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13704. } else {
  13705. for _, i := range insutypes {
  13706. if i.Insutype == "390" {
  13707. is390 = 1
  13708. }
  13709. if i.Insutype == "310" {
  13710. is310 = 1
  13711. }
  13712. }
  13713. }
  13714. if is390 == 1 {
  13715. insutype = "390"
  13716. }
  13717. if is310 == 1 {
  13718. insutype = "310"
  13719. }
  13720. if len(insutypes) == 0 {
  13721. insutype = "310"
  13722. }
  13723. for _, item := range rf {
  13724. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13725. insuplc_admdvs = item.InsuplcAdmdvs
  13726. }
  13727. }
  13728. psn := &models.HisPsn{
  13729. PsnNo: res.Output.Baseinfo.PsnNo,
  13730. PatientId: pateint2.ID,
  13731. Certno: res.Output.Baseinfo.Certno,
  13732. Gend: res.Output.Baseinfo.Gend,
  13733. Naty: res.Output.Baseinfo.Naty,
  13734. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13735. PsnName: res.Output.Baseinfo.PsnName,
  13736. Idetinfo: idetinfoStr,
  13737. Insuinfo: infoStr,
  13738. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13739. CardInfo: basStr,
  13740. InsuplcAdmdvs: insuplc_admdvs,
  13741. VerifyNumber: "",
  13742. }
  13743. service.CreateHisPsn(psn)
  13744. c.ServeSuccessJSON(map[string]interface{}{
  13745. "patient": patient,
  13746. "number": basNumber,
  13747. "insutype": insutype,
  13748. })
  13749. }
  13750. } else {
  13751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13752. return
  13753. }
  13754. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13755. fmt.Println(initFlag)
  13756. fmt.Println("initFlag")
  13757. if initFlag == 0 {
  13758. c.TestGetHnBasBaseInit()
  13759. }
  13760. basStr := c.GetBasBaseInfo()
  13761. if len(basStr) == 0 {
  13762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13763. return
  13764. }
  13765. fmt.Println(basStr)
  13766. bas := strings.Split(basStr, "|")
  13767. basNumber := bas[1]
  13768. fmt.Println(basNumber)
  13769. card_sn := bas[3]
  13770. card_no := bas[2]
  13771. fmt.Println(card_sn)
  13772. name := bas[4]
  13773. name = ConvertToString(name, "gbk", "utf-8")
  13774. 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)
  13775. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13776. var dat map[string]interface{}
  13777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13778. fmt.Println(dat)
  13779. } else {
  13780. fmt.Println(err)
  13781. }
  13782. userJSONBytes, _ := json.Marshal(dat)
  13783. var res ResultTwo
  13784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13785. utils.ErrorLog("解析失败:%v", err)
  13786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13787. return
  13788. }
  13789. if res.Infcode == 0 {
  13790. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13791. if err == gorm.ErrRecordNotFound {
  13792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13793. return
  13794. } else if err != nil {
  13795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13796. return
  13797. } else {
  13798. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13799. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13800. infoStr := string(Iinfos)
  13801. idetinfoStr := string(Idetinfos)
  13802. psn := &models.HisPsn{
  13803. PsnNo: res.Output.Baseinfo.PsnNo,
  13804. PatientId: patient.ID,
  13805. Certno: res.Output.Baseinfo.Certno,
  13806. Gend: res.Output.Baseinfo.Gend,
  13807. Naty: res.Output.Baseinfo.Naty,
  13808. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13809. PsnName: res.Output.Baseinfo.PsnName,
  13810. Idetinfo: idetinfoStr,
  13811. Insuinfo: infoStr,
  13812. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13813. CardInfo: basStr,
  13814. VerifyNumber: "",
  13815. }
  13816. service.CreateHisPsn(psn)
  13817. var rf []*ResultFive
  13818. json.Unmarshal([]byte(infoStr), &rf)
  13819. var insutypes []*ResultFive
  13820. var insutype string
  13821. var is390 int = 0
  13822. var is310 int = 0
  13823. for _, item := range rf {
  13824. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13825. insutypes = append(insutypes, item)
  13826. }
  13827. }
  13828. if len(insutypes) == 1 {
  13829. insutype = insutypes[0].Insutype
  13830. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13831. } else {
  13832. for _, i := range insutypes {
  13833. if i.Insutype == "390" {
  13834. is390 = 1
  13835. }
  13836. if i.Insutype == "310" {
  13837. is310 = 1
  13838. }
  13839. }
  13840. }
  13841. if is390 == 1 {
  13842. insutype = "390"
  13843. }
  13844. if is310 == 1 {
  13845. insutype = "310"
  13846. }
  13847. if len(insutypes) == 0 {
  13848. insutype = "310"
  13849. }
  13850. c.ServeSuccessJSON(map[string]interface{}{
  13851. "patient": patient,
  13852. "number": basNumber,
  13853. "insutype": insutype,
  13854. })
  13855. }
  13856. } else {
  13857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13858. return
  13859. }
  13860. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13861. var api string
  13862. 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 +
  13863. "&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
  13864. fmt.Println(api)
  13865. resp, requestErr := http.Get(api)
  13866. if requestErr != nil {
  13867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13868. return
  13869. }
  13870. body, ioErr := ioutil.ReadAll(resp.Body)
  13871. if ioErr != nil {
  13872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13874. return
  13875. }
  13876. var respJSON map[string]interface{}
  13877. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13880. return
  13881. }
  13882. var res ResultTwo //1101结果
  13883. var res10265 ResultTwo10265 //1101结果
  13884. var card_info string //卡信息
  13885. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13886. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13887. result, _ := json.Marshal(respJSON)
  13888. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13889. utils.ErrorLog("解析失败:%v", err)
  13890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13891. return
  13892. }
  13893. res.ErrMsg = res10265.ErrMsg
  13894. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13895. res.Infcode = infocode
  13896. res.Output = res10265.Output
  13897. res.InfRefmsgid = res10265.InfRefmsgid
  13898. if res.Infcode == 0 {
  13899. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13900. if err == gorm.ErrRecordNotFound {
  13901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13902. return
  13903. } else if err != nil {
  13904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13905. return
  13906. } else {
  13907. bas := strings.Split(card_info, "|")
  13908. basNumber := bas[2]
  13909. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13910. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13911. infoStr := string(Iinfos)
  13912. idetinfoStr := string(Idetinfos)
  13913. psn := &models.HisPsn{
  13914. PsnNo: res.Output.Baseinfo.PsnNo,
  13915. PatientId: patient.ID,
  13916. Certno: res.Output.Baseinfo.Certno,
  13917. Gend: res.Output.Baseinfo.Gend,
  13918. Naty: res.Output.Baseinfo.Naty,
  13919. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13920. PsnName: res.Output.Baseinfo.PsnName,
  13921. Idetinfo: idetinfoStr,
  13922. Insuinfo: infoStr,
  13923. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13924. CardInfo: card_info,
  13925. VerifyNumber: token,
  13926. }
  13927. service.CreateHisPsn(psn)
  13928. var rf []*ResultFive
  13929. json.Unmarshal([]byte(infoStr), &rf)
  13930. var insutypes []*ResultFive
  13931. var insutype string
  13932. var is390 int = 0
  13933. var is310 int = 0
  13934. for _, item := range rf {
  13935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13936. insutypes = append(insutypes, item)
  13937. }
  13938. }
  13939. if len(insutypes) == 1 {
  13940. insutype = insutypes[0].Insutype
  13941. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13942. } else {
  13943. for _, i := range insutypes {
  13944. if i.Insutype == "390" {
  13945. is390 = 1
  13946. }
  13947. if i.Insutype == "310" {
  13948. is310 = 1
  13949. }
  13950. }
  13951. }
  13952. if is390 == 1 {
  13953. insutype = "390"
  13954. }
  13955. if is310 == 1 {
  13956. insutype = "310"
  13957. }
  13958. if len(insutypes) == 0 {
  13959. insutype = "310"
  13960. }
  13961. c.ServeSuccessJSON(map[string]interface{}{
  13962. "patient": patient,
  13963. "number": basNumber,
  13964. "insutype": insutype,
  13965. })
  13966. }
  13967. } else {
  13968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13969. return
  13970. }
  13971. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13972. res := c.GetoleInfo()
  13973. if res.Infcode == 0 {
  13974. var result string
  13975. if res.Output.MdtrtCertType == "01" {
  13976. 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)
  13977. } else if res.Output.MdtrtCertType == "02" {
  13978. 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)
  13979. } else if res.Output.MdtrtCertType == "03" {
  13980. 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)
  13981. }
  13982. var dat map[string]interface{}
  13983. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13984. fmt.Println(dat)
  13985. } else {
  13986. fmt.Println(err)
  13987. }
  13988. userJSONBytes, _ := json.Marshal(dat)
  13989. var res2 ResultTwo
  13990. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13991. utils.ErrorLog("解析失败:%v", err)
  13992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13993. return
  13994. }
  13995. if res2.Infcode == 0 {
  13996. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13997. if err == gorm.ErrRecordNotFound {
  13998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13999. return
  14000. } else if err != nil {
  14001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14002. return
  14003. } else {
  14004. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14005. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14006. infoStr := string(Iinfos)
  14007. idetinfoStr := string(Idetinfos)
  14008. var rf []*ResultFive
  14009. json.Unmarshal([]byte(infoStr), &rf)
  14010. var insutypes []*ResultFive
  14011. var insutype string
  14012. var is390 int = 0
  14013. var is310 int = 0
  14014. //var insuplc_admdvs string
  14015. for _, item := range rf {
  14016. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14017. insutypes = append(insutypes, item)
  14018. }
  14019. }
  14020. if len(insutypes) == 1 {
  14021. insutype = insutypes[0].Insutype
  14022. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14023. } else {
  14024. for _, i := range insutypes {
  14025. if i.Insutype == "390" {
  14026. is390 = 1
  14027. }
  14028. if i.Insutype == "310" {
  14029. is310 = 1
  14030. }
  14031. }
  14032. }
  14033. if is390 == 1 {
  14034. insutype = "390"
  14035. }
  14036. if is310 == 1 {
  14037. insutype = "310"
  14038. }
  14039. if len(insutypes) == 0 {
  14040. insutype = "310"
  14041. }
  14042. psn := &models.HisPsn{
  14043. PsnNo: res2.Output.Baseinfo.PsnNo,
  14044. PatientId: patient.ID,
  14045. Certno: res2.Output.Baseinfo.Certno,
  14046. Gend: res2.Output.Baseinfo.Gend,
  14047. Naty: res2.Output.Baseinfo.Naty,
  14048. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14049. PsnName: res2.Output.Baseinfo.PsnName,
  14050. Idetinfo: idetinfoStr,
  14051. Insuinfo: infoStr,
  14052. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14053. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14054. VerifyNumber: res.Output.EcToken,
  14055. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14056. }
  14057. if res.Output.MdtrtCertType == "01" {
  14058. psn.VerifyNumber = res.Output.EcToken
  14059. //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)
  14060. } else if res.Output.MdtrtCertType == "02" {
  14061. psn.VerifyNumber = res.Output.MdtrtCertNo
  14062. //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)
  14063. } else if res.Output.MdtrtCertType == "03" {
  14064. psn.VerifyNumber = res.Output.MdtrtCertNo
  14065. //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)
  14066. }
  14067. var balc float64
  14068. for _, item := range rf {
  14069. if item.Insutype == insutype {
  14070. balc = item.Balc
  14071. }
  14072. }
  14073. service.CreateHisPsn(psn)
  14074. c.ServeSuccessJSON(map[string]interface{}{
  14075. "patient": patient,
  14076. "number": res.Output.CardNo,
  14077. "insutype": insutype,
  14078. "blac": balc,
  14079. "desc": idetinfoStr,
  14080. })
  14081. }
  14082. } else {
  14083. c.ServeSuccessJSON(map[string]interface{}{
  14084. "failed_code": -10,
  14085. "msg": res2.ErrMsg,
  14086. })
  14087. }
  14088. } else {
  14089. c.ServeSuccessJSON(map[string]interface{}{
  14090. "failed_code": -10,
  14091. "msg": res.ErrMsg,
  14092. })
  14093. }
  14094. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14095. var api string
  14096. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14097. "&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
  14098. fmt.Println(api)
  14099. resp, requestErr := http.Get(api)
  14100. if requestErr != nil {
  14101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14102. return
  14103. }
  14104. body, ioErr := ioutil.ReadAll(resp.Body)
  14105. if ioErr != nil {
  14106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14108. return
  14109. }
  14110. var respJSON map[string]interface{}
  14111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14114. return
  14115. }
  14116. var status string
  14117. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14118. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14119. //console.log()
  14120. fmt.Println("type===")
  14121. fmt.Println(card_type)
  14122. var token string
  14123. var res ResultTwo //1101结果
  14124. //var res10265 ResultTwoesultTwo10265 //1101结果
  14125. var card_info string //卡信息
  14126. var busi_card_info string
  14127. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14128. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14129. if status == "0" { //读卡成功
  14130. if card_type == "1" {
  14131. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14132. result, _ := json.Marshal(respJSON)
  14133. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14134. utils.ErrorLog("解析失败:%v", err)
  14135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14136. return
  14137. }
  14138. } else {
  14139. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14140. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14141. result, _ := json.Marshal(respJSON)
  14142. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14143. utils.ErrorLog("解析失败:%v", err)
  14144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14145. return
  14146. }
  14147. }
  14148. if res.Infcode == 0 {
  14149. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14150. if err == gorm.ErrRecordNotFound {
  14151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14152. return
  14153. } else if err != nil {
  14154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14155. return
  14156. } else {
  14157. if card_type == "1" {
  14158. bas := strings.Split(card_info, "|")
  14159. basNumber := bas[2]
  14160. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14161. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14162. infoStr := string(Iinfos)
  14163. idetinfoStr := string(Idetinfos)
  14164. psn := &models.HisPsn{
  14165. PsnNo: res.Output.Baseinfo.PsnNo,
  14166. PatientId: patient.ID,
  14167. Certno: res.Output.Baseinfo.Certno,
  14168. Gend: res.Output.Baseinfo.Gend,
  14169. Naty: res.Output.Baseinfo.Naty,
  14170. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14171. PsnName: res.Output.Baseinfo.PsnName,
  14172. Idetinfo: idetinfoStr,
  14173. Insuinfo: infoStr,
  14174. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14175. CardInfo: card_info,
  14176. VerifyNumber: busi_card_info,
  14177. }
  14178. service.CreateHisPsn(psn)
  14179. var rf []*ResultFive
  14180. json.Unmarshal([]byte(infoStr), &rf)
  14181. var insutypes []*ResultFive
  14182. var insutype string
  14183. var is390 int = 0
  14184. var is310 int = 0
  14185. for _, item := range rf {
  14186. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14187. insutypes = append(insutypes, item)
  14188. }
  14189. }
  14190. if len(insutypes) == 1 {
  14191. insutype = insutypes[0].Insutype
  14192. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14193. } else {
  14194. for _, i := range insutypes {
  14195. if i.Insutype == "390" {
  14196. is390 = 1
  14197. }
  14198. if i.Insutype == "310" {
  14199. is310 = 1
  14200. }
  14201. }
  14202. }
  14203. if is390 == 1 {
  14204. insutype = "390"
  14205. }
  14206. if is310 == 1 {
  14207. insutype = "310"
  14208. }
  14209. if len(insutypes) == 0 {
  14210. insutype = "310"
  14211. }
  14212. c.ServeSuccessJSON(map[string]interface{}{
  14213. "patient": patient,
  14214. "number": basNumber,
  14215. "insutype": insutype,
  14216. })
  14217. } else {
  14218. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14219. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14220. infoStr := string(Iinfos)
  14221. idetinfoStr := string(Idetinfos)
  14222. psn := &models.HisPsn{
  14223. PsnNo: res.Output.Baseinfo.PsnNo,
  14224. PatientId: patient.ID,
  14225. Certno: res.Output.Baseinfo.Certno,
  14226. Gend: res.Output.Baseinfo.Gend,
  14227. Naty: res.Output.Baseinfo.Naty,
  14228. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14229. PsnName: res.Output.Baseinfo.PsnName,
  14230. Idetinfo: idetinfoStr,
  14231. Insuinfo: infoStr,
  14232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14233. CardInfo: card_info,
  14234. VerifyNumber: token,
  14235. }
  14236. service.CreateHisPsn(psn)
  14237. c.ServeSuccessJSON(map[string]interface{}{
  14238. "patient": patient,
  14239. "number": token,
  14240. })
  14241. }
  14242. }
  14243. } else {
  14244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14245. return
  14246. }
  14247. } else { //读卡失败
  14248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14249. return
  14250. }
  14251. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14252. var api string
  14253. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14254. "&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
  14255. fmt.Println(api)
  14256. resp, requestErr := http.Get(api)
  14257. if requestErr != nil {
  14258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14259. return
  14260. }
  14261. body, ioErr := ioutil.ReadAll(resp.Body)
  14262. if ioErr != nil {
  14263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14265. return
  14266. }
  14267. var respJSON map[string]interface{}
  14268. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14271. return
  14272. }
  14273. var status string
  14274. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14275. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14276. //console.log()
  14277. fmt.Println("type===")
  14278. fmt.Println(card_type)
  14279. var token string
  14280. var res ResultTwo //1101结果
  14281. //var res10265 ResultTwoesultTwo10265 //1101结果
  14282. var card_info string //卡信息
  14283. //var busi_card_info string
  14284. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14285. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14286. if status == "0" { //读卡成功
  14287. if card_type == "1" {
  14288. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14289. result, _ := json.Marshal(respJSON)
  14290. fmt.Println(result)
  14291. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14292. utils.ErrorLog("解析失败:%v", err)
  14293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14294. return
  14295. }
  14296. fmt.Println(res)
  14297. } else {
  14298. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14299. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14300. result, _ := json.Marshal(respJSON)
  14301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14302. utils.ErrorLog("解析失败:%v", err)
  14303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14304. return
  14305. }
  14306. }
  14307. if res.Infcode == 0 {
  14308. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14309. if err == gorm.ErrRecordNotFound {
  14310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14311. return
  14312. } else if err != nil {
  14313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14314. return
  14315. } else {
  14316. if card_type == "1" {
  14317. bas := strings.Split(card_info, "|")
  14318. basNumber := bas[2]
  14319. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14320. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14321. infoStr := string(Iinfos)
  14322. idetinfoStr := string(Idetinfos)
  14323. psn := &models.HisPsn{
  14324. PsnNo: res.Output.Baseinfo.PsnNo,
  14325. PatientId: patient.ID,
  14326. Certno: res.Output.Baseinfo.Certno,
  14327. Gend: res.Output.Baseinfo.Gend,
  14328. Naty: res.Output.Baseinfo.Naty,
  14329. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14330. PsnName: res.Output.Baseinfo.PsnName,
  14331. Idetinfo: idetinfoStr,
  14332. Insuinfo: infoStr,
  14333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14334. CardInfo: card_info,
  14335. //VerifyNumber: busi_card_info,
  14336. }
  14337. service.CreateHisPsn(psn)
  14338. var rf []*ResultFive
  14339. json.Unmarshal([]byte(infoStr), &rf)
  14340. var insutypes []*ResultFive
  14341. var insutype string
  14342. var is390 int = 0
  14343. var is310 int = 0
  14344. for _, item := range rf {
  14345. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14346. insutypes = append(insutypes, item)
  14347. }
  14348. }
  14349. if len(insutypes) == 1 {
  14350. insutype = insutypes[0].Insutype
  14351. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14352. } else {
  14353. for _, i := range insutypes {
  14354. if i.Insutype == "390" {
  14355. is390 = 1
  14356. }
  14357. if i.Insutype == "310" {
  14358. is310 = 1
  14359. }
  14360. }
  14361. }
  14362. if is390 == 1 {
  14363. insutype = "390"
  14364. }
  14365. if is310 == 1 {
  14366. insutype = "310"
  14367. }
  14368. if len(insutypes) == 0 {
  14369. insutype = "310"
  14370. }
  14371. c.ServeSuccessJSON(map[string]interface{}{
  14372. "patient": patient,
  14373. "number": basNumber,
  14374. "insutype": insutype,
  14375. })
  14376. } else {
  14377. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14378. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14379. infoStr := string(Iinfos)
  14380. idetinfoStr := string(Idetinfos)
  14381. psn := &models.HisPsn{
  14382. PsnNo: res.Output.Baseinfo.PsnNo,
  14383. PatientId: patient.ID,
  14384. Certno: res.Output.Baseinfo.Certno,
  14385. Gend: res.Output.Baseinfo.Gend,
  14386. Naty: res.Output.Baseinfo.Naty,
  14387. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14388. PsnName: res.Output.Baseinfo.PsnName,
  14389. Idetinfo: idetinfoStr,
  14390. Insuinfo: infoStr,
  14391. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14392. CardInfo: card_info,
  14393. VerifyNumber: token,
  14394. }
  14395. service.CreateHisPsn(psn)
  14396. c.ServeSuccessJSON(map[string]interface{}{
  14397. "patient": patient,
  14398. "number": token,
  14399. })
  14400. }
  14401. }
  14402. } else {
  14403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14404. return
  14405. }
  14406. } else { //读卡失败
  14407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14408. return
  14409. }
  14410. } else {
  14411. if initFlag == 0 {
  14412. c.TestGetBasBaseInit()
  14413. }
  14414. basStr := c.GetBasBaseInfo()
  14415. if len(basStr) == 0 {
  14416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14417. return
  14418. }
  14419. fmt.Println(basStr)
  14420. bas := strings.Split(basStr, "|")
  14421. basNumber := bas[1]
  14422. fmt.Println(basNumber)
  14423. card_sn := bas[3]
  14424. fmt.Println(card_sn)
  14425. cardNumber := bas[2]
  14426. fmt.Println(cardNumber)
  14427. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14428. var result string
  14429. if bas[0][:2] == "44" {
  14430. 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)
  14431. } else {
  14432. 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)
  14433. }
  14434. var dat map[string]interface{}
  14435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14436. fmt.Println(dat)
  14437. } else {
  14438. fmt.Println(err)
  14439. }
  14440. userJSONBytes, _ := json.Marshal(dat)
  14441. var res ResultTwo
  14442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14443. utils.ErrorLog("解析失败:%v", err)
  14444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14445. return
  14446. }
  14447. if res.Infcode == 0 {
  14448. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14449. if err == gorm.ErrRecordNotFound {
  14450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14451. return
  14452. } else if err != nil {
  14453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14454. return
  14455. } else {
  14456. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14457. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14458. infoStr := string(Iinfos)
  14459. idetinfoStr := string(Idetinfos)
  14460. var rf []*ResultFive
  14461. json.Unmarshal([]byte(infoStr), &rf)
  14462. var insutypes []*ResultFive
  14463. var insutype string
  14464. var is390 int = 0
  14465. var is310 int = 0
  14466. var insuplc_admdvs string
  14467. for _, item := range rf {
  14468. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14469. insutypes = append(insutypes, item)
  14470. }
  14471. }
  14472. if len(insutypes) == 1 {
  14473. insutype = insutypes[0].Insutype
  14474. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14475. } else {
  14476. for _, i := range insutypes {
  14477. if i.Insutype == "390" {
  14478. is390 = 1
  14479. }
  14480. if i.Insutype == "310" {
  14481. is310 = 1
  14482. }
  14483. }
  14484. }
  14485. if is390 == 1 {
  14486. insutype = "390"
  14487. }
  14488. if is310 == 1 {
  14489. insutype = "310"
  14490. }
  14491. if len(insutypes) == 0 {
  14492. insutype = "310"
  14493. }
  14494. for _, item := range rf {
  14495. if item.Insutype == insutype {
  14496. insuplc_admdvs = item.InsuplcAdmdvs
  14497. }
  14498. }
  14499. psn := &models.HisPsn{
  14500. PsnNo: res.Output.Baseinfo.PsnNo,
  14501. PatientId: patient.ID,
  14502. Certno: res.Output.Baseinfo.Certno,
  14503. Gend: res.Output.Baseinfo.Gend,
  14504. Naty: res.Output.Baseinfo.Naty,
  14505. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14506. PsnName: res.Output.Baseinfo.PsnName,
  14507. Idetinfo: idetinfoStr,
  14508. Insuinfo: infoStr,
  14509. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14510. CardInfo: basStr,
  14511. VerifyNumber: "",
  14512. InsuplcAdmdvs: insuplc_admdvs,
  14513. }
  14514. service.CreateHisPsn(psn)
  14515. c.ServeSuccessJSON(map[string]interface{}{
  14516. "patient": patient,
  14517. "number": basNumber,
  14518. })
  14519. }
  14520. } else {
  14521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14522. return
  14523. }
  14524. break
  14525. }
  14526. case 2:
  14527. if miConfig.MdtrtareaAdmvs == "430800" {
  14528. if initFlag == 0 {
  14529. c.TestGetHnBasBaseInit()
  14530. }
  14531. SFZStr := c.GetSFZBaseInfo()
  14532. if len(SFZStr) == 0 {
  14533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14534. return
  14535. }
  14536. fmt.Println(SFZStr)
  14537. id_card_str := strings.Split(SFZStr, "^")
  14538. card_no := id_card_str[0]
  14539. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14540. //name := id_card_str[1]
  14541. //name = ConvertToString(name, "gbk", "utf-8")
  14542. 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)
  14543. var dat map[string]interface{}
  14544. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14545. fmt.Println(dat)
  14546. } else {
  14547. fmt.Println(err)
  14548. }
  14549. userJSONBytes, _ := json.Marshal(dat)
  14550. var res ResultTwo
  14551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14552. utils.ErrorLog("解析失败:%v", err)
  14553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14554. return
  14555. }
  14556. if res.Infcode == 0 {
  14557. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14558. if err == gorm.ErrRecordNotFound {
  14559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14560. return
  14561. } else if err != nil {
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14563. return
  14564. } else {
  14565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14567. infoStr := string(Iinfos)
  14568. idetinfoStr := string(Idetinfos)
  14569. var rf []*ResultFive
  14570. json.Unmarshal([]byte(infoStr), &rf)
  14571. var insutypes []*ResultFive
  14572. var insutype string
  14573. var is390 int = 0
  14574. var is310 int = 0
  14575. for _, item := range rf {
  14576. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14577. insutypes = append(insutypes, item)
  14578. }
  14579. }
  14580. if len(insutypes) == 1 {
  14581. insutype = insutypes[0].Insutype
  14582. } else {
  14583. for _, i := range insutypes {
  14584. if i.Insutype == "390" {
  14585. is390 = 1
  14586. }
  14587. if i.Insutype == "310" {
  14588. is310 = 1
  14589. }
  14590. }
  14591. }
  14592. if is390 == 1 {
  14593. insutype = "390"
  14594. }
  14595. if is310 == 1 {
  14596. insutype = "310"
  14597. }
  14598. if len(insutypes) == 0 {
  14599. insutype = "310"
  14600. }
  14601. var InsuplcAdmdvs string
  14602. for _, item := range rf {
  14603. if item.Insutype == insutype {
  14604. InsuplcAdmdvs = item.InsuplcAdmdvs
  14605. }
  14606. }
  14607. psn := &models.HisPsn{
  14608. PsnNo: res.Output.Baseinfo.PsnNo,
  14609. PatientId: patient.ID,
  14610. Certno: res.Output.Baseinfo.Certno,
  14611. Gend: res.Output.Baseinfo.Gend,
  14612. Naty: res.Output.Baseinfo.Naty,
  14613. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14614. PsnName: res.Output.Baseinfo.PsnName,
  14615. Idetinfo: idetinfoStr,
  14616. Insuinfo: infoStr,
  14617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14618. CardInfo: SFZStr,
  14619. VerifyNumber: "",
  14620. InsuplcAdmdvs: InsuplcAdmdvs,
  14621. }
  14622. service.CreateHisPsn(psn)
  14623. c.ServeSuccessJSON(map[string]interface{}{
  14624. "patient": patient,
  14625. "number": card_no,
  14626. "insutype": insutype,
  14627. })
  14628. }
  14629. } else {
  14630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14631. return
  14632. }
  14633. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14634. var res ResultTwo
  14635. api := "http://192.168.0.197:9532/" + "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 == "421182" {
  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. psn := &models.HisPsn{
  14744. PsnNo: res.Output.Baseinfo.PsnNo,
  14745. PatientId: patient.ID,
  14746. Certno: res.Output.Baseinfo.Certno,
  14747. Gend: res.Output.Baseinfo.Gend,
  14748. Naty: res.Output.Baseinfo.Naty,
  14749. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14750. PsnName: res.Output.Baseinfo.PsnName,
  14751. Idetinfo: idetinfoStr,
  14752. Insuinfo: infoStr,
  14753. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14754. }
  14755. service.CreateHisPsn(psn)
  14756. c.ServeSuccessJSON(map[string]interface{}{
  14757. "patient": patient,
  14758. "number": res.Output.Baseinfo.Certno,
  14759. })
  14760. }
  14761. } else {
  14762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14763. return
  14764. }
  14765. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14766. var res ResultTwo
  14767. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14768. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14769. "&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)
  14770. resp, requestErr := http.Get(api)
  14771. if requestErr != nil {
  14772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14773. return
  14774. }
  14775. body, ioErr := ioutil.ReadAll(resp.Body)
  14776. if ioErr != nil {
  14777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14779. return
  14780. }
  14781. var respJSON map[string]interface{}
  14782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14785. return
  14786. }
  14787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14788. result, _ := json.Marshal(respJSON)
  14789. fmt.Println("log")
  14790. fmt.Println(string(result))
  14791. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14792. utils.ErrorLog("解析失败:%v", err)
  14793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14794. return
  14795. }
  14796. if res.Infcode == 0 {
  14797. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14798. if err == gorm.ErrRecordNotFound {
  14799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14800. return
  14801. } else if err != nil {
  14802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14803. return
  14804. } else {
  14805. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14806. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14807. infoStr := string(Iinfos)
  14808. idetinfoStr := string(Idetinfos)
  14809. var rf []*ResultFive
  14810. json.Unmarshal([]byte(infoStr), &rf)
  14811. var insutypes []*ResultFive
  14812. var insutype string
  14813. var is390 int = 0
  14814. var is310 int = 0
  14815. for _, item := range rf {
  14816. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14817. insutypes = append(insutypes, item)
  14818. }
  14819. }
  14820. if len(insutypes) == 1 {
  14821. insutype = insutypes[0].Insutype
  14822. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14823. } else {
  14824. for _, i := range insutypes {
  14825. if i.Insutype == "390" {
  14826. is390 = 1
  14827. }
  14828. if i.Insutype == "310" {
  14829. is310 = 1
  14830. }
  14831. }
  14832. }
  14833. if is390 == 1 {
  14834. insutype = "390"
  14835. }
  14836. if is310 == 1 {
  14837. insutype = "310"
  14838. }
  14839. if len(insutypes) == 0 {
  14840. insutype = "390"
  14841. }
  14842. var insuplc_admdvs string
  14843. for _, item := range rf {
  14844. if item.Insutype == insutype {
  14845. insuplc_admdvs = item.InsuplcAdmdvs
  14846. }
  14847. }
  14848. psn := &models.HisPsn{
  14849. PsnNo: res.Output.Baseinfo.PsnNo,
  14850. PatientId: patient.ID,
  14851. Certno: res.Output.Baseinfo.Certno,
  14852. Gend: res.Output.Baseinfo.Gend,
  14853. Naty: res.Output.Baseinfo.Naty,
  14854. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14855. PsnName: res.Output.Baseinfo.PsnName,
  14856. Idetinfo: idetinfoStr,
  14857. Insuinfo: infoStr,
  14858. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14859. InsuplcAdmdvs: insuplc_admdvs,
  14860. }
  14861. service.CreateHisPsn(psn)
  14862. c.ServeSuccessJSON(map[string]interface{}{
  14863. "patient": patient,
  14864. "number": res.Output.Baseinfo.Certno,
  14865. })
  14866. }
  14867. } else {
  14868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14869. return
  14870. }
  14871. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14872. res := c.GetoleInfo()
  14873. if res.Infcode == 0 {
  14874. var result string
  14875. if res.Output.MdtrtCertType == "01" {
  14876. 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)
  14877. } else if res.Output.MdtrtCertType == "02" {
  14878. 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)
  14879. } else if res.Output.MdtrtCertType == "03" {
  14880. 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)
  14881. }
  14882. var dat map[string]interface{}
  14883. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14884. fmt.Println(dat)
  14885. } else {
  14886. fmt.Println(err)
  14887. }
  14888. userJSONBytes, _ := json.Marshal(dat)
  14889. var res2 ResultTwo
  14890. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14891. utils.ErrorLog("解析失败:%v", err)
  14892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14893. return
  14894. }
  14895. if res2.Infcode == 0 {
  14896. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14897. if err == gorm.ErrRecordNotFound {
  14898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14899. return
  14900. } else if err != nil {
  14901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14902. return
  14903. } else {
  14904. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14905. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14906. infoStr := string(Iinfos)
  14907. idetinfoStr := string(Idetinfos)
  14908. var rf []*ResultFive
  14909. json.Unmarshal([]byte(infoStr), &rf)
  14910. var insutypes []*ResultFive
  14911. var insutype string
  14912. var is390 int = 0
  14913. var is310 int = 0
  14914. //var insuplc_admdvs string
  14915. for _, item := range rf {
  14916. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14917. insutypes = append(insutypes, item)
  14918. }
  14919. }
  14920. if len(insutypes) == 1 {
  14921. insutype = insutypes[0].Insutype
  14922. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14923. } else {
  14924. for _, i := range insutypes {
  14925. if i.Insutype == "390" {
  14926. is390 = 1
  14927. }
  14928. if i.Insutype == "310" {
  14929. is310 = 1
  14930. }
  14931. }
  14932. }
  14933. if is390 == 1 {
  14934. insutype = "390"
  14935. }
  14936. if is310 == 1 {
  14937. insutype = "310"
  14938. }
  14939. if len(insutypes) == 0 {
  14940. insutype = "310"
  14941. }
  14942. psn := &models.HisPsn{
  14943. PsnNo: res2.Output.Baseinfo.PsnNo,
  14944. PatientId: patient.ID,
  14945. //Brdy: res2.Output.Baseinfo.Brdy,
  14946. Certno: res2.Output.Baseinfo.Certno,
  14947. Gend: res2.Output.Baseinfo.Gend,
  14948. Naty: res2.Output.Baseinfo.Naty,
  14949. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14950. PsnName: res2.Output.Baseinfo.PsnName,
  14951. Idetinfo: idetinfoStr,
  14952. Insuinfo: infoStr,
  14953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14954. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14955. VerifyNumber: res.Output.EcToken,
  14956. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14957. }
  14958. service.CreateHisPsn(psn)
  14959. var balc float64
  14960. for _, item := range rf {
  14961. if item.Insutype == insutype {
  14962. balc = item.Balc
  14963. }
  14964. }
  14965. c.ServeSuccessJSON(map[string]interface{}{
  14966. "patient": patient,
  14967. "number": res.Output.CardNo,
  14968. "insutype": insutype,
  14969. "blac": balc,
  14970. "desc": idetinfoStr,
  14971. })
  14972. }
  14973. } else {
  14974. c.ServeSuccessJSON(map[string]interface{}{
  14975. "failed_code": -10,
  14976. "msg": res2.ErrMsg,
  14977. })
  14978. }
  14979. } else {
  14980. c.ServeSuccessJSON(map[string]interface{}{
  14981. "failed_code": -10,
  14982. "msg": res.ErrMsg,
  14983. })
  14984. }
  14985. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14986. var insuplc_admdvs string
  14987. if len(patient.InsuplcAdmdvs) > 0 {
  14988. insuplc_admdvs = patient.InsuplcAdmdvs
  14989. } else {
  14990. if len(insuplc_admdvs_str) > 0 {
  14991. insuplc_admdvs = insuplc_admdvs_str
  14992. } else {
  14993. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14994. }
  14995. }
  14996. //请求内网数据
  14997. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14998. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14999. "&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=" + ""
  15000. resp, requestErr := http.Get(api)
  15001. if requestErr != nil {
  15002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15003. return
  15004. }
  15005. body, ioErr := ioutil.ReadAll(resp.Body)
  15006. if ioErr != nil {
  15007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15009. return
  15010. }
  15011. var respJSON map[string]interface{}
  15012. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15015. return
  15016. }
  15017. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15018. if status == "0" {
  15019. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15020. c.ServeSuccessJSON(map[string]interface{}{
  15021. "failed_code": -10,
  15022. "msg": err_msg,
  15023. })
  15024. return
  15025. }
  15026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15027. var res ResultTwo
  15028. result, _ := json.Marshal(respJSON)
  15029. fmt.Println("log")
  15030. fmt.Println(string(result))
  15031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15032. utils.ErrorLog("解析失败:%v", err)
  15033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15034. return
  15035. }
  15036. if res.Infcode == 0 {
  15037. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15038. if err == gorm.ErrRecordNotFound {
  15039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15040. return
  15041. } else if err != nil {
  15042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15043. return
  15044. } else {
  15045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15047. infoStr := string(Iinfos)
  15048. idetinfoStr := string(Idetinfos)
  15049. psn := &models.HisPsn{
  15050. PsnNo: res.Output.Baseinfo.PsnNo,
  15051. PatientId: patient.ID,
  15052. Certno: res.Output.Baseinfo.Certno,
  15053. Gend: res.Output.Baseinfo.Gend,
  15054. Naty: res.Output.Baseinfo.Naty,
  15055. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15056. PsnName: res.Output.Baseinfo.PsnName,
  15057. Idetinfo: idetinfoStr,
  15058. Insuinfo: infoStr,
  15059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15060. }
  15061. service.CreateHisPsn(psn)
  15062. var rf []*ResultFive
  15063. json.Unmarshal([]byte(infoStr), &rf)
  15064. var insutypes []*ResultFive
  15065. var is390 int = 0
  15066. var is310 int = 0
  15067. var insutype string
  15068. for _, item := range rf {
  15069. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15070. insutypes = append(insutypes, item)
  15071. }
  15072. }
  15073. if len(insutypes) == 1 {
  15074. insutype = insutypes[0].Insutype
  15075. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15076. } else {
  15077. for _, i := range insutypes {
  15078. if i.Insutype == "390" {
  15079. is390 = 1
  15080. }
  15081. if i.Insutype == "310" {
  15082. is310 = 1
  15083. }
  15084. }
  15085. }
  15086. if is390 == 1 {
  15087. insutype = "390"
  15088. }
  15089. if is310 == 1 {
  15090. insutype = "310"
  15091. }
  15092. if len(insutypes) == 0 {
  15093. insutype = "390"
  15094. }
  15095. c.ServeSuccessJSON(map[string]interface{}{
  15096. "patient": patient,
  15097. "insutype": insutype,
  15098. "number": res.Output.Baseinfo.Certno,
  15099. "info": res,
  15100. })
  15101. }
  15102. } else {
  15103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15104. return
  15105. }
  15106. } else {
  15107. SFZStr := c.GetSFZBaseInfo()
  15108. id_card_str := strings.Split(SFZStr, "^")
  15109. id_card_number := id_card_str[0]
  15110. card_sn := ""
  15111. 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)
  15112. var dat map[string]interface{}
  15113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15114. fmt.Println(dat)
  15115. } else {
  15116. fmt.Println(err)
  15117. }
  15118. userJSONBytes, _ := json.Marshal(dat)
  15119. var res ResultTwo
  15120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15121. utils.ErrorLog("解析失败:%v", err)
  15122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15123. return
  15124. }
  15125. if res.Infcode == 0 {
  15126. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15127. if err == gorm.ErrRecordNotFound {
  15128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15129. return
  15130. } else if err != nil {
  15131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15132. return
  15133. } else {
  15134. c.ServeSuccessJSON(map[string]interface{}{
  15135. "patient": patient,
  15136. "number": id_card_number,
  15137. })
  15138. }
  15139. } else {
  15140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15141. return
  15142. }
  15143. }
  15144. break
  15145. case 3:
  15146. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15147. var api string
  15148. if miConfig.MdtrtareaAdmvs == "320921" {
  15149. 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 +
  15150. "&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
  15151. fmt.Println(api)
  15152. } else {
  15153. 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 +
  15154. "&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)
  15155. }
  15156. resp, requestErr := http.Get(api)
  15157. if requestErr != nil {
  15158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15159. return
  15160. }
  15161. body, ioErr := ioutil.ReadAll(resp.Body)
  15162. if ioErr != nil {
  15163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15165. return
  15166. }
  15167. var respJSON map[string]interface{}
  15168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15171. return
  15172. }
  15173. var status string
  15174. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15175. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15176. var token string
  15177. var res ResultTwo //1101结果
  15178. var res10265 ResultTwo10265 //1101结果
  15179. var card_info string //卡信息
  15180. var busi_card_info string
  15181. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15182. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15183. if status == "0" { //读卡成功
  15184. if card_type == "1" {
  15185. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15186. result, _ := json.Marshal(respJSON)
  15187. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15188. utils.ErrorLog("解析失败:%v", err)
  15189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15190. return
  15191. }
  15192. res.ErrMsg = res10265.ErrMsg
  15193. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15194. res.Infcode = infocode
  15195. res.Output = res10265.Output
  15196. res.InfRefmsgid = res10265.InfRefmsgid
  15197. } else {
  15198. //var card_info string //卡信息
  15199. //var busi_card_info string
  15200. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15201. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15202. //fmt.Println(card_info)
  15203. //fmt.Println(busi_card_info)
  15204. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15205. result, _ := json.Marshal(respJSON)
  15206. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15207. utils.ErrorLog("解析失败:%v", err)
  15208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15209. return
  15210. }
  15211. res.ErrMsg = res10265.ErrMsg
  15212. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15213. res.Infcode = infocode
  15214. res.Output = res10265.Output
  15215. res.InfRefmsgid = res10265.InfRefmsgid
  15216. }
  15217. if res.Infcode == 0 {
  15218. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15219. if err == gorm.ErrRecordNotFound {
  15220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15221. return
  15222. } else if err != nil {
  15223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15224. return
  15225. } else {
  15226. if card_type == "1" {
  15227. bas := strings.Split(card_info, "|")
  15228. basNumber := bas[2]
  15229. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15230. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15231. infoStr := string(Iinfos)
  15232. idetinfoStr := string(Idetinfos)
  15233. psn := &models.HisPsn{
  15234. PsnNo: res.Output.Baseinfo.PsnNo,
  15235. PatientId: patient.ID,
  15236. Certno: res.Output.Baseinfo.Certno,
  15237. //Brdy: res.Output.Baseinfo.Brdy,
  15238. Gend: res.Output.Baseinfo.Gend,
  15239. Naty: res.Output.Baseinfo.Naty,
  15240. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15241. PsnName: res.Output.Baseinfo.PsnName,
  15242. Idetinfo: idetinfoStr,
  15243. Insuinfo: infoStr,
  15244. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15245. CardInfo: card_info,
  15246. VerifyNumber: busi_card_info,
  15247. }
  15248. service.CreateHisPsn(psn)
  15249. c.ServeSuccessJSON(map[string]interface{}{
  15250. "patient": patient,
  15251. "number": basNumber,
  15252. })
  15253. } else {
  15254. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15255. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15256. infoStr := string(Iinfos)
  15257. idetinfoStr := string(Idetinfos)
  15258. psn := &models.HisPsn{
  15259. PsnNo: res.Output.Baseinfo.PsnNo,
  15260. PatientId: patient.ID,
  15261. Certno: res.Output.Baseinfo.Certno,
  15262. Gend: res.Output.Baseinfo.Gend,
  15263. Naty: res.Output.Baseinfo.Naty,
  15264. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15265. PsnName: res.Output.Baseinfo.PsnName,
  15266. Idetinfo: idetinfoStr,
  15267. Insuinfo: infoStr,
  15268. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15269. CardInfo: card_info,
  15270. VerifyNumber: token,
  15271. }
  15272. service.CreateHisPsn(psn)
  15273. var rf []*ResultFive
  15274. json.Unmarshal([]byte(infoStr), &rf)
  15275. var insutypes []*ResultFive
  15276. var insutype string
  15277. var is390 int = 0
  15278. var is310 int = 0
  15279. for _, item := range rf {
  15280. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15281. insutypes = append(insutypes, item)
  15282. }
  15283. }
  15284. if len(insutypes) == 1 {
  15285. insutype = insutypes[0].Insutype
  15286. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15287. } else {
  15288. for _, i := range insutypes {
  15289. if i.Insutype == "390" {
  15290. is390 = 1
  15291. }
  15292. if i.Insutype == "310" {
  15293. is310 = 1
  15294. }
  15295. }
  15296. }
  15297. if is390 == 1 {
  15298. insutype = "390"
  15299. }
  15300. if is310 == 1 {
  15301. insutype = "310"
  15302. }
  15303. if len(insutypes) == 0 {
  15304. insutype = "310"
  15305. }
  15306. c.ServeSuccessJSON(map[string]interface{}{
  15307. "patient": patient,
  15308. "number": token,
  15309. "insutype": insutype,
  15310. })
  15311. }
  15312. }
  15313. } else {
  15314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15315. return
  15316. }
  15317. } else { //读卡失败
  15318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15319. return
  15320. }
  15321. }
  15322. break
  15323. case 4:
  15324. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15325. var api string
  15326. if miConfig.MdtrtareaAdmvs == "320921" {
  15327. 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 +
  15328. "&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
  15329. fmt.Println(api)
  15330. } else {
  15331. 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 +
  15332. "&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)
  15333. }
  15334. resp, requestErr := http.Get(api)
  15335. if requestErr != nil {
  15336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15337. return
  15338. }
  15339. body, ioErr := ioutil.ReadAll(resp.Body)
  15340. if ioErr != nil {
  15341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15343. return
  15344. }
  15345. var respJSON map[string]interface{}
  15346. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15349. return
  15350. }
  15351. var status string
  15352. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15353. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15354. var token string
  15355. var res ResultTwo //1101结果
  15356. var res10265 ResultTwo10265 //1101结果
  15357. if status == "0" { //读卡成功
  15358. var card_info string //卡信息
  15359. var busi_card_info string
  15360. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15361. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15362. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15363. fmt.Println(card_info)
  15364. fmt.Println(busi_card_info)
  15365. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15366. result, _ := json.Marshal(respJSON)
  15367. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15368. utils.ErrorLog("解析失败:%v", err)
  15369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15370. return
  15371. }
  15372. res.ErrMsg = res10265.ErrMsg
  15373. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15374. res.Infcode = infocode
  15375. res.Output = res10265.Output
  15376. res.InfRefmsgid = res10265.InfRefmsgid
  15377. if res.Infcode == 0 {
  15378. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15379. if err == gorm.ErrRecordNotFound {
  15380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15381. return
  15382. } else if err != nil {
  15383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15384. return
  15385. } else {
  15386. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15387. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15388. infoStr := string(Iinfos)
  15389. idetinfoStr := string(Idetinfos)
  15390. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15391. psn := &models.HisPsn{
  15392. PsnNo: res.Output.Baseinfo.PsnNo,
  15393. PatientId: patient.ID,
  15394. Certno: res.Output.Baseinfo.Certno,
  15395. Brdy: b,
  15396. Age: float64(age),
  15397. //Brdy: res.Output.Baseinfo.Brdy,
  15398. Gend: res.Output.Baseinfo.Gend,
  15399. Naty: res.Output.Baseinfo.Naty,
  15400. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15401. PsnName: res.Output.Baseinfo.PsnName,
  15402. Idetinfo: idetinfoStr,
  15403. Insuinfo: infoStr,
  15404. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15405. CardInfo: card_info,
  15406. VerifyNumber: token,
  15407. }
  15408. var rf []*ResultFive
  15409. json.Unmarshal([]byte(infoStr), &rf)
  15410. var insutypes []*ResultFive
  15411. var insutype string
  15412. var is390 int = 0
  15413. var is310 int = 0
  15414. for _, item := range rf {
  15415. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15416. insutypes = append(insutypes, item)
  15417. }
  15418. }
  15419. if len(insutypes) == 1 {
  15420. insutype = insutypes[0].Insutype
  15421. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15422. } else {
  15423. for _, i := range insutypes {
  15424. if i.Insutype == "390" {
  15425. is390 = 1
  15426. }
  15427. if i.Insutype == "310" {
  15428. is310 = 1
  15429. }
  15430. }
  15431. }
  15432. if is390 == 1 {
  15433. insutype = "390"
  15434. }
  15435. if is310 == 1 {
  15436. insutype = "310"
  15437. }
  15438. if len(insutypes) == 0 {
  15439. insutype = "310"
  15440. }
  15441. service.CreateHisPsn(psn)
  15442. c.ServeSuccessJSON(map[string]interface{}{
  15443. "patient": patient,
  15444. "number": token,
  15445. "insutype": insutype,
  15446. })
  15447. }
  15448. } else {
  15449. c.ServeSuccessJSON(map[string]interface{}{
  15450. "failed_code": -10,
  15451. "msg": res.ErrMsg,
  15452. })
  15453. }
  15454. } else { //读卡失败
  15455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15456. return
  15457. }
  15458. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15459. var api string
  15460. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15461. "&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
  15462. resp, requestErr := http.Get(api)
  15463. if requestErr != nil {
  15464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15465. return
  15466. }
  15467. body, ioErr := ioutil.ReadAll(resp.Body)
  15468. if ioErr != nil {
  15469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15471. return
  15472. }
  15473. var respJSON map[string]interface{}
  15474. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15477. return
  15478. }
  15479. var status string
  15480. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15481. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15482. var token string
  15483. var res ResultTwo //1101结果
  15484. if status == "1" { //读卡成功
  15485. var card_info string //卡信息
  15486. var busi_card_info string
  15487. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15488. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15489. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15490. fmt.Println(card_info)
  15491. fmt.Println(busi_card_info)
  15492. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15493. result, _ := json.Marshal(respJSON)
  15494. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15495. utils.ErrorLog("解析失败:%v", err)
  15496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15497. return
  15498. }
  15499. if res.Infcode == 0 {
  15500. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15501. if err == gorm.ErrRecordNotFound {
  15502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15503. return
  15504. } else if err != nil {
  15505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15506. return
  15507. } else {
  15508. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15509. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15510. infoStr := string(Iinfos)
  15511. idetinfoStr := string(Idetinfos)
  15512. psn := &models.HisPsn{
  15513. PsnNo: res.Output.Baseinfo.PsnNo,
  15514. PatientId: patient.ID,
  15515. Certno: res.Output.Baseinfo.Certno,
  15516. Gend: res.Output.Baseinfo.Gend,
  15517. Naty: res.Output.Baseinfo.Naty,
  15518. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15519. PsnName: res.Output.Baseinfo.PsnName,
  15520. Idetinfo: idetinfoStr,
  15521. Insuinfo: infoStr,
  15522. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15523. CardInfo: card_info,
  15524. VerifyNumber: token,
  15525. }
  15526. var rf []*ResultFive
  15527. json.Unmarshal([]byte(infoStr), &rf)
  15528. var insutypes []*ResultFive
  15529. var insutype string
  15530. var is390 int = 0
  15531. var is310 int = 0
  15532. for _, item := range rf {
  15533. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15534. insutypes = append(insutypes, item)
  15535. }
  15536. }
  15537. if len(insutypes) == 1 {
  15538. insutype = insutypes[0].Insutype
  15539. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15540. } else {
  15541. for _, i := range insutypes {
  15542. if i.Insutype == "390" {
  15543. is390 = 1
  15544. }
  15545. if i.Insutype == "310" {
  15546. is310 = 1
  15547. }
  15548. }
  15549. }
  15550. if is390 == 1 {
  15551. insutype = "390"
  15552. }
  15553. if is310 == 1 {
  15554. insutype = "310"
  15555. }
  15556. if len(insutypes) == 0 {
  15557. insutype = "310"
  15558. }
  15559. service.CreateHisPsn(psn)
  15560. c.ServeSuccessJSON(map[string]interface{}{
  15561. "patient": patient,
  15562. "number": token,
  15563. "insutype": insutype,
  15564. })
  15565. }
  15566. } else {
  15567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15568. return
  15569. }
  15570. } else { //读卡失败
  15571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15572. return
  15573. }
  15574. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15575. var api string
  15576. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15577. "&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
  15578. resp, requestErr := http.Get(api)
  15579. if requestErr != nil {
  15580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15581. return
  15582. }
  15583. body, ioErr := ioutil.ReadAll(resp.Body)
  15584. if ioErr != nil {
  15585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15587. return
  15588. }
  15589. var respJSON map[string]interface{}
  15590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15593. return
  15594. }
  15595. var status string
  15596. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15597. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15598. var token string
  15599. var res ResultTwo //1101结果
  15600. if status == "1" { //读卡成功
  15601. var card_info string //卡信息
  15602. var busi_card_info string
  15603. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15604. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15605. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15606. fmt.Println(card_info)
  15607. fmt.Println(busi_card_info)
  15608. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15609. result, _ := json.Marshal(respJSON)
  15610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15611. utils.ErrorLog("解析失败:%v", err)
  15612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15613. return
  15614. }
  15615. if res.Infcode == 0 {
  15616. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15617. if err == gorm.ErrRecordNotFound {
  15618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15619. return
  15620. } else if err != nil {
  15621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15622. return
  15623. } else {
  15624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15626. infoStr := string(Iinfos)
  15627. idetinfoStr := string(Idetinfos)
  15628. psn := &models.HisPsn{
  15629. PsnNo: res.Output.Baseinfo.PsnNo,
  15630. PatientId: patient.ID,
  15631. Certno: res.Output.Baseinfo.Certno,
  15632. Gend: res.Output.Baseinfo.Gend,
  15633. Naty: res.Output.Baseinfo.Naty,
  15634. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15635. PsnName: res.Output.Baseinfo.PsnName,
  15636. Idetinfo: idetinfoStr,
  15637. Insuinfo: infoStr,
  15638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15639. CardInfo: card_info,
  15640. VerifyNumber: token,
  15641. }
  15642. var rf []*ResultFive
  15643. json.Unmarshal([]byte(infoStr), &rf)
  15644. var insutypes []*ResultFive
  15645. var insutype string
  15646. var is390 int = 0
  15647. var is310 int = 0
  15648. for _, item := range rf {
  15649. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15650. insutypes = append(insutypes, item)
  15651. }
  15652. }
  15653. if len(insutypes) == 1 {
  15654. insutype = insutypes[0].Insutype
  15655. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15656. } else {
  15657. for _, i := range insutypes {
  15658. if i.Insutype == "390" {
  15659. is390 = 1
  15660. }
  15661. if i.Insutype == "310" {
  15662. is310 = 1
  15663. }
  15664. }
  15665. }
  15666. if is390 == 1 {
  15667. insutype = "390"
  15668. }
  15669. if is310 == 1 {
  15670. insutype = "310"
  15671. }
  15672. if len(insutypes) == 0 {
  15673. insutype = "310"
  15674. }
  15675. service.CreateHisPsn(psn)
  15676. c.ServeSuccessJSON(map[string]interface{}{
  15677. "patient": patient,
  15678. "number": token,
  15679. "insutype": insutype,
  15680. })
  15681. }
  15682. } else {
  15683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15684. return
  15685. }
  15686. } else { //读卡失败
  15687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15688. return
  15689. }
  15690. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15691. //idNo := c.GetString("idNo")
  15692. //userName := c.GetString("userName")
  15693. //ecToken := c.GetString("ecToken")
  15694. //insuOrg := c.GetString("insuOrg")
  15695. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15696. utils.ErrorLog("解析失败:%v", json_result)
  15697. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15698. type ELeData struct {
  15699. Data struct {
  15700. IdNo string `json:"idNo"`
  15701. IdType string `json:"idType"`
  15702. UserName string `json:"userName"`
  15703. EcToken string `json:"ecToken"`
  15704. InsuOrg string `json:"insuOrg"`
  15705. Gender string `json:"gender"`
  15706. Birthday string `json:"birthday"`
  15707. Nationality string `json:"nationality"`
  15708. Email string `json:"email"`
  15709. Extra string `json:"extra"`
  15710. } `json:"data"`
  15711. Code int `json:"code"`
  15712. Message string `json:"message"`
  15713. }
  15714. var ele ELeData
  15715. err := json.Unmarshal([]byte(json_result), &ele)
  15716. if err != nil {
  15717. utils.ErrorLog("解析失败:%v", err)
  15718. }
  15719. token := ele.Data.EcToken
  15720. token = Remove0000(token)
  15721. 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)
  15722. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15723. var res ResultTwo
  15724. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15725. utils.ErrorLog("解析失败:%v", err)
  15726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15727. return
  15728. }
  15729. if res.Infcode == 0 {
  15730. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15731. if err == gorm.ErrRecordNotFound {
  15732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15733. return
  15734. } else if err != nil {
  15735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15736. return
  15737. } else {
  15738. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15739. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15740. infoStr := string(Iinfos)
  15741. idetinfoStr := string(Idetinfos)
  15742. psn := &models.HisPsn{
  15743. PsnNo: res.Output.Baseinfo.PsnNo,
  15744. PatientId: patient.ID,
  15745. Certno: res.Output.Baseinfo.Certno,
  15746. Gend: res.Output.Baseinfo.Gend,
  15747. Naty: res.Output.Baseinfo.Naty,
  15748. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15749. PsnName: res.Output.Baseinfo.PsnName,
  15750. Idetinfo: idetinfoStr,
  15751. Insuinfo: infoStr,
  15752. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15753. CardInfo: "",
  15754. Stage: "1",
  15755. VerifyNumber: token,
  15756. InsuplcAdmdvs: ele.Data.InsuOrg,
  15757. }
  15758. service.CreateHisPsn(psn)
  15759. var rf []*ResultFive
  15760. json.Unmarshal([]byte(infoStr), &rf)
  15761. var insutypes []*ResultFive
  15762. var insutype string
  15763. var is390 int = 0
  15764. var is310 int = 0
  15765. for _, item := range rf {
  15766. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15767. insutypes = append(insutypes, item)
  15768. }
  15769. }
  15770. if len(insutypes) == 1 {
  15771. insutype = insutypes[0].Insutype
  15772. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15773. } else {
  15774. for _, i := range insutypes {
  15775. if i.Insutype == "390" {
  15776. is390 = 1
  15777. }
  15778. if i.Insutype == "310" {
  15779. is310 = 1
  15780. }
  15781. }
  15782. }
  15783. if is390 == 1 {
  15784. insutype = "390"
  15785. }
  15786. if is310 == 1 {
  15787. insutype = "310"
  15788. }
  15789. if len(insutypes) == 0 {
  15790. insutype = "310"
  15791. }
  15792. c.ServeSuccessJSON(map[string]interface{}{
  15793. "patient": patient,
  15794. "number": token,
  15795. "insutype": insutype,
  15796. })
  15797. }
  15798. } else {
  15799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15800. return
  15801. }
  15802. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15803. //if initFlag == 0 {
  15804. //c.TestGetJiangXiBasBaseInit()
  15805. //}
  15806. //if initEleFlag == 0 {
  15807. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15808. //}
  15809. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15810. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15811. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15812. type ELeData struct {
  15813. Data struct {
  15814. IdNo string `json:"idNo"`
  15815. IdType string `json:"idType"`
  15816. UserName string `json:"userName"`
  15817. EcToken string `json:"ecToken"`
  15818. InsuOrg string `json:"insuOrg"`
  15819. Gender string `json:"gender"`
  15820. Birthday string `json:"birthday"`
  15821. Nationality string `json:"nationality"`
  15822. Email string `json:"email"`
  15823. Extra string `json:"extra"`
  15824. } `json:"data"`
  15825. Code int `json:"code"`
  15826. Message string `json:"message"`
  15827. }
  15828. var ele ELeData
  15829. err := json.Unmarshal([]byte(result), &ele)
  15830. if err != nil {
  15831. utils.ErrorLog("解析失败:%v", err)
  15832. }
  15833. token := ele.Data.EcToken
  15834. token = Remove0000(token)
  15835. 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)
  15836. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15837. var res ResultTwo
  15838. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15839. utils.ErrorLog("解析失败:%v", err)
  15840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15841. return
  15842. }
  15843. if res.Infcode == 0 {
  15844. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15845. if err == gorm.ErrRecordNotFound {
  15846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15847. return
  15848. } else if err != nil {
  15849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15850. return
  15851. } else {
  15852. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15853. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15854. infoStr := string(Iinfos)
  15855. idetinfoStr := string(Idetinfos)
  15856. psn := &models.HisPsn{
  15857. PsnNo: res.Output.Baseinfo.PsnNo,
  15858. PatientId: patient.ID,
  15859. Certno: res.Output.Baseinfo.Certno,
  15860. Gend: res.Output.Baseinfo.Gend,
  15861. Naty: res.Output.Baseinfo.Naty,
  15862. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15863. PsnName: res.Output.Baseinfo.PsnName,
  15864. Idetinfo: idetinfoStr,
  15865. Insuinfo: infoStr,
  15866. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15867. CardInfo: "",
  15868. VerifyNumber: token,
  15869. InsuplcAdmdvs: ele.Data.InsuOrg,
  15870. }
  15871. service.CreateHisPsn(psn)
  15872. var rf []*ResultFive
  15873. json.Unmarshal([]byte(infoStr), &rf)
  15874. var insutypes []*ResultFive
  15875. var insutype string
  15876. var is390 int = 0
  15877. var is310 int = 0
  15878. for _, item := range rf {
  15879. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15880. insutypes = append(insutypes, item)
  15881. }
  15882. }
  15883. if len(insutypes) == 1 {
  15884. insutype = insutypes[0].Insutype
  15885. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15886. } else {
  15887. for _, i := range insutypes {
  15888. if i.Insutype == "390" {
  15889. is390 = 1
  15890. }
  15891. if i.Insutype == "310" {
  15892. is310 = 1
  15893. }
  15894. }
  15895. }
  15896. if is390 == 1 {
  15897. insutype = "390"
  15898. }
  15899. if is310 == 1 {
  15900. insutype = "310"
  15901. }
  15902. if len(insutypes) == 0 {
  15903. insutype = "310"
  15904. }
  15905. c.ServeSuccessJSON(map[string]interface{}{
  15906. "patient": patient,
  15907. "number": token,
  15908. "insutype": insutype,
  15909. })
  15910. }
  15911. } else {
  15912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15913. return
  15914. }
  15915. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15916. //if initFlag == 0 {
  15917. //c.TestGetJiangXiBasBaseInit()
  15918. //}
  15919. //if initEleFlag == 0 {
  15920. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15921. //}
  15922. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15923. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15924. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15925. type ELeData struct {
  15926. Data struct {
  15927. IdNo string `json:"idNo"`
  15928. IdType string `json:"idType"`
  15929. UserName string `json:"userName"`
  15930. EcToken string `json:"ecToken"`
  15931. InsuOrg string `json:"insuOrg"`
  15932. Gender string `json:"gender"`
  15933. Birthday string `json:"birthday"`
  15934. Nationality string `json:"nationality"`
  15935. Email string `json:"email"`
  15936. Extra string `json:"extra"`
  15937. } `json:"data"`
  15938. Code int `json:"code"`
  15939. Message string `json:"message"`
  15940. }
  15941. var ele ELeData
  15942. err := json.Unmarshal([]byte(result), &ele)
  15943. if err != nil {
  15944. utils.ErrorLog("解析失败:%v", err)
  15945. }
  15946. token := ele.Data.EcToken
  15947. token = Remove0000(token)
  15948. 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)
  15949. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15950. var res ResultTwo
  15951. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15952. utils.ErrorLog("解析失败:%v", err)
  15953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15954. return
  15955. }
  15956. if res.Infcode == 0 {
  15957. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15958. if err == gorm.ErrRecordNotFound {
  15959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15960. return
  15961. } else if err != nil {
  15962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15963. return
  15964. } else {
  15965. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15966. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15967. infoStr := string(Iinfos)
  15968. idetinfoStr := string(Idetinfos)
  15969. psn := &models.HisPsn{
  15970. PsnNo: res.Output.Baseinfo.PsnNo,
  15971. PatientId: patient.ID,
  15972. Certno: res.Output.Baseinfo.Certno,
  15973. Gend: res.Output.Baseinfo.Gend,
  15974. Naty: res.Output.Baseinfo.Naty,
  15975. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15976. PsnName: res.Output.Baseinfo.PsnName,
  15977. Idetinfo: idetinfoStr,
  15978. Insuinfo: infoStr,
  15979. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15980. CardInfo: "",
  15981. VerifyNumber: token,
  15982. InsuplcAdmdvs: ele.Data.InsuOrg,
  15983. }
  15984. service.CreateHisPsn(psn)
  15985. var rf []*ResultFive
  15986. json.Unmarshal([]byte(infoStr), &rf)
  15987. var insutypes []*ResultFive
  15988. var insutype string
  15989. var is390 int = 0
  15990. var is310 int = 0
  15991. for _, item := range rf {
  15992. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15993. insutypes = append(insutypes, item)
  15994. }
  15995. }
  15996. if len(insutypes) == 1 {
  15997. insutype = insutypes[0].Insutype
  15998. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15999. } else {
  16000. for _, i := range insutypes {
  16001. if i.Insutype == "390" {
  16002. is390 = 1
  16003. }
  16004. if i.Insutype == "310" {
  16005. is310 = 1
  16006. }
  16007. }
  16008. }
  16009. if is390 == 1 {
  16010. insutype = "390"
  16011. }
  16012. if is310 == 1 {
  16013. insutype = "310"
  16014. }
  16015. if len(insutypes) == 0 {
  16016. insutype = "310"
  16017. }
  16018. c.ServeSuccessJSON(map[string]interface{}{
  16019. "patient": patient,
  16020. "number": token,
  16021. "insutype": insutype,
  16022. })
  16023. }
  16024. } else {
  16025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16026. return
  16027. }
  16028. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16029. //if initFlag == 0 {
  16030. c.TestGetJiangXiBasBaseInit()
  16031. //}
  16032. //if initEleFlag == 0 {
  16033. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16034. //}
  16035. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16036. type ELeData struct {
  16037. Data struct {
  16038. IdNo string `json:"idNo"`
  16039. IdType string `json:"idType"`
  16040. UserName string `json:"userName"`
  16041. EcToken string `json:"ecToken"`
  16042. InsuOrg string `json:"insuOrg"`
  16043. Gender string `json:"gender"`
  16044. Birthday string `json:"birthday"`
  16045. Nationality string `json:"nationality"`
  16046. Email string `json:"email"`
  16047. Extra string `json:"extra"`
  16048. } `json:"data"`
  16049. Code int `json:"code"`
  16050. Message string `json:"message"`
  16051. }
  16052. var ele ELeData
  16053. err := json.Unmarshal([]byte(json_result), &ele)
  16054. if err != nil {
  16055. utils.ErrorLog("解析失败:%v", err)
  16056. }
  16057. token := ele.Data.EcToken
  16058. token = Remove0000(token)
  16059. 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)
  16060. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16061. var res ResultTwo
  16062. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16063. utils.ErrorLog("解析失败:%v", err)
  16064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16065. return
  16066. }
  16067. if res.Infcode == 0 {
  16068. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16069. if err == gorm.ErrRecordNotFound {
  16070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16071. return
  16072. } else if err != nil {
  16073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16074. return
  16075. } else {
  16076. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16077. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16078. infoStr := string(Iinfos)
  16079. idetinfoStr := string(Idetinfos)
  16080. psn := &models.HisPsn{
  16081. PsnNo: res.Output.Baseinfo.PsnNo,
  16082. PatientId: patient.ID,
  16083. Certno: res.Output.Baseinfo.Certno,
  16084. Gend: res.Output.Baseinfo.Gend,
  16085. Naty: res.Output.Baseinfo.Naty,
  16086. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16087. PsnName: res.Output.Baseinfo.PsnName,
  16088. Idetinfo: idetinfoStr,
  16089. Insuinfo: infoStr,
  16090. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16091. CardInfo: "",
  16092. VerifyNumber: token,
  16093. }
  16094. service.CreateHisPsn(psn)
  16095. var rf []*ResultFive
  16096. json.Unmarshal([]byte(infoStr), &rf)
  16097. var insutypes []*ResultFive
  16098. var insutype string
  16099. var is390 int = 0
  16100. var is310 int = 0
  16101. for _, item := range rf {
  16102. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16103. insutypes = append(insutypes, item)
  16104. }
  16105. }
  16106. if len(insutypes) == 1 {
  16107. insutype = insutypes[0].Insutype
  16108. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16109. } else {
  16110. for _, i := range insutypes {
  16111. if i.Insutype == "390" {
  16112. is390 = 1
  16113. }
  16114. if i.Insutype == "310" {
  16115. is310 = 1
  16116. }
  16117. }
  16118. }
  16119. if is390 == 1 {
  16120. insutype = "390"
  16121. }
  16122. if is310 == 1 {
  16123. insutype = "310"
  16124. }
  16125. if len(insutypes) == 0 {
  16126. insutype = "310"
  16127. }
  16128. c.ServeSuccessJSON(map[string]interface{}{
  16129. "patient": patient,
  16130. "number": token,
  16131. "insutype": insutype,
  16132. })
  16133. }
  16134. } else {
  16135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16136. return
  16137. }
  16138. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16139. type ELeData struct {
  16140. Code string `json:"code"`
  16141. Data struct {
  16142. Aac002 string `json:"aac002"`
  16143. Aaz500 string `json:"aaz500"`
  16144. ActCardNo string `json:"actCardNo"`
  16145. Bab520 string `json:"bab520"`
  16146. Bkz543 string `json:"bkz543"`
  16147. BusinessType string `json:"businessType"`
  16148. CertfCodg string `json:"certfCodg"`
  16149. EcIndexNo string `json:"ecIndexNo"`
  16150. EcToken string `json:"ecToken"`
  16151. ID0000 string `json:"id0000"`
  16152. IDNo string `json:"idNo"`
  16153. IDType string `json:"idType"`
  16154. Idcode string `json:"idcode"`
  16155. IdentityToken string `json:"identity_token"`
  16156. InsuOrg string `json:"insuOrg"`
  16157. OfficeID string `json:"officeId"`
  16158. OfficeName string `json:"officeName"`
  16159. OperatorID string `json:"operatorId"`
  16160. OperatorName string `json:"operatorName"`
  16161. OrgID string `json:"orgId"`
  16162. UserName string `json:"userName"`
  16163. } `json:"data"`
  16164. Infno interface{} `json:"infno"`
  16165. Message string `json:"message"`
  16166. OrgID string `json:"orgId"`
  16167. TransType string `json:"transType"`
  16168. }
  16169. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16170. outPutInfo = Remove0000(outPutInfo)
  16171. if len(outPutInfo) > 0 {
  16172. var ele ELeData
  16173. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16174. if err != nil {
  16175. utils.ErrorLog("解析失败:%v", err)
  16176. }
  16177. token := ele.Data.EcToken
  16178. fmt.Println(inputInfo)
  16179. fmt.Println(outPutInfo)
  16180. 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)
  16181. saveLog(result, requestLog, "1101", "获取人员信息")
  16182. var dat map[string]interface{}
  16183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16184. fmt.Println(dat)
  16185. } else {
  16186. fmt.Println(err)
  16187. }
  16188. userJSONBytes, _ := json.Marshal(dat)
  16189. var res ResultTwo
  16190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16191. utils.ErrorLog("解析失败:%v", err)
  16192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16193. return
  16194. }
  16195. res.ErrMsg = errMsgLog
  16196. if res.Infcode == 0 {
  16197. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16198. if err == gorm.ErrRecordNotFound {
  16199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16200. return
  16201. } else if err != nil {
  16202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16203. return
  16204. } else {
  16205. fmt.Println(res)
  16206. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16207. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16208. infoStr := string(Iinfos)
  16209. idetinfoStr := string(Idetinfos)
  16210. psn := &models.HisPsn{
  16211. PsnNo: res.Output.Baseinfo.PsnNo,
  16212. PatientId: patient.ID,
  16213. Certno: res.Output.Baseinfo.Certno,
  16214. Gend: res.Output.Baseinfo.Gend,
  16215. Naty: res.Output.Baseinfo.Naty,
  16216. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16217. PsnName: res.Output.Baseinfo.PsnName,
  16218. Idetinfo: idetinfoStr,
  16219. Insuinfo: infoStr,
  16220. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16221. CardInfo: outPutInfo,
  16222. VerifyNumber: token,
  16223. InsuplcAdmdvs: ele.Data.InsuOrg,
  16224. }
  16225. service.CreateHisPsn(psn)
  16226. var rf []*ResultFive
  16227. json.Unmarshal([]byte(infoStr), &rf)
  16228. var insutypes []*ResultFive
  16229. var insutype string
  16230. var is390 int = 0
  16231. var is310 int = 0
  16232. for _, item := range rf {
  16233. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16234. insutypes = append(insutypes, item)
  16235. }
  16236. }
  16237. if len(insutypes) == 1 {
  16238. insutype = insutypes[0].Insutype
  16239. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16240. } else {
  16241. for _, i := range insutypes {
  16242. if i.Insutype == "390" {
  16243. is390 = 1
  16244. }
  16245. if i.Insutype == "310" {
  16246. is310 = 1
  16247. }
  16248. }
  16249. }
  16250. if is390 == 1 {
  16251. insutype = "390"
  16252. }
  16253. if is310 == 1 {
  16254. insutype = "310"
  16255. }
  16256. if len(insutypes) == 0 {
  16257. insutype = "310"
  16258. }
  16259. c.ServeSuccessJSON(map[string]interface{}{
  16260. "patient": patient,
  16261. "number": token,
  16262. "insutype": insutype,
  16263. })
  16264. }
  16265. } else {
  16266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16267. return
  16268. }
  16269. }
  16270. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16271. var api string
  16272. 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 +
  16273. "&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
  16274. resp, requestErr := http.Get(api)
  16275. if requestErr != nil {
  16276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16277. return
  16278. }
  16279. body, ioErr := ioutil.ReadAll(resp.Body)
  16280. if ioErr != nil {
  16281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16283. return
  16284. }
  16285. var respJSON map[string]interface{}
  16286. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16289. return
  16290. }
  16291. var status string
  16292. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16293. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16294. var token string
  16295. var res ResultTwo //1101结果
  16296. var res10265 ResultTwo10265 //1101结果
  16297. if status == "0" { //读卡成功
  16298. var card_info string //卡信息
  16299. var busi_card_info string
  16300. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16301. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16302. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16303. fmt.Println(card_info)
  16304. fmt.Println(busi_card_info)
  16305. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16306. result, _ := json.Marshal(respJSON)
  16307. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16308. utils.ErrorLog("解析失败:%v", err)
  16309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16310. return
  16311. }
  16312. res.ErrMsg = res10265.ErrMsg
  16313. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16314. res.Infcode = infocode
  16315. res.Output = res10265.Output
  16316. res.InfRefmsgid = res10265.InfRefmsgid
  16317. if res.Infcode == 0 {
  16318. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16319. if err == gorm.ErrRecordNotFound {
  16320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16321. return
  16322. } else if err != nil {
  16323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16324. return
  16325. } else {
  16326. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16327. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16328. infoStr := string(Iinfos)
  16329. idetinfoStr := string(Idetinfos)
  16330. psn := &models.HisPsn{
  16331. PsnNo: res.Output.Baseinfo.PsnNo,
  16332. PatientId: patient.ID,
  16333. Certno: res.Output.Baseinfo.Certno,
  16334. Gend: res.Output.Baseinfo.Gend,
  16335. Naty: res.Output.Baseinfo.Naty,
  16336. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16337. PsnName: res.Output.Baseinfo.PsnName,
  16338. Idetinfo: idetinfoStr,
  16339. Insuinfo: infoStr,
  16340. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16341. CardInfo: card_info,
  16342. VerifyNumber: token,
  16343. }
  16344. var rf []*ResultFive
  16345. json.Unmarshal([]byte(infoStr), &rf)
  16346. var insutypes []*ResultFive
  16347. var insutype string
  16348. var is390 int = 0
  16349. var is310 int = 0
  16350. for _, item := range rf {
  16351. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16352. insutypes = append(insutypes, item)
  16353. }
  16354. }
  16355. if len(insutypes) == 1 {
  16356. insutype = insutypes[0].Insutype
  16357. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16358. } else {
  16359. for _, i := range insutypes {
  16360. if i.Insutype == "390" {
  16361. is390 = 1
  16362. }
  16363. if i.Insutype == "310" {
  16364. is310 = 1
  16365. }
  16366. }
  16367. }
  16368. if is390 == 1 {
  16369. insutype = "390"
  16370. }
  16371. if is310 == 1 {
  16372. insutype = "310"
  16373. }
  16374. if len(insutypes) == 0 {
  16375. insutype = "310"
  16376. }
  16377. service.CreateHisPsn(psn)
  16378. c.ServeSuccessJSON(map[string]interface{}{
  16379. "patient": patient,
  16380. "number": token,
  16381. "insutype": insutype,
  16382. })
  16383. }
  16384. } else {
  16385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16386. return
  16387. }
  16388. } else { //读卡失败
  16389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16390. return
  16391. }
  16392. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16393. res := c.GetoleInfo()
  16394. if res.Infcode == 0 {
  16395. var result string
  16396. if res.Output.MdtrtCertType == "01" {
  16397. 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)
  16398. } else if res.Output.MdtrtCertType == "02" {
  16399. 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)
  16400. } else if res.Output.MdtrtCertType == "03" {
  16401. 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)
  16402. }
  16403. var dat map[string]interface{}
  16404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16405. fmt.Println(dat)
  16406. } else {
  16407. fmt.Println(err)
  16408. }
  16409. userJSONBytes, _ := json.Marshal(dat)
  16410. var res2 ResultTwo
  16411. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16412. utils.ErrorLog("解析失败:%v", err)
  16413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16414. return
  16415. }
  16416. if res2.Infcode == 0 {
  16417. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16418. if err == gorm.ErrRecordNotFound {
  16419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16420. return
  16421. } else if err != nil {
  16422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16423. return
  16424. } else {
  16425. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16426. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16427. infoStr := string(Iinfos)
  16428. idetinfoStr := string(Idetinfos)
  16429. var rf []*ResultFive
  16430. json.Unmarshal([]byte(infoStr), &rf)
  16431. var insutypes []*ResultFive
  16432. var insutype string
  16433. var is390 int = 0
  16434. var is310 int = 0
  16435. //var insuplc_admdvs string
  16436. for _, item := range rf {
  16437. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16438. insutypes = append(insutypes, item)
  16439. }
  16440. }
  16441. if len(insutypes) == 1 {
  16442. insutype = insutypes[0].Insutype
  16443. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16444. } else {
  16445. for _, i := range insutypes {
  16446. if i.Insutype == "390" {
  16447. is390 = 1
  16448. }
  16449. if i.Insutype == "310" {
  16450. is310 = 1
  16451. }
  16452. }
  16453. }
  16454. if is390 == 1 {
  16455. insutype = "390"
  16456. }
  16457. if is310 == 1 {
  16458. insutype = "310"
  16459. }
  16460. if len(insutypes) == 0 {
  16461. insutype = "310"
  16462. }
  16463. psn := &models.HisPsn{
  16464. PsnNo: res2.Output.Baseinfo.PsnNo,
  16465. PatientId: patient.ID,
  16466. Certno: res2.Output.Baseinfo.Certno,
  16467. Gend: res2.Output.Baseinfo.Gend,
  16468. Naty: res2.Output.Baseinfo.Naty,
  16469. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16470. PsnName: res2.Output.Baseinfo.PsnName,
  16471. Idetinfo: idetinfoStr,
  16472. Insuinfo: infoStr,
  16473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16474. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16475. VerifyNumber: res.Output.EcToken,
  16476. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16477. }
  16478. if res.Output.MdtrtCertType == "01" {
  16479. psn.VerifyNumber = res.Output.EcToken
  16480. //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)
  16481. } else if res.Output.MdtrtCertType == "02" {
  16482. psn.VerifyNumber = res.Output.CardNo
  16483. //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)
  16484. } else if res.Output.MdtrtCertType == "03" {
  16485. psn.VerifyNumber = res.Output.MdtrtCertNo
  16486. //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)
  16487. }
  16488. service.CreateHisPsn(psn)
  16489. var balc float64
  16490. for _, item := range rf {
  16491. if item.Insutype == insutype {
  16492. balc = item.Balc
  16493. }
  16494. }
  16495. c.ServeSuccessJSON(map[string]interface{}{
  16496. "patient": patient,
  16497. "number": res.Output.CardNo,
  16498. "insutype": insutype,
  16499. "blac": balc,
  16500. "desc": idetinfoStr,
  16501. })
  16502. }
  16503. } else {
  16504. c.ServeSuccessJSON(map[string]interface{}{
  16505. "failed_code": -10,
  16506. "msg": res2.ErrMsg,
  16507. })
  16508. }
  16509. } else {
  16510. c.ServeSuccessJSON(map[string]interface{}{
  16511. "failed_code": -10,
  16512. "msg": res.ErrMsg,
  16513. })
  16514. }
  16515. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16516. var res ResultTwo
  16517. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16518. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16519. "&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)
  16520. resp, requestErr := http.Get(api)
  16521. if requestErr != nil {
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16523. return
  16524. }
  16525. body, ioErr := ioutil.ReadAll(resp.Body)
  16526. if ioErr != nil {
  16527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16529. return
  16530. }
  16531. var respJSON map[string]interface{}
  16532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16535. return
  16536. }
  16537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16538. result, _ := json.Marshal(respJSON)
  16539. fmt.Println("log")
  16540. fmt.Println(string(result))
  16541. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16542. utils.ErrorLog("解析失败:%v", err)
  16543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16544. return
  16545. }
  16546. if res.Infcode == 0 {
  16547. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16548. if err == gorm.ErrRecordNotFound {
  16549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16550. return
  16551. } else if err != nil {
  16552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16553. return
  16554. } else {
  16555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16556. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16557. infoStr := string(Iinfos)
  16558. idetinfoStr := string(Idetinfos)
  16559. var rf []*ResultFive
  16560. json.Unmarshal([]byte(infoStr), &rf)
  16561. var insutypes []*ResultFive
  16562. var insutype string
  16563. var is390 int = 0
  16564. var is310 int = 0
  16565. for _, item := range rf {
  16566. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16567. insutypes = append(insutypes, item)
  16568. }
  16569. }
  16570. if len(insutypes) == 1 {
  16571. insutype = insutypes[0].Insutype
  16572. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16573. } else {
  16574. for _, i := range insutypes {
  16575. if i.Insutype == "390" {
  16576. is390 = 1
  16577. }
  16578. if i.Insutype == "310" {
  16579. is310 = 1
  16580. }
  16581. }
  16582. }
  16583. if is390 == 1 {
  16584. insutype = "390"
  16585. }
  16586. if is310 == 1 {
  16587. insutype = "310"
  16588. }
  16589. if len(insutypes) == 0 {
  16590. insutype = "390"
  16591. }
  16592. var insuplc_admdvs string
  16593. for _, item := range rf {
  16594. if item.Insutype == insutype {
  16595. insuplc_admdvs = item.InsuplcAdmdvs
  16596. }
  16597. }
  16598. psn := &models.HisPsn{
  16599. PsnNo: res.Output.Baseinfo.PsnNo,
  16600. PatientId: patient.ID,
  16601. Certno: res.Output.Baseinfo.Certno,
  16602. Gend: res.Output.Baseinfo.Gend,
  16603. Naty: res.Output.Baseinfo.Naty,
  16604. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16605. PsnName: res.Output.Baseinfo.PsnName,
  16606. Idetinfo: idetinfoStr,
  16607. Insuinfo: infoStr,
  16608. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16609. InsuplcAdmdvs: insuplc_admdvs,
  16610. }
  16611. service.CreateHisPsn(psn)
  16612. c.ServeSuccessJSON(map[string]interface{}{
  16613. "patient": patient,
  16614. "number": res.Output.Baseinfo.Certno,
  16615. })
  16616. }
  16617. } else {
  16618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16619. return
  16620. }
  16621. } else {
  16622. type ELeData struct {
  16623. Code string `json:"code"`
  16624. Data struct {
  16625. Aac002 string `json:"aac002"`
  16626. Aaz500 string `json:"aaz500"`
  16627. ActCardNo string `json:"actCardNo"`
  16628. Bab520 string `json:"bab520"`
  16629. Bkz543 string `json:"bkz543"`
  16630. BusinessType string `json:"businessType"`
  16631. CertfCodg string `json:"certfCodg"`
  16632. EcIndexNo string `json:"ecIndexNo"`
  16633. EcToken string `json:"ecToken"`
  16634. ID0000 string `json:"id0000"`
  16635. IDNo string `json:"idNo"`
  16636. IDType string `json:"idType"`
  16637. Idcode string `json:"idcode"`
  16638. IdentityToken string `json:"identity_token"`
  16639. InsuOrg string `json:"insuOrg"`
  16640. OfficeID string `json:"officeId"`
  16641. OfficeName string `json:"officeName"`
  16642. OperatorID string `json:"operatorId"`
  16643. OperatorName string `json:"operatorName"`
  16644. OrgID string `json:"orgId"`
  16645. UserName string `json:"userName"`
  16646. } `json:"data"`
  16647. Infno interface{} `json:"infno"`
  16648. Message string `json:"message"`
  16649. OrgID string `json:"orgId"`
  16650. TransType string `json:"transType"`
  16651. }
  16652. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16653. fmt.Println(result)
  16654. outPutInfo := Remove0000(result)
  16655. fmt.Println(outPutInfo)
  16656. if len(outPutInfo) > 0 {
  16657. var ele ELeData
  16658. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16659. if err != nil {
  16660. utils.ErrorLog("解析失败:%v", err)
  16661. }
  16662. token := ele.Data.EcToken
  16663. fmt.Println(outPutInfo)
  16664. 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)
  16665. saveLog(result, requestLog, "1101", "获取人员信息")
  16666. var dat map[string]interface{}
  16667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16668. fmt.Println(dat)
  16669. } else {
  16670. fmt.Println(err)
  16671. }
  16672. userJSONBytes, _ := json.Marshal(dat)
  16673. var res ResultTwo
  16674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16675. utils.ErrorLog("解析失败:%v", err)
  16676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16677. return
  16678. }
  16679. if res.Infcode == 0 {
  16680. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16681. if err == gorm.ErrRecordNotFound {
  16682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16683. return
  16684. } else if err != nil {
  16685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16686. return
  16687. } else {
  16688. fmt.Println(res)
  16689. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16690. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16691. infoStr := string(Iinfos)
  16692. idetinfoStr := string(Idetinfos)
  16693. psn := &models.HisPsn{
  16694. PsnNo: res.Output.Baseinfo.PsnNo,
  16695. PatientId: patient.ID,
  16696. Certno: res.Output.Baseinfo.Certno,
  16697. Gend: res.Output.Baseinfo.Gend,
  16698. Naty: res.Output.Baseinfo.Naty,
  16699. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16700. PsnName: res.Output.Baseinfo.PsnName,
  16701. Idetinfo: idetinfoStr,
  16702. Insuinfo: infoStr,
  16703. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16704. CardInfo: outPutInfo,
  16705. VerifyNumber: token,
  16706. InsuplcAdmdvs: ele.Data.InsuOrg,
  16707. }
  16708. service.CreateHisPsn(psn)
  16709. var rf []*ResultFive
  16710. json.Unmarshal([]byte(infoStr), &rf)
  16711. var insutypes []*ResultFive
  16712. var insutype string
  16713. var is390 int = 0
  16714. var is310 int = 0
  16715. for _, item := range rf {
  16716. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16717. insutypes = append(insutypes, item)
  16718. }
  16719. }
  16720. if len(insutypes) == 1 {
  16721. insutype = insutypes[0].Insutype
  16722. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16723. } else {
  16724. for _, i := range insutypes {
  16725. if i.Insutype == "390" {
  16726. is390 = 1
  16727. }
  16728. if i.Insutype == "310" {
  16729. is310 = 1
  16730. }
  16731. }
  16732. }
  16733. if is390 == 1 {
  16734. insutype = "390"
  16735. }
  16736. if is310 == 1 {
  16737. insutype = "310"
  16738. }
  16739. if len(insutypes) == 0 {
  16740. insutype = "310"
  16741. }
  16742. c.ServeSuccessJSON(map[string]interface{}{
  16743. "patient": patient,
  16744. "number": token,
  16745. "insutype": insutype,
  16746. })
  16747. }
  16748. } else {
  16749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16750. return
  16751. }
  16752. }
  16753. //fmt.Println(result)
  16754. //
  16755. //if initFlag == 0 {
  16756. // c.TestGetBasBaseInit()
  16757. //}
  16758. //token := c.GetEleBaseInfo()
  16759. //
  16760. //token = Remove0000(token)
  16761. //
  16762. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16763. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16764. ////
  16765. //var res ResultTwo
  16766. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16767. // utils.ErrorLog("解析失败:%v", err)
  16768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16769. // return
  16770. //}
  16771. //
  16772. //if res.Infcode == 0 {
  16773. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16774. // if err == gorm.ErrRecordNotFound {
  16775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16776. // return
  16777. // } else if err != nil {
  16778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16779. // return
  16780. //
  16781. // } else {
  16782. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16783. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16784. // infoStr := string(Iinfos)
  16785. // idetinfoStr := string(Idetinfos)
  16786. //
  16787. //
  16788. //
  16789. //
  16790. // var rf []*ResultFive
  16791. // json.Unmarshal([]byte(infoStr), &rf)
  16792. //
  16793. // var insutypes []*ResultFive
  16794. // var insutype string
  16795. // var is390 int = 0
  16796. // var is310 int = 0
  16797. // var insuplc_admdvs string
  16798. //
  16799. // for _, item := range rf {
  16800. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16801. // insutypes = append(insutypes, item)
  16802. // }
  16803. // }
  16804. //
  16805. // if len(insutypes) == 1 {
  16806. // insutype = insutypes[0].Insutype
  16807. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16808. // } else {
  16809. // for _, i := range insutypes {
  16810. // if i.Insutype == "390" {
  16811. // is390 = 1
  16812. // }
  16813. //
  16814. // if i.Insutype == "310" {
  16815. // is310 = 1
  16816. // }
  16817. // }
  16818. // }
  16819. // if is390 == 1 {
  16820. // insutype = "390"
  16821. // }
  16822. //
  16823. // if is310 == 1 {
  16824. // insutype = "310"
  16825. // }
  16826. // if len(insutypes) == 0 {
  16827. // insutype = "310"
  16828. // }
  16829. // for _, item := range rf {
  16830. // if item.Insutype == insutype {
  16831. // insuplc_admdvs = item.InsuplcAdmdvs
  16832. // }
  16833. // }
  16834. // psn := &models.HisPsn{
  16835. // PsnNo: res.Output.Baseinfo.PsnNo,
  16836. // Age: res.Output.Baseinfo.Age,
  16837. // PatientId: patient.ID,
  16838. // Certno: res.Output.Baseinfo.Certno,
  16839. // Brdy: res.Output.Baseinfo.Brdy,
  16840. // Gend: res.Output.Baseinfo.Gend,
  16841. // Naty: res.Output.Baseinfo.Naty,
  16842. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16843. // PsnName: res.Output.Baseinfo.PsnName,
  16844. // Idetinfo: idetinfoStr,
  16845. // Insuinfo: infoStr,
  16846. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16847. // CardInfo: "",
  16848. // VerifyNumber: token,
  16849. // InsuplcAdmdvs: insuplc_admdvs,
  16850. // }
  16851. // service.CreateHisPsn(psn)
  16852. //
  16853. // c.ServeSuccessJSON(map[string]interface{}{
  16854. // "patient": patient,
  16855. // "number": token,
  16856. // })
  16857. // }
  16858. //} else {
  16859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16860. // return
  16861. //}
  16862. }
  16863. break
  16864. case 5:
  16865. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16866. var api string
  16867. if miConfig.MdtrtareaAdmvs == "320921" {
  16868. 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 +
  16869. "&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
  16870. fmt.Println(api)
  16871. } else {
  16872. 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 +
  16873. "&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)
  16874. }
  16875. resp, requestErr := http.Get(api)
  16876. if requestErr != nil {
  16877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16878. return
  16879. }
  16880. body, ioErr := ioutil.ReadAll(resp.Body)
  16881. if ioErr != nil {
  16882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16884. return
  16885. }
  16886. var respJSON map[string]interface{}
  16887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16890. return
  16891. }
  16892. var status string
  16893. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16894. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16895. var token string
  16896. var res ResultTwo //1101结果
  16897. var res10265 ResultTwo10265 //1101结果
  16898. if status == "0" { //读卡成功
  16899. var card_info string //卡信息
  16900. //var busi_card_info string
  16901. var auth_info string
  16902. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16903. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16904. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16905. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16906. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16907. result, _ := json.Marshal(respJSON)
  16908. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16909. utils.ErrorLog("解析失败:%v", err)
  16910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16911. return
  16912. }
  16913. res.ErrMsg = res10265.ErrMsg
  16914. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16915. res.Infcode = infocode
  16916. res.Output = res10265.Output
  16917. res.InfRefmsgid = res10265.InfRefmsgid
  16918. if res.Infcode == 0 {
  16919. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16920. if err == gorm.ErrRecordNotFound {
  16921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16922. return
  16923. } else if err != nil {
  16924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16925. return
  16926. } else {
  16927. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16928. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16929. infoStr := string(Iinfos)
  16930. idetinfoStr := string(Idetinfos)
  16931. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16932. psn := &models.HisPsn{
  16933. PsnNo: res.Output.Baseinfo.PsnNo,
  16934. PatientId: patient.ID,
  16935. Certno: res.Output.Baseinfo.Certno,
  16936. Gend: res.Output.Baseinfo.Gend,
  16937. Brdy: b,
  16938. Age: float64(age),
  16939. Naty: res.Output.Baseinfo.Naty,
  16940. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16941. PsnName: res.Output.Baseinfo.PsnName,
  16942. Idetinfo: idetinfoStr,
  16943. Insuinfo: infoStr,
  16944. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16945. CardInfo: card_info,
  16946. VerifyNumber: token,
  16947. AuthInfo: auth_info,
  16948. }
  16949. var rf []*ResultFive
  16950. json.Unmarshal([]byte(infoStr), &rf)
  16951. var insutypes []*ResultFive
  16952. var insutype string
  16953. var is390 int = 0
  16954. var is310 int = 0
  16955. for _, item := range rf {
  16956. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16957. insutypes = append(insutypes, item)
  16958. }
  16959. }
  16960. if len(insutypes) == 1 {
  16961. insutype = insutypes[0].Insutype
  16962. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16963. } else {
  16964. for _, i := range insutypes {
  16965. if i.Insutype == "390" {
  16966. is390 = 1
  16967. }
  16968. if i.Insutype == "310" {
  16969. is310 = 1
  16970. }
  16971. }
  16972. }
  16973. if is390 == 1 {
  16974. insutype = "390"
  16975. }
  16976. if is310 == 1 {
  16977. insutype = "310"
  16978. }
  16979. if len(insutypes) == 0 {
  16980. insutype = "310"
  16981. }
  16982. service.CreateHisPsn(psn)
  16983. c.ServeSuccessJSON(map[string]interface{}{
  16984. "patient": patient,
  16985. "number": token,
  16986. "insutype": insutype,
  16987. })
  16988. }
  16989. } else {
  16990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16991. return
  16992. }
  16993. } else { //读卡失败
  16994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16995. return
  16996. }
  16997. }
  16998. break
  16999. }
  17000. }
  17001. var initFlag int64 = 0
  17002. var initEleFlag int64 = 0
  17003. func (c *HisApiController) TestGetBasBaseInit() {
  17004. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17005. Iinit := DllDef.MustFindProc("Init")
  17006. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17007. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17008. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17009. if ret != 0 {
  17010. fmt.Println("SSCard的报错原因:", err)
  17011. fmt.Println("SSCard的运算结果为:", ret)
  17012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17013. return
  17014. }
  17015. result := int(ret)
  17016. fmt.Println("SSCard的运算结果为1:", result)
  17017. initFlag = 1
  17018. return
  17019. }
  17020. func (c *HisApiController) HandleJiangXiReadCard() {
  17021. fmt.Println("~~~~~~")
  17022. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17023. admin_user_id, _ := c.GetInt64("admin_user_id")
  17024. id_card_type, _ := c.GetInt64("id_card_type")
  17025. //certificates, _ := c.GetInt64("certificates")
  17026. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17027. if initFlag == 0 {
  17028. c.TestGetJiangXiBasBaseInit()
  17029. }
  17030. basStr := c.GetBasBaseInfo()
  17031. if len(basStr) == 0 {
  17032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17033. return
  17034. }
  17035. fmt.Println(basStr)
  17036. bas := strings.Split(basStr, "|")
  17037. basNumber := bas[1]
  17038. fmt.Println(basNumber)
  17039. card_sn := bas[3]
  17040. fmt.Println(card_sn)
  17041. 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, "")
  17042. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17043. var dat map[string]interface{}
  17044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17045. fmt.Println(dat)
  17046. } else {
  17047. fmt.Println(err)
  17048. }
  17049. userJSONBytes, _ := json.Marshal(dat)
  17050. var res ResultTwo
  17051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17052. utils.ErrorLog("解析失败:%v", err)
  17053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17054. return
  17055. }
  17056. if res.Infcode == 0 {
  17057. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17058. if err == gorm.ErrRecordNotFound {
  17059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17060. return
  17061. } else if err != nil {
  17062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17063. return
  17064. } else {
  17065. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17066. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17067. infoStr := string(Iinfos)
  17068. idetinfoStr := string(Idetinfos)
  17069. psn := &models.HisPsn{
  17070. PsnNo: res.Output.Baseinfo.PsnNo,
  17071. PatientId: patient.ID,
  17072. Certno: res.Output.Baseinfo.Certno,
  17073. Gend: res.Output.Baseinfo.Gend,
  17074. Naty: res.Output.Baseinfo.Naty,
  17075. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17076. PsnName: res.Output.Baseinfo.PsnName,
  17077. Idetinfo: idetinfoStr,
  17078. Insuinfo: infoStr,
  17079. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17080. CardInfo: basStr,
  17081. VerifyNumber: "",
  17082. }
  17083. service.CreateHisPsn(psn)
  17084. c.ServeSuccessJSON(map[string]interface{}{
  17085. "patient": patient,
  17086. "number": basNumber,
  17087. })
  17088. }
  17089. } else {
  17090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17091. return
  17092. }
  17093. }
  17094. func (c *HisApiController) TestGetHnBasBaseInit() {
  17095. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17096. Iinit := DllDef.MustFindProc("Init")
  17097. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17098. //http://10.77.211.236/CSB/hsa-fsi-1303
  17099. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17100. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17101. // 调用 Init 函数
  17102. 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"))))
  17103. //if ret != 0 {
  17104. fmt.Println("SSCard的报错原因:", err)
  17105. fmt.Println("SSCard的运算结果为:", ret)
  17106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17107. // return
  17108. //}
  17109. result := int(ret)
  17110. fmt.Println("SSCard的运算结果为1:", result)
  17111. initFlag = 1
  17112. return
  17113. }
  17114. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17115. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17116. Iinit := DllDef.MustFindProc("Init")
  17117. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17118. //http://10.77.211.236/CSB/hsa-fsi-1303
  17119. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17120. if ret != 0 {
  17121. fmt.Println("SSCard的报错原因:", err)
  17122. fmt.Println("SSCard的运算结果为:", ret)
  17123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17124. return
  17125. }
  17126. result := int(ret)
  17127. fmt.Println("SSCard的运算结果为1:", result)
  17128. initFlag = 1
  17129. return
  17130. }
  17131. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17132. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17133. Iinit := DllDef.MustFindProc("Init")
  17134. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17135. //http://10.77.211.236/CSB/hsa-fsi-1303
  17136. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17137. if ret != 0 {
  17138. fmt.Println("SSCard的报错原因:", err)
  17139. fmt.Println("SSCard的运算结果为:", ret)
  17140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17141. return
  17142. }
  17143. result := int(ret)
  17144. fmt.Println("SSCard的运算结果为1:", result)
  17145. initFlag = 1
  17146. return
  17147. }
  17148. func (c *HisApiController) GetSFZBaseInfo() string {
  17149. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17150. readCard := DllDef.MustFindProc("ReadSFZ")
  17151. if readCard == nil {
  17152. fmt.Println("readcard is nil")
  17153. readCard = DllDef.MustFindProc("ReadSFZ")
  17154. }
  17155. str := make([]byte, 8096)
  17156. str1 := make([]byte, 8096)
  17157. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17158. fmt.Println(r)
  17159. return Remove0000(string(str))
  17160. }
  17161. func (c *HisApiController) GetEleBaseInfo() string {
  17162. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17163. readCard := DllDef.MustFindProc("GetQRBase")
  17164. fmt.Println(readCard)
  17165. if readCard == nil {
  17166. fmt.Println("readcard is nil")
  17167. readCard = DllDef.MustFindProc("GetQRBase")
  17168. }
  17169. str := make([]byte, 1024)
  17170. str1 := make([]byte, 1024)
  17171. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17172. fmt.Println(ret2)
  17173. fmt.Println(string(str1))
  17174. fmt.Println(string(str))
  17175. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17176. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17177. if ret2 != 0 {
  17178. return ""
  17179. }
  17180. return string(str)
  17181. }
  17182. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17183. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17184. readCard := DllDef.MustFindProc("NationEcTrans")
  17185. fmt.Println(readCard)
  17186. fmt.Println("!!!!!")
  17187. pBusiCardInfo := make([]byte, 2048)
  17188. input := make(map[string]interface{})
  17189. inputData := make(map[string]interface{})
  17190. inputData["orgId"] = code
  17191. inputData["businessType"] = "01101"
  17192. inputData["operatorId"] = "1"
  17193. inputData["operatorName"] = "admin"
  17194. inputData["officeId"] = "001"
  17195. inputData["officeName"] = "血透室"
  17196. inputData["deviceType"] = ""
  17197. input["data"] = inputData
  17198. input["orgId"] = code
  17199. input["transType"] = "ec.query"
  17200. bytesData, _ := json.Marshal(input)
  17201. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17202. fmt.Println(ret2)
  17203. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17204. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17205. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17206. }
  17207. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17208. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17209. readCard := DllDef.MustFindProc("NationEcTrans")
  17210. fmt.Println(readCard)
  17211. fmt.Println("!!!!!")
  17212. pBusiCardInfo := make([]byte, 2048)
  17213. input := make(map[string]interface{})
  17214. inputData := make(map[string]interface{})
  17215. inputData["orgId"] = code
  17216. inputData["businessType"] = "01101"
  17217. inputData["operatorId"] = "9"
  17218. inputData["operatorName"] = "admin"
  17219. inputData["officeId"] = "001"
  17220. inputData["officeName"] = "血透室"
  17221. inputData["deviceType"] = ""
  17222. input["data"] = inputData
  17223. input["orgId"] = code
  17224. input["transType"] = "ec.query"
  17225. bytesData, _ := json.Marshal(input)
  17226. 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])))
  17227. fmt.Println(ret2)
  17228. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17229. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17230. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17231. }
  17232. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17233. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17234. readCard := DllDef.MustFindProc("NationEcTrans")
  17235. fmt.Println(readCard)
  17236. fmt.Println("!!!!!")
  17237. pBusiCardInfo := make([]byte, 2048)
  17238. input := make(map[string]interface{})
  17239. inputData := make(map[string]interface{})
  17240. inputData["orgId"] = code
  17241. inputData["businessType"] = "01301"
  17242. inputData["operatorId"] = "9"
  17243. inputData["operatorName"] = "admin"
  17244. inputData["officeId"] = "001"
  17245. inputData["officeName"] = "血透室"
  17246. inputData["deviceType"] = ""
  17247. input["data"] = inputData
  17248. input["orgId"] = code
  17249. input["transType"] = "ec.query"
  17250. bytesData, _ := json.Marshal(input)
  17251. 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])))
  17252. fmt.Println(ret2)
  17253. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17254. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17255. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17256. }
  17257. func GetJxEleBaseInfo(org_id int64) string {
  17258. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17259. readCard := DllDef.MustFindProc("NationEcTrans")
  17260. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17261. if readCard == nil {
  17262. fmt.Println("readcard is nil")
  17263. readCard = DllDef.MustFindProc("NationEcTrans")
  17264. }
  17265. str1 := make([]byte, 1024)
  17266. data := make(map[string]interface{})
  17267. inputData := make(map[string]interface{})
  17268. inputData["orgId"] = miConfig.Code
  17269. inputData["businessType"] = "01101"
  17270. inputData["operatorId"] = "test001"
  17271. inputData["operatorName"] = "cn"
  17272. inputData["officeId"] = "32760"
  17273. inputData["officeName"] = "waike"
  17274. inputData["deviceType"] = ""
  17275. data["data"] = inputData
  17276. data["transType"] = "ec.query"
  17277. data["extra "] = ""
  17278. data["orgId"] = miConfig.Code
  17279. bytesData, _ := json.Marshal(data)
  17280. //bytesData, _ := json.Marshal(data)
  17281. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17282. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17283. fmt.Println(ret2)
  17284. fmt.Println(string(str1))
  17285. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17286. if ret2 != 0 {
  17287. return ""
  17288. }
  17289. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17290. }
  17291. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17292. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17293. // readCard := DllDef.MustFindProc("NationEcTrans")
  17294. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17295. //
  17296. // if readCard == nil {
  17297. // fmt.Println("readcard is nil")
  17298. // readCard = DllDef.MustFindProc("NationEcTrans")
  17299. // }
  17300. // str1 := make([]byte, 1024)
  17301. //
  17302. // data := make(map[string]interface{})
  17303. //
  17304. // inputData := make(map[string]interface{})
  17305. // inputData["orgId"] = miConfig.Code
  17306. // inputData["businessType"] = "01101"
  17307. // inputData["operatorId"] = "test001"
  17308. // inputData["operatorName"] = "cn"
  17309. // inputData["officeId"] = "32760"
  17310. // inputData["officeName"] = "waike"
  17311. // inputData["deviceType"] = ""
  17312. //
  17313. // data["data"] = inputData
  17314. // data["transType"] = "ec.query"
  17315. // data["extra "] = ""
  17316. // data["orgId"] = miConfig.Code
  17317. // bytesData, _ := json.Marshal(data)
  17318. // //bytesData, _ := json.Marshal(data)
  17319. //
  17320. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17321. //
  17322. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17323. // fmt.Println(ret2)
  17324. // fmt.Println(string(str1))
  17325. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17326. //
  17327. // if ret2 != 0 {
  17328. // return ""
  17329. // }
  17330. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17331. //}
  17332. func GetJxEleBaseInitInfo(org_id int64) string {
  17333. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17334. readCard := DllDef.MustFindProc("NationEcTrans")
  17335. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17336. if readCard == nil {
  17337. fmt.Println("readcard is nil")
  17338. readCard = DllDef.MustFindProc("NationEcTrans")
  17339. }
  17340. str1 := make([]byte, 2048)
  17341. data := make(map[string]interface{})
  17342. inputData := make(map[string]interface{})
  17343. inputData["orgId"] = miConfig.Code
  17344. inputData["businessType"] = "01101"
  17345. inputData["operatorId"] = "1"
  17346. inputData["operatorName"] = "huangchuang"
  17347. inputData["officeId"] = "101"
  17348. inputData["officeName"] = "xuetou"
  17349. inputData["deviceType"] = ""
  17350. data["data"] = inputData
  17351. data["transType"] = "ec.query"
  17352. data["orgId"] = miConfig.Code
  17353. bytesData, _ := json.Marshal(data)
  17354. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17355. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17356. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17357. fmt.Println(ret2)
  17358. fmt.Println(string(str1))
  17359. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17360. if ret2 != 0 {
  17361. return ""
  17362. }
  17363. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17364. initEleFlag = 1
  17365. }
  17366. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17367. }
  17368. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17369. // // 构建命令
  17370. // cmd := exec.Command("python", "b.py")
  17371. //
  17372. // // 执行命令并等待完成
  17373. // output, err := cmd.CombinedOutput()
  17374. // if err != nil {
  17375. // fmt.Println("Error executing Python script:", err)
  17376. // return
  17377. // }
  17378. //
  17379. // // 打印Python脚本的输出
  17380. // fmt.Println(string(output))
  17381. //}
  17382. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17383. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17384. readCard := DllDef.MustFindProc("gxyb_call")
  17385. if readCard == nil {
  17386. fmt.Println("readcard is nil")
  17387. readCard = DllDef.MustFindProc("gxyb_call")
  17388. }
  17389. str := make([]byte, 1024)
  17390. str1 := make([]byte, 1024)
  17391. //data := make(map[string]interface{})
  17392. currentTime := time.Now()
  17393. // 格式化时间为 "YYYYMMDDHH24MISS"
  17394. formattedTime := currentTime.Format("20060102150405")
  17395. inputData := make(map[string]interface{})
  17396. inputData2 := make(map[string]interface{})
  17397. inputData["transNo"] = "1401"
  17398. inputData["transType"] = "passwordCheck"
  17399. inputData["timestamp"] = formattedTime
  17400. inputData2["fixmedinsCode"] = code
  17401. inputData2["psnNo"] = ""
  17402. inputData["data"] = inputData2
  17403. jsonBytes, err := json.Marshal(inputData)
  17404. if err != nil {
  17405. fmt.Println("Error encoding map to JSON:", err)
  17406. }
  17407. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17408. fmt.Println(string(str1))
  17409. fmt.Println(string(str))
  17410. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17411. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17412. if ret2 != 0 {
  17413. return ""
  17414. }
  17415. return string(str)
  17416. }
  17417. func (c *HisApiController) GetoleInfo() Response {
  17418. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17419. defer ole.CoUninitialize()
  17420. // Replace with the ProgID or CLSID of your COM object
  17421. progID := "YinHai.XJ.Actual.Interface.New"
  17422. // Create COM object
  17423. unknown, err := oleutil.CreateObject(progID)
  17424. if err != nil {
  17425. fmt.Println("Unable to create COM object:", err)
  17426. }
  17427. defer unknown.Release()
  17428. // Query for the IDispatch interface
  17429. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17430. if err != nil {
  17431. fmt.Println("Unable to get IDispatch interface:", err)
  17432. }
  17433. defer dispatch.Release()
  17434. // Prepare parameters
  17435. transNo := "1401"
  17436. transType := "passwordCheck"
  17437. timestamp := time.Now().Unix()
  17438. fixmedinsCode := "H45072101171"
  17439. psnNo := ""
  17440. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17441. result2 := ""
  17442. // Call COM object's method using the IDispatch interface
  17443. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17444. fmt.Println(resulr)
  17445. fmt.Println(result2)
  17446. if err != nil {
  17447. fmt.Println("调用COM对象方法失败:", err)
  17448. }
  17449. var response Response
  17450. err2 := json.Unmarshal([]byte(result2), &response)
  17451. if err2 != nil {
  17452. fmt.Println("解析JSON失败:", err)
  17453. }
  17454. return response
  17455. }
  17456. func (c *HisApiController) GetBasBaseInfo() string {
  17457. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17458. readCard := DllDef.MustFindProc("ReadCardBas")
  17459. if readCard == nil {
  17460. fmt.Println("readcard is nil")
  17461. readCard = DllDef.MustFindProc("ReadCardBas")
  17462. }
  17463. str := make([]byte, 1024)
  17464. str1 := make([]byte, 1024)
  17465. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17466. fmt.Println(string(str1))
  17467. fmt.Println(string(str))
  17468. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17469. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17470. if ret2 != 0 {
  17471. return ""
  17472. }
  17473. return string(str)
  17474. }
  17475. type Program struct {
  17476. FunctionID string `xml:"function_id"`
  17477. CardInfo string `xml:"cardinfo"`
  17478. User string `xml:"user"`
  17479. }
  17480. func (c *HisApiController) GetBasBaseInfo1111() string {
  17481. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17482. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17483. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17484. if readCard == nil {
  17485. fmt.Println("readcard is nil")
  17486. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17487. }
  17488. if readCard2 == nil {
  17489. fmt.Println("readcard is nil")
  17490. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17491. }
  17492. str := make([]byte, 1024)
  17493. str1 := make([]byte, 1024)
  17494. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17495. str3 := make([]byte, 1024)
  17496. str4 := make([]byte, 1024)
  17497. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17498. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17499. //if err != nil {
  17500. // fmt.Println("Error opening file:", err)
  17501. //}
  17502. //defer file.Close()
  17503. //
  17504. //var lastProgram Program
  17505. //scanner := bufio.NewScanner(file)
  17506. //inProgram := false
  17507. //
  17508. //for scanner.Scan() {
  17509. // line := scanner.Text()
  17510. // if strings.Contains(line, "<program>") {
  17511. // inProgram = true
  17512. // programXML := "<program>"
  17513. // for scanner.Scan() {
  17514. // line = scanner.Text()
  17515. // programXML += line
  17516. // if strings.Contains(line, "</program>") {
  17517. // programXML += "</program>"
  17518. // break
  17519. // }
  17520. // }
  17521. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17522. // // 解析成功,更新最后的 Program
  17523. // }
  17524. // inProgram = false
  17525. // }
  17526. //}
  17527. //
  17528. // fmt.Println("Error reading file:", inProgram)
  17529. //
  17530. //if err := scanner.Err(); err != nil {
  17531. // fmt.Println("Error reading file:", err)
  17532. //}
  17533. // 输出最后一次的 Program
  17534. //fmt.Printf("最后一次的 <program>:\n")
  17535. //fmt.Printf("<program>\n")
  17536. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17537. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17538. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17539. //fmt.Printf("</program>\n")
  17540. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17541. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17542. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17543. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17544. return ConvertToString(string(str), "gbk", "utf-8")
  17545. }
  17546. func (c *HisApiController) GetBasBaseInfo22222() string {
  17547. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17548. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17549. if readCard == nil {
  17550. fmt.Println("readcard is nil")
  17551. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17552. }
  17553. str := make([]byte, 1024)
  17554. str1 := make([]byte, 1024)
  17555. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17556. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17557. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17558. //if err != nil {
  17559. // fmt.Println("Error opening file:", err)
  17560. //}
  17561. //defer file.Close()
  17562. //
  17563. //var lastProgram Program
  17564. //scanner := bufio.NewScanner(file)
  17565. //inProgram := false
  17566. //
  17567. //for scanner.Scan() {
  17568. // line := scanner.Text()
  17569. // if strings.Contains(line, "<program>") {
  17570. // inProgram = true
  17571. // programXML := "<program>"
  17572. // for scanner.Scan() {
  17573. // line = scanner.Text()
  17574. // programXML += line
  17575. // if strings.Contains(line, "</program>") {
  17576. // programXML += "</program>"
  17577. // break
  17578. // }
  17579. // }
  17580. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17581. // // 解析成功,更新最后的 Program
  17582. // }
  17583. // inProgram = false
  17584. // }
  17585. //}
  17586. //
  17587. // fmt.Println("Error reading file:", inProgram)
  17588. //
  17589. //if err := scanner.Err(); err != nil {
  17590. // fmt.Println("Error reading file:", err)
  17591. //}
  17592. // 输出最后一次的 Program
  17593. //fmt.Printf("最后一次的 <program>:\n")
  17594. //fmt.Printf("<program>\n")
  17595. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17596. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17597. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17598. //fmt.Printf("</program>\n")
  17599. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17600. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17601. return ConvertToString(string(str1), "gbk", "utf-8")
  17602. }
  17603. func (c *HisApiController) GetahBasBaseInfo() string {
  17604. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17605. readCard := DllDef.MustFindProc("iReadCardBas")
  17606. if readCard == nil {
  17607. fmt.Println("readcard is nil")
  17608. readCard = DllDef.MustFindProc("iReadCardBas")
  17609. }
  17610. //str := make([]byte, 1024)
  17611. str1 := make([]byte, 1024)
  17612. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17613. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17614. //if err != nil {
  17615. // fmt.Println("Error opening file:", err)
  17616. //}
  17617. //defer file.Close()
  17618. //
  17619. //var lastProgram Program
  17620. //scanner := bufio.NewScanner(file)
  17621. //inProgram := false
  17622. //
  17623. //for scanner.Scan() {
  17624. // line := scanner.Text()
  17625. // if strings.Contains(line, "<program>") {
  17626. // inProgram = true
  17627. // programXML := "<program>"
  17628. // for scanner.Scan() {
  17629. // line = scanner.Text()
  17630. // programXML += line
  17631. // if strings.Contains(line, "</program>") {
  17632. // programXML += "</program>"
  17633. // break
  17634. // }
  17635. // }
  17636. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17637. // // 解析成功,更新最后的 Program
  17638. // }
  17639. // inProgram = false
  17640. // }
  17641. //}
  17642. //
  17643. // fmt.Println("Error reading file:", inProgram)
  17644. //
  17645. //if err := scanner.Err(); err != nil {
  17646. // fmt.Println("Error reading file:", err)
  17647. //}
  17648. // 输出最后一次的 Program
  17649. //fmt.Printf("最后一次的 <program>:\n")
  17650. //fmt.Printf("<program>\n")
  17651. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17652. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17653. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17654. //fmt.Printf("</program>\n")
  17655. fmt.Println(string(str1))
  17656. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17657. if ret2 != 0 {
  17658. return ""
  17659. }
  17660. return string(str1)
  17661. }
  17662. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17663. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17664. readCard := DllDef.MustFindProc("read_cardinfo")
  17665. if readCard == nil {
  17666. fmt.Println("readcard is nil")
  17667. readCard = DllDef.MustFindProc("read_cardinfo")
  17668. }
  17669. str := make([]byte, 1024) //卡号
  17670. str1 := make([]byte, 1024) //卡识别码
  17671. str2 := make([]byte, 1024) //身份证号
  17672. str3 := make([]byte, 1024) //姓名
  17673. str4 := make([]byte, 1024) //错误信息
  17674. 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])))
  17675. fmt.Println(string(str1))
  17676. fmt.Println(string(str))
  17677. fmt.Println(string(str2))
  17678. fmt.Println(string(str3))
  17679. fmt.Println(string(str4))
  17680. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17681. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17682. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17683. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17684. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17685. if ret2 != 0 {
  17686. return "", "", "", "", ""
  17687. }
  17688. return string(str), string(str1), string(str2), string(str3), string(str4)
  17689. }
  17690. type CustomFundPay struct {
  17691. FundPayType string `json:"fund_pay_type"`
  17692. FundPayamt float64 `json:"fund_payamt"`
  17693. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17694. }
  17695. //func (c *HisApiController) GetBatchSettleList() {
  17696. // start_time_str := c.GetString("start_time")
  17697. // //end_time_str := c.GetString("end_time")
  17698. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17699. //
  17700. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17701. //
  17702. // for _, item := range orders {
  17703. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17704. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17705. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17706. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17707. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17708. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17709. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17710. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17711. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17712. //
  17713. // if order.ID == 0 {
  17714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17715. // return
  17716. // }
  17717. //
  17718. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17719. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17720. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17721. // //fmt.Println(count)
  17722. // //var zero string
  17723. // //number := count + 1
  17724. // //if number >= 1000 {
  17725. // // zero = "0000" + strconv.FormatInt(number, 10)
  17726. // //} else if number >= 10000 {
  17727. // // zero = "000" + strconv.FormatInt(number, 10)
  17728. // //} else if number >= 100000 {
  17729. // // zero = "00" + strconv.FormatInt(number, 10)
  17730. // //} else if number >= 1000000 {
  17731. // // zero = "0" + strconv.FormatInt(number, 10)
  17732. // //} else {
  17733. // // zero = strconv.FormatInt(number, 10)
  17734. // //}
  17735. // //fmt.Println(zero)
  17736. //
  17737. // struct4101 := service.Struct4101{
  17738. // PsnNo: order.PsnNo,
  17739. // MdtrtId: order.MdtrtId,
  17740. // SetlId: order.SetlId,
  17741. // PsnName: order.PsnName,
  17742. // Gend: order.Gend,
  17743. // Brdy: his.Brdy,
  17744. // Age: his.Age,
  17745. // Naty: order.Naty,
  17746. // PatnCertType: "01",
  17747. // Certno: order.Certno,
  17748. // Prfs: "90",
  17749. // ConerName: roles[0].UserName,
  17750. // PatnRlts: "99",
  17751. // ConerAddr: miConfig.OrgName,
  17752. // ConerTel: admin.Mobile,
  17753. // HiType: order.Insutype,
  17754. // Insuplc: miConfig.InsuplcAdmdvs,
  17755. // MaindiagFlag: "1",
  17756. // BillCode: order.SetlId,
  17757. // BillNo: order.SetlId,
  17758. // BizSn: order.Number,
  17759. // PsnSelfPay: order.PsnPartAmt,
  17760. // PsnOwnPay: order.PsnPartAmt,
  17761. // AcctPay: order.AcctPay,
  17762. // PsnCashpay: order.PsnCashPay,
  17763. // HiPaymtd: "1",
  17764. // Hsorg: miConfig.InsuplcAdmdvs,
  17765. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17766. // MedinsFillPsn: curRoles.UserName,
  17767. // MedinsFillDept: miConfig.OrgName,
  17768. // IptMedType: "2",
  17769. // }
  17770. // struct4101.SetlBegnDate = order.SetlTime
  17771. // struct4101.SetlEndDate = order.SetlTime
  17772. // time_arr := strings.Split(order.SetlTime, " ")
  17773. // struct4101.AdmTime = time_arr[0]
  17774. // struct4101.AdmEndTime = time_arr[0]
  17775. //
  17776. // var rf []CustomFundPay
  17777. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17778. //
  17779. // var tempFunPays []service.CustomStruct
  17780. // for _, item := range rf {
  17781. // var tempFunPay service.CustomStruct
  17782. // tempFunPay.FundPayamt = item.FundPayamt
  17783. // tempFunPay.FundPayType = item.FundPayType
  17784. // tempFunPays = append(tempFunPays, tempFunPay)
  17785. // }
  17786. // struct4101.CustomStruct = tempFunPays
  17787. //
  17788. // var tempDiaginfos []service.DiaginfoStructTwo
  17789. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17790. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17791. //
  17792. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17793. // var config []*models.HisXtDiagnoseConfig
  17794. // for _, item := range diagnosis_ids {
  17795. // id, _ := strconv.ParseInt(item, 10, 64)
  17796. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17797. // config = append(config, &diagnosisConfig)
  17798. // }
  17799. //
  17800. // for index, item := range config {
  17801. // if index == 0 {
  17802. // var tempDiaginfo service.DiaginfoStructTwo
  17803. // tempDiaginfo.DiagCode = item.CountryCode
  17804. // tempDiaginfo.DiagName = item.CountryContentName
  17805. // tempDiaginfo.DiagType = "1"
  17806. // tempDiaginfo.MaindiagFlag = "1"
  17807. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17808. // } else {
  17809. // var tempDiaginfo service.DiaginfoStructTwo
  17810. // tempDiaginfo.DiagCode = item.CountryCode
  17811. // tempDiaginfo.DiagName = item.CountryContentName
  17812. // tempDiaginfo.DiagType = "1"
  17813. // tempDiaginfo.MaindiagFlag = "0"
  17814. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17815. // }
  17816. // }
  17817. // struct4101.Diseinfo = tempDiaginfos
  17818. //
  17819. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17820. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17821. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17822. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17823. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17824. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17825. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17826. //
  17827. // var iteminfo service.IteminfoStruct
  17828. //
  17829. // var bedCostTotal float64 = 0 //床位总费
  17830. // var bedCostSelfTotal float64 = 0 //床位自费
  17831. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17832. //
  17833. // var operationCostTotal float64 = 0 //手术费
  17834. // var operationCostSelfTotal float64 = 0 //手术费
  17835. // var operationCostPartSelfTotal float64 = 0 //手术费
  17836. //
  17837. // var otherCostTotal float64 = 0 //其他费用
  17838. // var otherCostSelfTotal float64 = 0 //其他费用
  17839. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17840. //
  17841. // var materialCostTotal float64 = 0 //材料费
  17842. // var materialCostSelfTotal float64 = 0 //材料费
  17843. // var materialCostPartSelfTotal float64 = 0 //材料费
  17844. //
  17845. // var westernMedicineCostTotal float64 = 0 //西药费
  17846. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17847. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17848. //
  17849. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17850. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17851. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17852. //
  17853. // var checkCostTotal float64 = 0 //检查费
  17854. // var checkCostSelfTotal float64 = 0 //检查费
  17855. // var checkCostPartSelfTotal float64 = 0 //检查费
  17856. //
  17857. // var laboratoryCostTotal float64 = 0 //化验费
  17858. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17859. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17860. //
  17861. // var treatCostTotal float64 = 0 //治疗费用
  17862. // var treatCostSelfTotal float64 = 0 //治疗费用
  17863. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17864. //
  17865. // decimal.DivisionPrecision = 2
  17866. //
  17867. // var bed_fulamt_ownpay_amt float64 = 0
  17868. // var operation_fulamt_ownpay_amt float64 = 0
  17869. // var other_fulamt_ownpay_amt float64 = 0
  17870. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17871. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17872. // var check_fulamt_ownpay_amt float64 = 0
  17873. // var material_fulamt_ownpay_amt float64 = 0
  17874. // var laboratory_fulamt_ownpay_amt float64 = 0
  17875. // var treat_fulamt_ownpay_amt float64 = 0
  17876. //
  17877. // var bed_claa_sunmfee float64 = 0
  17878. // var bed_clab_amt float64 = 0
  17879. // var bed_other_amt float64 = 0
  17880. //
  17881. // var operation_claa_sunmfee float64 = 0
  17882. // var operation_clab_amt float64 = 0
  17883. // var operation_other_amt float64 = 0
  17884. //
  17885. // var other_claa_sunmfee float64 = 0
  17886. // var other_clab_amt float64 = 0
  17887. // var other_other_amt float64 = 0
  17888. //
  17889. // var westernMedicine_claa_sunmfee float64 = 0
  17890. // var westernMedicine_clab_amt float64 = 0
  17891. // var westernMedicine_other_amt float64 = 0
  17892. //
  17893. // var chineseTraditional_claa_sunmfee float64 = 0
  17894. // var chineseTraditional_clab_amt float64 = 0
  17895. // var chineseTraditional_other_amt float64 = 0
  17896. //
  17897. // var check_claa_sunmfee float64 = 0
  17898. // var check_clab_amt float64 = 0
  17899. // var check_other_amt float64 = 0
  17900. //
  17901. // var material_claa_sunmfee float64 = 0
  17902. // var material_clab_amt float64 = 0
  17903. // var material_other_amt float64 = 0
  17904. //
  17905. // var laboratory_claa_sunmfee float64 = 0
  17906. // var laboratory_clab_amt float64 = 0
  17907. // var laboratory_other_amt float64 = 0
  17908. //
  17909. // var treat_claa_sunmfee float64 = 0
  17910. // var treat_clab_amt float64 = 0
  17911. // var treat_other_amt float64 = 0
  17912. //
  17913. // for _, item := range order.HisOrderInfo {
  17914. // if item.MedChrgitmType == "01" { //床位费
  17915. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17916. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17917. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17918. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17919. // if item.ChrgitmLv == "1" {
  17920. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17921. // }
  17922. // if item.ChrgitmLv == "2" {
  17923. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17924. //
  17925. // }
  17926. // if item.ChrgitmLv == "3" {
  17927. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17928. // }
  17929. //
  17930. // }
  17931. //
  17932. // if item.MedChrgitmType == "03" { //检查费
  17933. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17934. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17935. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17936. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17937. // if item.ChrgitmLv == "1" {
  17938. //
  17939. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17940. //
  17941. // }
  17942. // if item.ChrgitmLv == "2" {
  17943. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17944. //
  17945. // }
  17946. // if item.ChrgitmLv == "3" {
  17947. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17948. // }
  17949. // }
  17950. //
  17951. // if item.MedChrgitmType == "04" { //化验费
  17952. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17953. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17954. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17955. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17956. // if item.ChrgitmLv == "1" {
  17957. //
  17958. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17959. //
  17960. // }
  17961. // if item.ChrgitmLv == "2" {
  17962. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17963. //
  17964. // }
  17965. // if item.ChrgitmLv == "3" {
  17966. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17967. // }
  17968. // }
  17969. //
  17970. // if item.MedChrgitmType == "05" { //治疗费
  17971. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17972. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17973. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17974. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17975. // if item.ChrgitmLv == "1" {
  17976. //
  17977. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17978. //
  17979. // }
  17980. // if item.ChrgitmLv == "2" {
  17981. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17982. //
  17983. // }
  17984. // if item.ChrgitmLv == "3" {
  17985. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17986. // }
  17987. // }
  17988. //
  17989. // if item.MedChrgitmType == "06" { //手术费
  17990. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17991. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17992. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17993. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17994. //
  17995. // if item.ChrgitmLv == "1" {
  17996. //
  17997. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17998. //
  17999. // }
  18000. // if item.ChrgitmLv == "2" {
  18001. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18002. //
  18003. // }
  18004. // if item.ChrgitmLv == "3" {
  18005. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18006. // }
  18007. // }
  18008. //
  18009. // if item.MedChrgitmType == "08" { //材料费
  18010. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18011. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18012. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18013. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18014. // if item.ChrgitmLv == "1" {
  18015. //
  18016. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18017. //
  18018. // }
  18019. // if item.ChrgitmLv == "2" {
  18020. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18021. //
  18022. // }
  18023. // if item.ChrgitmLv == "3" {
  18024. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18025. // }
  18026. // }
  18027. //
  18028. // if item.MedChrgitmType == "09" { //西药费
  18029. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18030. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18031. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18032. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18033. // if item.ChrgitmLv == "1" {
  18034. //
  18035. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18036. //
  18037. // }
  18038. // if item.ChrgitmLv == "2" {
  18039. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18040. //
  18041. // }
  18042. // if item.ChrgitmLv == "3" {
  18043. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18044. // }
  18045. // }
  18046. //
  18047. // if item.MedChrgitmType == "11" { //中成费
  18048. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18049. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18050. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18051. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18052. // if item.ChrgitmLv == "1" {
  18053. //
  18054. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18055. //
  18056. // }
  18057. // if item.ChrgitmLv == "2" {
  18058. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18059. //
  18060. // }
  18061. // if item.ChrgitmLv == "3" {
  18062. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18063. // }
  18064. // }
  18065. //
  18066. // if item.MedChrgitmType == "14" { //其他费
  18067. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18068. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18069. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18070. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18071. // if item.ChrgitmLv == "1" {
  18072. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18073. //
  18074. // }
  18075. // if item.ChrgitmLv == "2" {
  18076. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18077. //
  18078. // }
  18079. // if item.ChrgitmLv == "3" {
  18080. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18081. // }
  18082. // }
  18083. //
  18084. // }
  18085. //
  18086. // var iteminfoStructs []service.IteminfoStruct
  18087. //
  18088. // if bedCostTotal != 0 {
  18089. // iteminfo.MedChrgitm = "01"
  18090. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18091. // iteminfo.Amt = bedCostTotal
  18092. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18093. // iteminfo.ClabAmt = bed_clab_amt
  18094. // iteminfo.OthAmt = bed_other_amt
  18095. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18096. // }
  18097. //
  18098. // if checkCostTotal != 0 {
  18099. // iteminfo.MedChrgitm = "03"
  18100. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18101. // iteminfo.Amt = checkCostTotal
  18102. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18103. // iteminfo.ClabAmt = check_clab_amt
  18104. // iteminfo.OthAmt = check_other_amt
  18105. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18106. //
  18107. // }
  18108. //
  18109. // if laboratoryCostTotal != 0 {
  18110. // iteminfo.MedChrgitm = "04"
  18111. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18112. // iteminfo.Amt = laboratoryCostTotal
  18113. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18114. // iteminfo.ClabAmt = laboratory_clab_amt
  18115. // iteminfo.OthAmt = laboratory_other_amt
  18116. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18117. //
  18118. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18119. //
  18120. // }
  18121. //
  18122. // if treatCostTotal != 0 {
  18123. // iteminfo.MedChrgitm = "05"
  18124. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18125. // iteminfo.Amt = treatCostTotal
  18126. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18127. // iteminfo.ClabAmt = treat_clab_amt
  18128. // iteminfo.OthAmt = treat_other_amt
  18129. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18130. // //(struct4101.IteminfoStruct, iteminfo)
  18131. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18132. // }
  18133. //
  18134. // if operationCostTotal != 0 {
  18135. // iteminfo.MedChrgitm = "06"
  18136. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18137. // iteminfo.Amt = operationCostTotal
  18138. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18139. // iteminfo.ClabAmt = operation_clab_amt
  18140. // iteminfo.OthAmt = operation_other_amt
  18141. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18142. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18143. // }
  18144. //
  18145. // if materialCostTotal != 0 {
  18146. // iteminfo.MedChrgitm = "08"
  18147. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18148. // iteminfo.Amt = materialCostTotal
  18149. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18150. // iteminfo.ClabAmt = material_clab_amt
  18151. // iteminfo.OthAmt = material_other_amt
  18152. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18153. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18154. // }
  18155. //
  18156. // if westernMedicineCostTotal != 0 {
  18157. // iteminfo.MedChrgitm = "09"
  18158. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18159. // iteminfo.Amt = westernMedicineCostTotal
  18160. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18161. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18162. // iteminfo.OthAmt = westernMedicine_other_amt
  18163. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18164. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18165. //
  18166. // }
  18167. // if chineseTraditionalMedicineCostTotal != 0 {
  18168. // iteminfo.MedChrgitm = "11"
  18169. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18170. // iteminfo.Amt = westernMedicineCostTotal
  18171. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18172. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18173. // iteminfo.OthAmt = westernMedicine_other_amt
  18174. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18175. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18176. //
  18177. // }
  18178. // if otherCostTotal != 0 {
  18179. // iteminfo.MedChrgitm = "14"
  18180. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18181. // iteminfo.Amt = otherCostTotal
  18182. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18183. // iteminfo.ClabAmt = other_clab_amt
  18184. // iteminfo.OthAmt = other_other_amt
  18185. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18186. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18187. //
  18188. // }
  18189. // struct4101.IteminfoStruct = iteminfoStructs
  18190. // struct4101.Ntly = "中国"
  18191. // struct4101.AdmCaty = "A03.06"
  18192. //
  18193. // struct4101.DoctorName = doctor.UserName
  18194. // struct4101.DoctorCode = doctor.DoctorNumber
  18195. //
  18196. // var res ResultSeventeen
  18197. //
  18198. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18199. // struct4101.BillCode = order.Number
  18200. // struct4101.BillNo = order.SetlId
  18201. // var resOther ResultSeventeenOther
  18202. // var pp models.PublicParams
  18203. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18204. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18205. // pp.FixmedinsName = miConfig.OrgName
  18206. // pp.FixmedinsCode = miConfig.Code
  18207. // pp.RequestUrl = miConfig.Url
  18208. // pp.Cainfo = miConfig.Cainfo
  18209. // pp.SecretKey = miConfig.SecretKey
  18210. // pp.AccessKey = miConfig.AccessKey
  18211. // pp.OpterName = curRoles.UserName
  18212. //
  18213. // client := &http.Client{}
  18214. // var req *http.Request
  18215. // data := make(map[string]interface{})
  18216. // data["struct4101"] = struct4101
  18217. // data["pp"] = pp
  18218. // bytesData, _ := json.Marshal(data)
  18219. // if miConfig.MdtrtareaAdmvs == "320921" {
  18220. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18221. // } else {
  18222. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18223. // }
  18224. // resp, _ := client.Do(req)
  18225. // defer resp.Body.Close()
  18226. // body, ioErr := ioutil.ReadAll(resp.Body)
  18227. // if ioErr != nil {
  18228. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18230. // return
  18231. // }
  18232. // var respJSON map[string]interface{}
  18233. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18234. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18236. // return
  18237. // }
  18238. //
  18239. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18240. // userJSONBytes, _ := json.Marshal(respJSON)
  18241. // fmt.Println("log")
  18242. // fmt.Println(string(userJSONBytes))
  18243. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18244. // utils.ErrorLog("解析失败:%v", err)
  18245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18246. // return
  18247. // }
  18248. // res.InfRefmsgid = resOther.InfRefmsgid
  18249. // res.Output = resOther.Output
  18250. // res.ErrMsg = resOther.ErrMsg
  18251. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18252. // res.Infcode = infocode
  18253. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18254. //
  18255. // var pp models.PublicParams
  18256. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18257. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18258. // pp.FixmedinsName = miConfig.OrgName
  18259. // pp.FixmedinsCode = miConfig.Code
  18260. // pp.RequestUrl = miConfig.Url
  18261. // pp.Cainfo = miConfig.Cainfo
  18262. // pp.SecretKey = miConfig.SecretKey
  18263. // pp.AccessKey = miConfig.AccessKey
  18264. // pp.OpterName = curRoles.UserName
  18265. // result, _ := service.Jxyb4101(struct4101, pp)
  18266. // var dat map[string]interface{}
  18267. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18268. // fmt.Println(dat)
  18269. // } else {
  18270. // fmt.Println(err)
  18271. // }
  18272. // userJSONBytes, _ := json.Marshal(dat)
  18273. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18274. // utils.ErrorLog("解析失败:%v", err)
  18275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18276. // return
  18277. // }
  18278. //
  18279. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18280. // var pp models.PublicParams
  18281. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18282. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18283. // pp.FixmedinsName = miConfig.OrgName
  18284. // pp.FixmedinsCode = miConfig.Code
  18285. // pp.RequestUrl = miConfig.Url
  18286. // pp.Cainfo = miConfig.Cainfo
  18287. // pp.SecretKey = miConfig.SecretKey
  18288. // pp.AccessKey = miConfig.AccessKey
  18289. // pp.OpterName = curRoles.UserName
  18290. // result, _ := service.Hnyb4101(struct4101, pp)
  18291. // var dat map[string]interface{}
  18292. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18293. // fmt.Println(dat)
  18294. // } else {
  18295. // fmt.Println(err)
  18296. // }
  18297. // userJSONBytes, _ := json.Marshal(dat)
  18298. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18299. // utils.ErrorLog("解析失败:%v", err)
  18300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18301. // return
  18302. // }
  18303. //
  18304. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18305. // var resOther ResultSeventeenOther
  18306. //
  18307. // var pp models.PublicParams
  18308. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18309. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18310. // pp.FixmedinsName = miConfig.OrgName
  18311. // pp.FixmedinsCode = miConfig.Code
  18312. // pp.RequestUrl = miConfig.Url
  18313. // pp.Cainfo = miConfig.Cainfo
  18314. // pp.SecretKey = miConfig.SecretKey
  18315. // pp.AccessKey = miConfig.AccessKey
  18316. // pp.OpterName = curRoles.UserName
  18317. // client := &http.Client{}
  18318. // var req *http.Request
  18319. // data := make(map[string]interface{})
  18320. // data["struct4101"] = struct4101
  18321. // data["pp"] = pp
  18322. // bytesData, _ := json.Marshal(data)
  18323. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18324. // resp, _ := client.Do(req)
  18325. // defer resp.Body.Close()
  18326. // body, ioErr := ioutil.ReadAll(resp.Body)
  18327. // if ioErr != nil {
  18328. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18330. // return
  18331. // }
  18332. // var respJSON map[string]interface{}
  18333. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18334. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18336. // return
  18337. // }
  18338. //
  18339. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18340. // userJSONBytes, _ := json.Marshal(respJSON)
  18341. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18342. // utils.ErrorLog("解析失败:%v", err)
  18343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18344. // return
  18345. // }
  18346. // res.InfRefmsgid = resOther.InfRefmsgid
  18347. // res.Output = resOther.Output
  18348. // res.ErrMsg = resOther.ErrMsg
  18349. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18350. // res.Infcode = infocode
  18351. //
  18352. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18353. // var pp models.PublicParams
  18354. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18355. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18356. // pp.FixmedinsName = miConfig.OrgName
  18357. // pp.FixmedinsCode = miConfig.Code
  18358. // pp.RequestUrl = miConfig.Url
  18359. // pp.Cainfo = miConfig.Cainfo
  18360. // pp.SecretKey = miConfig.SecretKey
  18361. // pp.AccessKey = miConfig.AccessKey
  18362. // pp.OpterName = curRoles.UserName
  18363. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18364. // fmt.Println(requestLog)
  18365. // fmt.Println(errMsgLog)
  18366. //
  18367. // saveLog(result, requestLog, "4101a", "上传清单")
  18368. //
  18369. // var dat map[string]interface{}
  18370. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18371. // fmt.Println(dat)
  18372. // } else {
  18373. // fmt.Println(err)
  18374. // }
  18375. // userJSONBytes, _ := json.Marshal(dat)
  18376. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18377. // utils.ErrorLog("解析失败:%v", err)
  18378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18379. // return
  18380. // }
  18381. //
  18382. // } else {
  18383. //
  18384. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18385. // var dat map[string]interface{}
  18386. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18387. // fmt.Println(dat)
  18388. // } else {
  18389. // fmt.Println(err)
  18390. // }
  18391. // userJSONBytes, _ := json.Marshal(dat)
  18392. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18393. // utils.ErrorLog("解析失败:%v", err)
  18394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18395. // return
  18396. // }
  18397. // }
  18398. //
  18399. // if res.Infcode != 0 {
  18400. // adminUser := c.GetAdminUserInfo()
  18401. // errlog := &models.HisOrderError{
  18402. // UserOrgId: adminUser.CurrentOrgId,
  18403. // Ctime: time.Now().Unix(),
  18404. // Mtime: time.Now().Unix(),
  18405. // ErrMsg: res.ErrMsg,
  18406. // Status: 1,
  18407. // PatientId: order.ID,
  18408. // Stage: 10265,
  18409. // }
  18410. // service.CreateErrMsgLog(errlog)
  18411. // continue
  18412. // } else {
  18413. // //order.FaPiaoNumber = zero
  18414. // //order.FaPiaoCode = last_order.FaPiaoCode
  18415. // //service.UpdateOrder(order)
  18416. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18417. // Number: res.Output.SetlListId,
  18418. // Status: 1,
  18419. // Ctime: time.Now().Unix(),
  18420. // Mtime: time.Now().Unix(),
  18421. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18422. // IsUpload: 1,
  18423. // OrderId: order.ID,
  18424. // }
  18425. // service.CreateUploadRecord(hisFundSettleListResult)
  18426. // c.ServeSuccessJSON(map[string]interface{}{
  18427. // "msg": "上传成功",
  18428. // "result": hisFundSettleListResult,
  18429. // })
  18430. // continue
  18431. // }
  18432. // }
  18433. //}
  18434. func (c *HisApiController) GetbatchSettleList() {
  18435. //order_id, _ := c.GetInt64("order_id")
  18436. admin_user_id, _ := c.GetInt64("admin_user_id")
  18437. orders, _ := service.GetAllHisOrderTwo10485()
  18438. for _, item := range orders {
  18439. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18440. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18441. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18442. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18443. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18444. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18445. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18446. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18447. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18448. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18449. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18450. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18451. //fmt.Println(count)
  18452. //var zero string
  18453. //number := count + 1
  18454. //if number >= 1000 {
  18455. // zero = "0000" + strconv.FormatInt(number, 10)
  18456. //} else if number >= 10000 {
  18457. // zero = "000" + strconv.FormatInt(number, 10)
  18458. //} else if number >= 100000 {
  18459. // zero = "00" + strconv.FormatInt(number, 10)
  18460. //} else if number >= 1000000 {
  18461. // zero = "0" + strconv.FormatInt(number, 10)
  18462. //} else {
  18463. // zero = strconv.FormatInt(number, 10)
  18464. //}
  18465. //fmt.Println(zero)
  18466. struct4101 := service.Struct4101{
  18467. PsnNo: order.PsnNo,
  18468. MdtrtId: order.MdtrtId,
  18469. SetlId: order.SetlId,
  18470. PsnName: order.PsnName,
  18471. Gend: order.Gend,
  18472. Brdy: his.Brdy,
  18473. Age: his.Age,
  18474. Naty: order.Naty,
  18475. PatnCertType: "01",
  18476. Certno: order.Certno,
  18477. Prfs: "90",
  18478. ConerName: roles[0].UserName,
  18479. PatnRlts: "99",
  18480. ConerAddr: miConfig.OrgName,
  18481. ConerTel: admin.Mobile,
  18482. HiType: order.Insutype,
  18483. Insuplc: miConfig.InsuplcAdmdvs,
  18484. MaindiagFlag: "1",
  18485. BillCode: order.SetlId,
  18486. BillNo: order.SetlId,
  18487. BizSn: order.Number,
  18488. PsnSelfPay: order.PsnPartAmt,
  18489. PsnOwnPay: order.PsnPartAmt,
  18490. AcctPay: order.AcctPay,
  18491. PsnCashpay: order.PsnCashPay,
  18492. HiPaymtd: "1",
  18493. Hsorg: miConfig.InsuplcAdmdvs,
  18494. HsorgOpter: miConfig.InsuplcAdmdvs,
  18495. MedinsFillPsn: curRoles.UserName,
  18496. MedinsFillDept: miConfig.OrgName,
  18497. IptMedType: "2",
  18498. }
  18499. struct4101.SetlBegnDate = order.SetlTime
  18500. struct4101.SetlEndDate = order.SetlTime
  18501. time_arr := strings.Split(order.SetlTime, " ")
  18502. struct4101.AdmTime = time_arr[0]
  18503. struct4101.AdmEndTime = time_arr[0]
  18504. //var rf []CustomFundPay
  18505. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18506. //
  18507. //var tempFunPays []service.CustomStruct
  18508. //for _, item := range rf {
  18509. // var tempFunPay service.CustomStruct
  18510. // tempFunPay.FundPayamt = item.FundPayamt
  18511. // tempFunPay.FundPayType = item.FundPayType
  18512. // tempFunPays = append(tempFunPays, tempFunPay)
  18513. //}
  18514. //struct4101.CustomStruct = tempFunPays
  18515. var tempDiaginfos []service.DiaginfoStructTwo
  18516. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18517. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18518. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18519. var config []*models.HisXtDiagnoseConfig
  18520. for _, item := range diagnosis_ids {
  18521. id, _ := strconv.ParseInt(item, 10, 64)
  18522. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18523. config = append(config, &diagnosisConfig)
  18524. }
  18525. for index, item := range config {
  18526. if index == 0 {
  18527. var tempDiaginfo service.DiaginfoStructTwo
  18528. tempDiaginfo.DiagCode = item.CountryCode
  18529. tempDiaginfo.DiagName = item.CountryContentName
  18530. tempDiaginfo.DiagType = "1"
  18531. tempDiaginfo.MaindiagFlag = "1"
  18532. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18533. } else {
  18534. var tempDiaginfo service.DiaginfoStructTwo
  18535. tempDiaginfo.DiagCode = item.CountryCode
  18536. tempDiaginfo.DiagName = item.CountryContentName
  18537. tempDiaginfo.DiagType = "1"
  18538. tempDiaginfo.MaindiagFlag = "0"
  18539. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18540. }
  18541. }
  18542. struct4101.Diseinfo = tempDiaginfos
  18543. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18544. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18545. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18546. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18547. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18548. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18549. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18550. var iteminfo service.IteminfoStruct
  18551. var bedCostTotal float64 = 0 //床位总费
  18552. var bedCostSelfTotal float64 = 0 //床位自费
  18553. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18554. var operationCostTotal float64 = 0 //手术费
  18555. var operationCostSelfTotal float64 = 0 //手术费
  18556. var operationCostPartSelfTotal float64 = 0 //手术费
  18557. var otherCostTotal float64 = 0 //其他费用
  18558. var otherCostSelfTotal float64 = 0 //其他费用
  18559. var otherCostPartSelfTotal float64 = 0 //其他费用
  18560. var materialCostTotal float64 = 0 //材料费
  18561. var materialCostSelfTotal float64 = 0 //材料费
  18562. var materialCostPartSelfTotal float64 = 0 //材料费
  18563. var westernMedicineCostTotal float64 = 0 //西药费
  18564. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18565. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18566. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18567. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18568. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18569. var checkCostTotal float64 = 0 //检查费
  18570. var checkCostSelfTotal float64 = 0 //检查费
  18571. var checkCostPartSelfTotal float64 = 0 //检查费
  18572. var laboratoryCostTotal float64 = 0 //化验费
  18573. var laboratoryCostSelfTotal float64 = 0 //化验费
  18574. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18575. var treatCostTotal float64 = 0 //治疗费用
  18576. var treatCostSelfTotal float64 = 0 //治疗费用
  18577. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18578. decimal.DivisionPrecision = 2
  18579. var bed_fulamt_ownpay_amt float64 = 0
  18580. var operation_fulamt_ownpay_amt float64 = 0
  18581. var other_fulamt_ownpay_amt float64 = 0
  18582. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18583. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18584. var check_fulamt_ownpay_amt float64 = 0
  18585. var material_fulamt_ownpay_amt float64 = 0
  18586. var laboratory_fulamt_ownpay_amt float64 = 0
  18587. var treat_fulamt_ownpay_amt float64 = 0
  18588. var bed_claa_sunmfee float64 = 0
  18589. var bed_clab_amt float64 = 0
  18590. var bed_other_amt float64 = 0
  18591. var operation_claa_sunmfee float64 = 0
  18592. var operation_clab_amt float64 = 0
  18593. var operation_other_amt float64 = 0
  18594. var other_claa_sunmfee float64 = 0
  18595. var other_clab_amt float64 = 0
  18596. var other_other_amt float64 = 0
  18597. var westernMedicine_claa_sunmfee float64 = 0
  18598. var westernMedicine_clab_amt float64 = 0
  18599. var westernMedicine_other_amt float64 = 0
  18600. var chineseTraditional_claa_sunmfee float64 = 0
  18601. var chineseTraditional_clab_amt float64 = 0
  18602. var chineseTraditional_other_amt float64 = 0
  18603. var check_claa_sunmfee float64 = 0
  18604. var check_clab_amt float64 = 0
  18605. var check_other_amt float64 = 0
  18606. var material_claa_sunmfee float64 = 0
  18607. var material_clab_amt float64 = 0
  18608. var material_other_amt float64 = 0
  18609. var laboratory_claa_sunmfee float64 = 0
  18610. var laboratory_clab_amt float64 = 0
  18611. var laboratory_other_amt float64 = 0
  18612. var treat_claa_sunmfee float64 = 0
  18613. var treat_clab_amt float64 = 0
  18614. var treat_other_amt float64 = 0
  18615. for _, item := range order.HisOrderInfo {
  18616. if item.MedChrgitmType == "01" { //床位费
  18617. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18618. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18619. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18620. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18621. if item.ChrgitmLv == "1" {
  18622. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18623. }
  18624. if item.ChrgitmLv == "2" {
  18625. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18626. }
  18627. if item.ChrgitmLv == "3" {
  18628. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18629. }
  18630. }
  18631. if item.MedChrgitmType == "03" { //检查费
  18632. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18633. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18634. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18635. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18636. if item.ChrgitmLv == "1" {
  18637. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18638. }
  18639. if item.ChrgitmLv == "2" {
  18640. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18641. }
  18642. if item.ChrgitmLv == "3" {
  18643. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18644. }
  18645. }
  18646. if item.MedChrgitmType == "04" { //化验费
  18647. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18648. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18649. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18650. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18651. if item.ChrgitmLv == "1" {
  18652. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18653. }
  18654. if item.ChrgitmLv == "2" {
  18655. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18656. }
  18657. if item.ChrgitmLv == "3" {
  18658. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18659. }
  18660. }
  18661. if item.MedChrgitmType == "05" { //治疗费
  18662. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18663. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18664. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18665. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18666. if item.ChrgitmLv == "1" {
  18667. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18668. }
  18669. if item.ChrgitmLv == "2" {
  18670. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18671. }
  18672. if item.ChrgitmLv == "3" {
  18673. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18674. }
  18675. }
  18676. if item.MedChrgitmType == "06" { //手术费
  18677. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18678. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18679. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18680. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18681. if item.ChrgitmLv == "1" {
  18682. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18683. }
  18684. if item.ChrgitmLv == "2" {
  18685. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18686. }
  18687. if item.ChrgitmLv == "3" {
  18688. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18689. }
  18690. }
  18691. if item.MedChrgitmType == "08" { //材料费
  18692. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18693. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18694. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18695. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18696. if item.ChrgitmLv == "1" {
  18697. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18698. }
  18699. if item.ChrgitmLv == "2" {
  18700. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18701. }
  18702. if item.ChrgitmLv == "3" {
  18703. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18704. }
  18705. }
  18706. if item.MedChrgitmType == "09" { //西药费
  18707. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18708. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18709. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18710. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18711. if item.ChrgitmLv == "1" {
  18712. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18713. }
  18714. if item.ChrgitmLv == "2" {
  18715. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18716. }
  18717. if item.ChrgitmLv == "3" {
  18718. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18719. }
  18720. }
  18721. if item.MedChrgitmType == "11" { //中成费
  18722. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18723. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18724. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18725. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18726. if item.ChrgitmLv == "1" {
  18727. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18728. }
  18729. if item.ChrgitmLv == "2" {
  18730. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18731. }
  18732. if item.ChrgitmLv == "3" {
  18733. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18734. }
  18735. }
  18736. if item.MedChrgitmType == "14" { //其他费
  18737. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18738. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18739. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18740. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18741. if item.ChrgitmLv == "1" {
  18742. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18743. }
  18744. if item.ChrgitmLv == "2" {
  18745. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18746. }
  18747. if item.ChrgitmLv == "3" {
  18748. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18749. }
  18750. }
  18751. }
  18752. var iteminfoStructs []service.IteminfoStruct
  18753. if bedCostTotal != 0 {
  18754. iteminfo.MedChrgitm = "01"
  18755. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18756. iteminfo.Amt = bedCostTotal
  18757. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18758. iteminfo.ClabAmt = bed_clab_amt
  18759. iteminfo.OthAmt = bed_other_amt
  18760. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18761. }
  18762. if checkCostTotal != 0 {
  18763. iteminfo.MedChrgitm = "03"
  18764. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18765. iteminfo.Amt = checkCostTotal
  18766. iteminfo.ClaaSumfee = check_claa_sunmfee
  18767. iteminfo.ClabAmt = check_clab_amt
  18768. iteminfo.OthAmt = check_other_amt
  18769. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18770. }
  18771. if laboratoryCostTotal != 0 {
  18772. iteminfo.MedChrgitm = "04"
  18773. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18774. iteminfo.Amt = laboratoryCostTotal
  18775. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18776. iteminfo.ClabAmt = laboratory_clab_amt
  18777. iteminfo.OthAmt = laboratory_other_amt
  18778. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18779. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18780. }
  18781. if treatCostTotal != 0 {
  18782. iteminfo.MedChrgitm = "05"
  18783. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18784. iteminfo.Amt = treatCostTotal
  18785. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18786. iteminfo.ClabAmt = treat_clab_amt
  18787. iteminfo.OthAmt = treat_other_amt
  18788. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18789. //(struct4101.IteminfoStruct, iteminfo)
  18790. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18791. }
  18792. if operationCostTotal != 0 {
  18793. iteminfo.MedChrgitm = "06"
  18794. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18795. iteminfo.Amt = operationCostTotal
  18796. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18797. iteminfo.ClabAmt = operation_clab_amt
  18798. iteminfo.OthAmt = operation_other_amt
  18799. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18800. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18801. }
  18802. if materialCostTotal != 0 {
  18803. iteminfo.MedChrgitm = "08"
  18804. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18805. iteminfo.Amt = materialCostTotal
  18806. iteminfo.ClaaSumfee = material_claa_sunmfee
  18807. iteminfo.ClabAmt = material_clab_amt
  18808. iteminfo.OthAmt = material_other_amt
  18809. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18810. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18811. }
  18812. if westernMedicineCostTotal != 0 {
  18813. iteminfo.MedChrgitm = "09"
  18814. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18815. iteminfo.Amt = westernMedicineCostTotal
  18816. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18817. iteminfo.ClabAmt = westernMedicine_clab_amt
  18818. iteminfo.OthAmt = westernMedicine_other_amt
  18819. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18820. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18821. }
  18822. if chineseTraditionalMedicineCostTotal != 0 {
  18823. iteminfo.MedChrgitm = "11"
  18824. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18825. iteminfo.Amt = westernMedicineCostTotal
  18826. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18827. iteminfo.ClabAmt = westernMedicine_clab_amt
  18828. iteminfo.OthAmt = westernMedicine_other_amt
  18829. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18830. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18831. }
  18832. if otherCostTotal != 0 {
  18833. iteminfo.MedChrgitm = "14"
  18834. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18835. iteminfo.Amt = otherCostTotal
  18836. iteminfo.ClaaSumfee = other_claa_sunmfee
  18837. iteminfo.ClabAmt = other_clab_amt
  18838. iteminfo.OthAmt = other_other_amt
  18839. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18840. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18841. }
  18842. struct4101.IteminfoStruct = iteminfoStructs
  18843. struct4101.Ntly = "中国"
  18844. struct4101.AdmCaty = "A03.06"
  18845. struct4101.DoctorName = doctor.UserName
  18846. struct4101.DoctorCode = doctor.DoctorNumber
  18847. var res ResultSeventeen
  18848. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18849. struct4101.BillCode = order.Number
  18850. struct4101.BillNo = order.SetlId
  18851. var resOther ResultSeventeenOther
  18852. var pp models.PublicParams
  18853. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18854. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18855. pp.FixmedinsName = miConfig.OrgName
  18856. pp.FixmedinsCode = miConfig.Code
  18857. pp.RequestUrl = miConfig.Url
  18858. pp.Cainfo = miConfig.Cainfo
  18859. pp.SecretKey = miConfig.SecretKey
  18860. pp.AccessKey = miConfig.AccessKey
  18861. pp.OpterName = curRoles.UserName
  18862. client := &http.Client{}
  18863. var req *http.Request
  18864. data := make(map[string]interface{})
  18865. data["struct4101"] = struct4101
  18866. data["pp"] = pp
  18867. bytesData, _ := json.Marshal(data)
  18868. if miConfig.MdtrtareaAdmvs == "320921" {
  18869. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18870. } else {
  18871. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18872. }
  18873. resp, _ := client.Do(req)
  18874. defer resp.Body.Close()
  18875. body, ioErr := ioutil.ReadAll(resp.Body)
  18876. if ioErr != nil {
  18877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18879. return
  18880. }
  18881. var respJSON map[string]interface{}
  18882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18885. return
  18886. }
  18887. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18888. userJSONBytes, _ := json.Marshal(respJSON)
  18889. fmt.Println("log")
  18890. fmt.Println(string(userJSONBytes))
  18891. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18892. utils.ErrorLog("解析失败:%v", err)
  18893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18894. return
  18895. }
  18896. res.InfRefmsgid = resOther.InfRefmsgid
  18897. res.Output = resOther.Output
  18898. res.ErrMsg = resOther.ErrMsg
  18899. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18900. res.Infcode = infocode
  18901. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18902. var pp models.PublicParams
  18903. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18904. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18905. pp.FixmedinsName = miConfig.OrgName
  18906. pp.FixmedinsCode = miConfig.Code
  18907. pp.RequestUrl = miConfig.Url
  18908. pp.Cainfo = miConfig.Cainfo
  18909. pp.SecretKey = miConfig.SecretKey
  18910. pp.AccessKey = miConfig.AccessKey
  18911. pp.OpterName = curRoles.UserName
  18912. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18913. result, _ := service.Jxyb4101(struct4101, pp)
  18914. var dat map[string]interface{}
  18915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18916. fmt.Println(dat)
  18917. } else {
  18918. fmt.Println(err)
  18919. }
  18920. userJSONBytes, _ := json.Marshal(dat)
  18921. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18922. utils.ErrorLog("解析失败:%v", err)
  18923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18924. return
  18925. }
  18926. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18927. var pp models.PublicParams
  18928. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18929. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18930. pp.FixmedinsName = miConfig.OrgName
  18931. pp.FixmedinsCode = miConfig.Code
  18932. pp.RequestUrl = miConfig.Url
  18933. pp.Cainfo = miConfig.Cainfo
  18934. pp.SecretKey = miConfig.SecretKey
  18935. pp.AccessKey = miConfig.AccessKey
  18936. pp.OpterName = curRoles.UserName
  18937. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18938. result, _ := service.Jxyb4101(struct4101, pp)
  18939. var dat map[string]interface{}
  18940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18941. fmt.Println(dat)
  18942. } else {
  18943. fmt.Println(err)
  18944. }
  18945. userJSONBytes, _ := json.Marshal(dat)
  18946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18947. utils.ErrorLog("解析失败:%v", err)
  18948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18949. return
  18950. }
  18951. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18952. var pp models.PublicParams
  18953. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18954. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18955. pp.FixmedinsName = miConfig.OrgName
  18956. pp.FixmedinsCode = miConfig.Code
  18957. pp.RequestUrl = miConfig.Url
  18958. pp.Cainfo = miConfig.Cainfo
  18959. pp.SecretKey = miConfig.SecretKey
  18960. pp.AccessKey = miConfig.AccessKey
  18961. pp.OpterName = curRoles.UserName
  18962. result, _ := service.Hnyb4101(struct4101, pp)
  18963. var dat map[string]interface{}
  18964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18965. fmt.Println(dat)
  18966. } else {
  18967. fmt.Println(err)
  18968. }
  18969. userJSONBytes, _ := json.Marshal(dat)
  18970. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18971. utils.ErrorLog("解析失败:%v", err)
  18972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18973. return
  18974. }
  18975. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18976. var resOther ResultSeventeenOther
  18977. var pp models.PublicParams
  18978. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18979. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18980. pp.FixmedinsName = miConfig.OrgName
  18981. pp.FixmedinsCode = miConfig.Code
  18982. pp.RequestUrl = miConfig.Url
  18983. pp.Cainfo = miConfig.Cainfo
  18984. pp.SecretKey = miConfig.SecretKey
  18985. pp.AccessKey = miConfig.AccessKey
  18986. pp.OpterName = curRoles.UserName
  18987. client := &http.Client{}
  18988. var req *http.Request
  18989. data := make(map[string]interface{})
  18990. data["struct4101"] = struct4101
  18991. data["pp"] = pp
  18992. bytesData, _ := json.Marshal(data)
  18993. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18994. resp, _ := client.Do(req)
  18995. defer resp.Body.Close()
  18996. body, ioErr := ioutil.ReadAll(resp.Body)
  18997. if ioErr != nil {
  18998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19000. return
  19001. }
  19002. var respJSON map[string]interface{}
  19003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19006. return
  19007. }
  19008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19009. userJSONBytes, _ := json.Marshal(respJSON)
  19010. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19011. utils.ErrorLog("解析失败:%v", err)
  19012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19013. return
  19014. }
  19015. res.InfRefmsgid = resOther.InfRefmsgid
  19016. res.Output = resOther.Output
  19017. res.ErrMsg = resOther.ErrMsg
  19018. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19019. res.Infcode = infocode
  19020. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19021. var pp models.PublicParams
  19022. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19023. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19024. pp.FixmedinsName = miConfig.OrgName
  19025. pp.FixmedinsCode = miConfig.Code
  19026. pp.RequestUrl = miConfig.Url
  19027. pp.Cainfo = miConfig.Cainfo
  19028. pp.SecretKey = miConfig.SecretKey
  19029. pp.AccessKey = miConfig.AccessKey
  19030. pp.OpterName = curRoles.UserName
  19031. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19032. fmt.Println(requestLog)
  19033. fmt.Println(errMsgLog)
  19034. saveLog(result, requestLog, "4101a", "上传清单")
  19035. var dat map[string]interface{}
  19036. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19037. fmt.Println(dat)
  19038. } else {
  19039. fmt.Println(err)
  19040. }
  19041. userJSONBytes, _ := json.Marshal(dat)
  19042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19043. utils.ErrorLog("解析失败:%v", err)
  19044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19045. return
  19046. }
  19047. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19048. var pp models.PublicParams
  19049. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19050. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19051. pp.FixmedinsName = miConfig.OrgName
  19052. pp.FixmedinsCode = miConfig.Code
  19053. pp.RequestUrl = miConfig.Url
  19054. pp.Cainfo = miConfig.Cainfo
  19055. pp.SecretKey = miConfig.SecretKey
  19056. pp.AccessKey = miConfig.AccessKey
  19057. pp.OpterName = curRoles.UserName
  19058. client := &http.Client{}
  19059. var req *http.Request
  19060. data := make(map[string]interface{})
  19061. data["struct4101"] = struct4101
  19062. data["pp"] = pp
  19063. bytesData, _ := json.Marshal(data)
  19064. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19065. resp, _ := client.Do(req)
  19066. defer resp.Body.Close()
  19067. body, ioErr := ioutil.ReadAll(resp.Body)
  19068. if ioErr != nil {
  19069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19071. return
  19072. }
  19073. var respJSON map[string]interface{}
  19074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19077. return
  19078. }
  19079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19080. userJSONBytes, _ := json.Marshal(respJSON)
  19081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19082. utils.ErrorLog("解析失败:%v", err)
  19083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19084. return
  19085. }
  19086. } else {
  19087. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19088. var dat map[string]interface{}
  19089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19090. fmt.Println(dat)
  19091. } else {
  19092. fmt.Println(err)
  19093. }
  19094. userJSONBytes, _ := json.Marshal(dat)
  19095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19096. utils.ErrorLog("解析失败:%v", err)
  19097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19098. return
  19099. }
  19100. }
  19101. if res.Infcode != 0 {
  19102. errlog := &models.HisOrderError{
  19103. UserOrgId: order.UserOrgId,
  19104. Ctime: time.Now().Unix(),
  19105. Mtime: time.Now().Unix(),
  19106. ErrMsg: res.ErrMsg + "解析失败",
  19107. Status: 1,
  19108. PatientId: order.ID,
  19109. Stage: 10485,
  19110. }
  19111. service.CreateErrMsgLog(errlog)
  19112. continue
  19113. //c.ServeSuccessJSON(map[string]interface{}{
  19114. // "failed_code": -10,
  19115. // "msg": res.ErrMsg,
  19116. //})
  19117. } else {
  19118. //order.FaPiaoNumber = zero
  19119. //order.FaPiaoCode = last_order.FaPiaoCode
  19120. //service.UpdateOrder(order)
  19121. hisFundSettleListResult := &models.HisFundSettleListResult{
  19122. Number: res.Output.SetlListId,
  19123. Status: 1,
  19124. Ctime: time.Now().Unix(),
  19125. Mtime: time.Now().Unix(),
  19126. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19127. IsUpload: 1,
  19128. OrderId: order.ID,
  19129. }
  19130. service.CreateUploadRecord(hisFundSettleListResult)
  19131. continue
  19132. }
  19133. }
  19134. }
  19135. func (c *HisApiController) GetSettleList() {
  19136. order_id, _ := c.GetInt64("order_id")
  19137. admin_user_id, _ := c.GetInt64("admin_user_id")
  19138. order, _ := service.GetHisOrderByIDTwo(order_id)
  19139. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19140. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19141. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19142. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19143. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19144. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19145. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19146. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19147. if order.ID == 0 {
  19148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19149. return
  19150. }
  19151. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19152. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19153. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19154. //fmt.Println(count)
  19155. //var zero string
  19156. //number := count + 1
  19157. //if number >= 1000 {
  19158. // zero = "0000" + strconv.FormatInt(number, 10)
  19159. //} else if number >= 10000 {
  19160. // zero = "000" + strconv.FormatInt(number, 10)
  19161. //} else if number >= 100000 {
  19162. // zero = "00" + strconv.FormatInt(number, 10)
  19163. //} else if number >= 1000000 {
  19164. // zero = "0" + strconv.FormatInt(number, 10)
  19165. //} else {
  19166. // zero = strconv.FormatInt(number, 10)
  19167. //}
  19168. //fmt.Println(zero)
  19169. struct4101 := service.Struct4101{
  19170. PsnNo: order.PsnNo,
  19171. MdtrtId: order.MdtrtId,
  19172. SetlId: order.SetlId,
  19173. PsnName: order.PsnName,
  19174. Gend: order.Gend,
  19175. Brdy: his.Brdy,
  19176. Age: his.Age,
  19177. Naty: order.Naty,
  19178. PatnCertType: "01",
  19179. Certno: order.Certno,
  19180. Prfs: "90",
  19181. ConerName: roles[0].UserName,
  19182. PatnRlts: "99",
  19183. ConerAddr: miConfig.OrgName,
  19184. ConerTel: admin.Mobile,
  19185. HiType: order.Insutype,
  19186. Insuplc: miConfig.InsuplcAdmdvs,
  19187. MaindiagFlag: "1",
  19188. BillCode: order.SetlId,
  19189. BillNo: order.SetlId,
  19190. BizSn: order.Number,
  19191. PsnSelfPay: order.PsnPartAmt,
  19192. PsnOwnPay: order.PsnPartAmt,
  19193. AcctPay: order.AcctPay,
  19194. PsnCashpay: order.PsnCashPay,
  19195. HiPaymtd: "1",
  19196. Hsorg: miConfig.InsuplcAdmdvs,
  19197. HsorgOpter: miConfig.InsuplcAdmdvs,
  19198. MedinsFillPsn: curRoles.UserName,
  19199. MedinsFillDept: miConfig.OrgName,
  19200. IptMedType: "2",
  19201. }
  19202. struct4101.SetlBegnDate = order.SetlTime
  19203. struct4101.SetlEndDate = order.SetlTime
  19204. time_arr := strings.Split(order.SetlTime, " ")
  19205. struct4101.AdmTime = time_arr[0]
  19206. struct4101.AdmEndTime = time_arr[0]
  19207. //
  19208. //var rf []CustomFundPay
  19209. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19210. //
  19211. //var tempFunPays []service.CustomStruct
  19212. //for _, item := range rf {
  19213. // var tempFunPay service.CustomStruct
  19214. // tempFunPay.FundPayamt = item.FundPayamt
  19215. // tempFunPay.FundPayType = item.FundPayType
  19216. // tempFunPays = append(tempFunPays, tempFunPay)
  19217. //}
  19218. //struct4101.CustomStruct = tempFunPays
  19219. var tempDiaginfos []service.DiaginfoStructTwo
  19220. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19221. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19222. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19223. var config []*models.HisXtDiagnoseConfig
  19224. for _, item := range diagnosis_ids {
  19225. id, _ := strconv.ParseInt(item, 10, 64)
  19226. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19227. config = append(config, &diagnosisConfig)
  19228. }
  19229. if miConfig.Code == "H15049901371" {
  19230. //for _, item := range config {
  19231. // if item.ID == 138 {
  19232. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19233. var tempDiaginfo service.DiaginfoStructTwo
  19234. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19235. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19236. tempDiaginfo.DiagType = "1"
  19237. tempDiaginfo.MaindiagFlag = "1"
  19238. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19239. //}
  19240. //}
  19241. for _, item := range config {
  19242. if item.ID != 138 {
  19243. var tempDiaginfo service.DiaginfoStructTwo
  19244. tempDiaginfo.DiagCode = item.CountryCode
  19245. tempDiaginfo.DiagName = item.CountryContentName
  19246. tempDiaginfo.DiagType = "1"
  19247. tempDiaginfo.MaindiagFlag = "0"
  19248. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19249. }
  19250. }
  19251. } else {
  19252. for index, item := range config {
  19253. if index == 0 {
  19254. var tempDiaginfo service.DiaginfoStructTwo
  19255. tempDiaginfo.DiagCode = item.CountryCode
  19256. tempDiaginfo.DiagName = item.CountryContentName
  19257. tempDiaginfo.DiagType = "1"
  19258. tempDiaginfo.MaindiagFlag = "1"
  19259. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19260. } else {
  19261. var tempDiaginfo service.DiaginfoStructTwo
  19262. tempDiaginfo.DiagCode = item.CountryCode
  19263. tempDiaginfo.DiagName = item.CountryContentName
  19264. tempDiaginfo.DiagType = "1"
  19265. tempDiaginfo.MaindiagFlag = "0"
  19266. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19267. }
  19268. }
  19269. }
  19270. struct4101.Diseinfo = tempDiaginfos
  19271. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19272. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19273. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19274. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19275. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19276. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19277. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19278. var iteminfo service.IteminfoStruct
  19279. var bedCostTotal float64 = 0 //床位总费
  19280. var bedCostSelfTotal float64 = 0 //床位自费
  19281. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19282. var operationCostTotal float64 = 0 //手术费
  19283. var operationCostSelfTotal float64 = 0 //手术费
  19284. var operationCostPartSelfTotal float64 = 0 //手术费
  19285. var otherCostTotal float64 = 0 //其他费用
  19286. var otherCostSelfTotal float64 = 0 //其他费用
  19287. var otherCostPartSelfTotal float64 = 0 //其他费用
  19288. var materialCostTotal float64 = 0 //材料费
  19289. var materialCostSelfTotal float64 = 0 //材料费
  19290. var materialCostPartSelfTotal float64 = 0 //材料费
  19291. var westernMedicineCostTotal float64 = 0 //西药费
  19292. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19293. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19294. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19295. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19296. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19297. var checkCostTotal float64 = 0 //检查费
  19298. var checkCostSelfTotal float64 = 0 //检查费
  19299. var checkCostPartSelfTotal float64 = 0 //检查费
  19300. var laboratoryCostTotal float64 = 0 //化验费
  19301. var laboratoryCostSelfTotal float64 = 0 //化验费
  19302. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19303. var treatCostTotal float64 = 0 //治疗费用
  19304. var treatCostSelfTotal float64 = 0 //治疗费用
  19305. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19306. decimal.DivisionPrecision = 2
  19307. var bed_fulamt_ownpay_amt float64 = 0
  19308. var operation_fulamt_ownpay_amt float64 = 0
  19309. var other_fulamt_ownpay_amt float64 = 0
  19310. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19311. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19312. var check_fulamt_ownpay_amt float64 = 0
  19313. var material_fulamt_ownpay_amt float64 = 0
  19314. var laboratory_fulamt_ownpay_amt float64 = 0
  19315. var treat_fulamt_ownpay_amt float64 = 0
  19316. var bed_claa_sunmfee float64 = 0
  19317. var bed_clab_amt float64 = 0
  19318. var bed_other_amt float64 = 0
  19319. var operation_claa_sunmfee float64 = 0
  19320. var operation_clab_amt float64 = 0
  19321. var operation_other_amt float64 = 0
  19322. var other_claa_sunmfee float64 = 0
  19323. var other_clab_amt float64 = 0
  19324. var other_other_amt float64 = 0
  19325. var westernMedicine_claa_sunmfee float64 = 0
  19326. var westernMedicine_clab_amt float64 = 0
  19327. var westernMedicine_other_amt float64 = 0
  19328. var chineseTraditional_claa_sunmfee float64 = 0
  19329. var chineseTraditional_clab_amt float64 = 0
  19330. var chineseTraditional_other_amt float64 = 0
  19331. var check_claa_sunmfee float64 = 0
  19332. var check_clab_amt float64 = 0
  19333. var check_other_amt float64 = 0
  19334. var material_claa_sunmfee float64 = 0
  19335. var material_clab_amt float64 = 0
  19336. var material_other_amt float64 = 0
  19337. var laboratory_claa_sunmfee float64 = 0
  19338. var laboratory_clab_amt float64 = 0
  19339. var laboratory_other_amt float64 = 0
  19340. var treat_claa_sunmfee float64 = 0
  19341. var treat_clab_amt float64 = 0
  19342. var treat_other_amt float64 = 0
  19343. for _, item := range order.HisOrderInfo {
  19344. if item.MedChrgitmType == "01" { //床位费
  19345. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19346. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19347. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19348. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19349. if item.ChrgitmLv == "1" {
  19350. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19351. }
  19352. if item.ChrgitmLv == "2" {
  19353. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19354. }
  19355. if item.ChrgitmLv == "3" {
  19356. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19357. }
  19358. }
  19359. if item.MedChrgitmType == "03" { //检查费
  19360. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19361. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19362. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19363. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19364. if item.ChrgitmLv == "1" {
  19365. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19366. }
  19367. if item.ChrgitmLv == "2" {
  19368. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19369. }
  19370. if item.ChrgitmLv == "3" {
  19371. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19372. }
  19373. }
  19374. if item.MedChrgitmType == "04" { //化验费
  19375. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19376. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19377. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19378. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19379. if item.ChrgitmLv == "1" {
  19380. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19381. }
  19382. if item.ChrgitmLv == "2" {
  19383. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19384. }
  19385. if item.ChrgitmLv == "3" {
  19386. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19387. }
  19388. }
  19389. if item.MedChrgitmType == "05" { //治疗费
  19390. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19391. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19392. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19393. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19394. if item.ChrgitmLv == "1" {
  19395. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19396. }
  19397. if item.ChrgitmLv == "2" {
  19398. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19399. }
  19400. if item.ChrgitmLv == "3" {
  19401. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19402. }
  19403. }
  19404. if item.MedChrgitmType == "06" { //手术费
  19405. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19406. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19407. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19408. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19409. if item.ChrgitmLv == "1" {
  19410. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19411. }
  19412. if item.ChrgitmLv == "2" {
  19413. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19414. }
  19415. if item.ChrgitmLv == "3" {
  19416. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19417. }
  19418. }
  19419. if item.MedChrgitmType == "08" { //材料费
  19420. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19421. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19422. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19423. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19424. if item.ChrgitmLv == "1" {
  19425. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19426. }
  19427. if item.ChrgitmLv == "2" {
  19428. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19429. }
  19430. if item.ChrgitmLv == "3" {
  19431. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19432. }
  19433. }
  19434. if item.MedChrgitmType == "09" { //西药费
  19435. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19436. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19437. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19438. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19439. if item.ChrgitmLv == "1" {
  19440. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19441. }
  19442. if item.ChrgitmLv == "2" {
  19443. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19444. }
  19445. if item.ChrgitmLv == "3" {
  19446. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19447. }
  19448. }
  19449. if item.MedChrgitmType == "11" { //中成费
  19450. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19451. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19452. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19453. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19454. if item.ChrgitmLv == "1" {
  19455. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19456. }
  19457. if item.ChrgitmLv == "2" {
  19458. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19459. }
  19460. if item.ChrgitmLv == "3" {
  19461. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19462. }
  19463. }
  19464. if item.MedChrgitmType == "14" { //其他费
  19465. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19466. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19467. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19468. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19469. if item.ChrgitmLv == "1" {
  19470. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19471. }
  19472. if item.ChrgitmLv == "2" {
  19473. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19474. }
  19475. if item.ChrgitmLv == "3" {
  19476. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19477. }
  19478. }
  19479. }
  19480. var iteminfoStructs []service.IteminfoStruct
  19481. if bedCostTotal != 0 {
  19482. iteminfo.MedChrgitm = "01"
  19483. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19484. iteminfo.Amt = bedCostTotal
  19485. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19486. iteminfo.ClabAmt = bed_clab_amt
  19487. iteminfo.OthAmt = bed_other_amt
  19488. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19489. }
  19490. if checkCostTotal != 0 {
  19491. iteminfo.MedChrgitm = "03"
  19492. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19493. iteminfo.Amt = checkCostTotal
  19494. iteminfo.ClaaSumfee = check_claa_sunmfee
  19495. iteminfo.ClabAmt = check_clab_amt
  19496. iteminfo.OthAmt = check_other_amt
  19497. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19498. }
  19499. if laboratoryCostTotal != 0 {
  19500. iteminfo.MedChrgitm = "04"
  19501. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19502. iteminfo.Amt = laboratoryCostTotal
  19503. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19504. iteminfo.ClabAmt = laboratory_clab_amt
  19505. iteminfo.OthAmt = laboratory_other_amt
  19506. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19507. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19508. }
  19509. if treatCostTotal != 0 {
  19510. iteminfo.MedChrgitm = "05"
  19511. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19512. iteminfo.Amt = treatCostTotal
  19513. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19514. iteminfo.ClabAmt = treat_clab_amt
  19515. iteminfo.OthAmt = treat_other_amt
  19516. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19517. //(struct4101.IteminfoStruct, iteminfo)
  19518. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19519. }
  19520. if operationCostTotal != 0 {
  19521. iteminfo.MedChrgitm = "06"
  19522. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19523. iteminfo.Amt = operationCostTotal
  19524. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19525. iteminfo.ClabAmt = operation_clab_amt
  19526. iteminfo.OthAmt = operation_other_amt
  19527. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19528. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19529. }
  19530. if materialCostTotal != 0 {
  19531. iteminfo.MedChrgitm = "08"
  19532. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19533. iteminfo.Amt = materialCostTotal
  19534. iteminfo.ClaaSumfee = material_claa_sunmfee
  19535. iteminfo.ClabAmt = material_clab_amt
  19536. iteminfo.OthAmt = material_other_amt
  19537. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19538. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19539. }
  19540. if westernMedicineCostTotal != 0 {
  19541. iteminfo.MedChrgitm = "09"
  19542. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19543. iteminfo.Amt = westernMedicineCostTotal
  19544. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19545. iteminfo.ClabAmt = westernMedicine_clab_amt
  19546. iteminfo.OthAmt = westernMedicine_other_amt
  19547. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19548. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19549. }
  19550. if chineseTraditionalMedicineCostTotal != 0 {
  19551. iteminfo.MedChrgitm = "11"
  19552. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19553. iteminfo.Amt = westernMedicineCostTotal
  19554. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19555. iteminfo.ClabAmt = westernMedicine_clab_amt
  19556. iteminfo.OthAmt = westernMedicine_other_amt
  19557. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19558. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19559. }
  19560. if otherCostTotal != 0 {
  19561. iteminfo.MedChrgitm = "14"
  19562. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19563. iteminfo.Amt = otherCostTotal
  19564. iteminfo.ClaaSumfee = other_claa_sunmfee
  19565. iteminfo.ClabAmt = other_clab_amt
  19566. iteminfo.OthAmt = other_other_amt
  19567. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19568. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19569. }
  19570. struct4101.IteminfoStruct = iteminfoStructs
  19571. struct4101.Ntly = "中国"
  19572. struct4101.AdmCaty = "A03.06"
  19573. struct4101.DoctorName = doctor.UserName
  19574. struct4101.DoctorCode = doctor.DoctorNumber
  19575. var res ResultSeventeen
  19576. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19577. struct4101.BillCode = order.Number
  19578. struct4101.BillNo = order.SetlId
  19579. var resOther ResultSeventeenOther
  19580. var pp models.PublicParams
  19581. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19582. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19583. pp.FixmedinsName = miConfig.OrgName
  19584. pp.FixmedinsCode = miConfig.Code
  19585. pp.RequestUrl = miConfig.Url
  19586. pp.Cainfo = miConfig.Cainfo
  19587. pp.SecretKey = miConfig.SecretKey
  19588. pp.AccessKey = miConfig.AccessKey
  19589. pp.OpterName = curRoles.UserName
  19590. client := &http.Client{}
  19591. var req *http.Request
  19592. data := make(map[string]interface{})
  19593. data["struct4101"] = struct4101
  19594. data["pp"] = pp
  19595. bytesData, _ := json.Marshal(data)
  19596. if miConfig.MdtrtareaAdmvs == "320921" {
  19597. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19598. } else {
  19599. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19600. }
  19601. resp, _ := client.Do(req)
  19602. defer resp.Body.Close()
  19603. body, ioErr := ioutil.ReadAll(resp.Body)
  19604. if ioErr != nil {
  19605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19607. return
  19608. }
  19609. var respJSON map[string]interface{}
  19610. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19613. return
  19614. }
  19615. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19616. userJSONBytes, _ := json.Marshal(respJSON)
  19617. fmt.Println("log")
  19618. fmt.Println(string(userJSONBytes))
  19619. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19620. utils.ErrorLog("解析失败:%v", err)
  19621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19622. return
  19623. }
  19624. res.InfRefmsgid = resOther.InfRefmsgid
  19625. res.Output = resOther.Output
  19626. res.ErrMsg = resOther.ErrMsg
  19627. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19628. res.Infcode = infocode
  19629. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19630. var pp models.PublicParams
  19631. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19632. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19633. pp.FixmedinsName = miConfig.OrgName
  19634. pp.FixmedinsCode = miConfig.Code
  19635. pp.RequestUrl = miConfig.Url
  19636. pp.Cainfo = miConfig.Cainfo
  19637. pp.SecretKey = miConfig.SecretKey
  19638. pp.AccessKey = miConfig.AccessKey
  19639. pp.OpterName = curRoles.UserName
  19640. result, _ := service.Jxyb4101(struct4101, pp)
  19641. var dat map[string]interface{}
  19642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19643. fmt.Println(dat)
  19644. } else {
  19645. fmt.Println(err)
  19646. }
  19647. userJSONBytes, _ := json.Marshal(dat)
  19648. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19649. utils.ErrorLog("解析失败:%v", err)
  19650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19651. return
  19652. }
  19653. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19654. var pp models.PublicParams
  19655. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19656. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19657. pp.FixmedinsName = miConfig.OrgName
  19658. pp.FixmedinsCode = miConfig.Code
  19659. pp.RequestUrl = miConfig.Url
  19660. pp.Cainfo = miConfig.Cainfo
  19661. pp.SecretKey = miConfig.SecretKey
  19662. pp.AccessKey = miConfig.AccessKey
  19663. pp.OpterName = curRoles.UserName
  19664. result, _ := service.Jxyb4101(struct4101, pp)
  19665. var dat map[string]interface{}
  19666. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19667. fmt.Println(dat)
  19668. } else {
  19669. fmt.Println(err)
  19670. }
  19671. userJSONBytes, _ := json.Marshal(dat)
  19672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19673. utils.ErrorLog("解析失败:%v", err)
  19674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19675. return
  19676. }
  19677. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19678. var pp models.PublicParams
  19679. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19680. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19681. pp.FixmedinsName = miConfig.OrgName
  19682. pp.FixmedinsCode = miConfig.Code
  19683. pp.RequestUrl = miConfig.Url
  19684. pp.Cainfo = miConfig.Cainfo
  19685. pp.SecretKey = miConfig.SecretKey
  19686. pp.AccessKey = miConfig.AccessKey
  19687. pp.OpterName = curRoles.UserName
  19688. result, _ := service.Hnyb4101(struct4101, pp)
  19689. var dat map[string]interface{}
  19690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19691. fmt.Println(dat)
  19692. } else {
  19693. fmt.Println(err)
  19694. }
  19695. userJSONBytes, _ := json.Marshal(dat)
  19696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19697. utils.ErrorLog("解析失败:%v", err)
  19698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19699. return
  19700. }
  19701. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19702. var resOther ResultSeventeenOther
  19703. var pp models.PublicParams
  19704. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19705. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19706. pp.FixmedinsName = miConfig.OrgName
  19707. pp.FixmedinsCode = miConfig.Code
  19708. pp.RequestUrl = miConfig.Url
  19709. pp.Cainfo = miConfig.Cainfo
  19710. pp.SecretKey = miConfig.SecretKey
  19711. pp.AccessKey = miConfig.AccessKey
  19712. pp.OpterName = curRoles.UserName
  19713. client := &http.Client{}
  19714. var req *http.Request
  19715. data := make(map[string]interface{})
  19716. data["struct4101"] = struct4101
  19717. data["pp"] = pp
  19718. bytesData, _ := json.Marshal(data)
  19719. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19720. resp, _ := client.Do(req)
  19721. defer resp.Body.Close()
  19722. body, ioErr := ioutil.ReadAll(resp.Body)
  19723. if ioErr != nil {
  19724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19726. return
  19727. }
  19728. var respJSON map[string]interface{}
  19729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19732. return
  19733. }
  19734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19735. userJSONBytes, _ := json.Marshal(respJSON)
  19736. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19737. utils.ErrorLog("解析失败:%v", err)
  19738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19739. return
  19740. }
  19741. res.InfRefmsgid = resOther.InfRefmsgid
  19742. res.Output = resOther.Output
  19743. res.ErrMsg = resOther.ErrMsg
  19744. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19745. res.Infcode = infocode
  19746. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19747. var pp models.PublicParams
  19748. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19749. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19750. pp.FixmedinsName = miConfig.OrgName
  19751. pp.FixmedinsCode = miConfig.Code
  19752. pp.RequestUrl = miConfig.Url
  19753. pp.Cainfo = miConfig.Cainfo
  19754. pp.SecretKey = miConfig.SecretKey
  19755. pp.AccessKey = miConfig.AccessKey
  19756. pp.OpterName = curRoles.UserName
  19757. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19758. fmt.Println(requestLog)
  19759. fmt.Println(errMsgLog)
  19760. saveLog(result, requestLog, "4101a", "上传清单")
  19761. var dat map[string]interface{}
  19762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19763. fmt.Println(dat)
  19764. } else {
  19765. fmt.Println(err)
  19766. }
  19767. userJSONBytes, _ := json.Marshal(dat)
  19768. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19769. utils.ErrorLog("解析失败:%v", err)
  19770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19771. return
  19772. }
  19773. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19774. var pp models.PublicParams
  19775. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19776. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19777. pp.FixmedinsName = miConfig.OrgName
  19778. pp.FixmedinsCode = miConfig.Code
  19779. pp.RequestUrl = miConfig.Url
  19780. pp.Cainfo = miConfig.Cainfo
  19781. pp.SecretKey = miConfig.SecretKey
  19782. pp.AccessKey = miConfig.AccessKey
  19783. pp.OpterName = curRoles.UserName
  19784. client := &http.Client{}
  19785. var req *http.Request
  19786. data := make(map[string]interface{})
  19787. data["struct4101"] = struct4101
  19788. data["pp"] = pp
  19789. bytesData, _ := json.Marshal(data)
  19790. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19791. resp, _ := client.Do(req)
  19792. defer resp.Body.Close()
  19793. body, ioErr := ioutil.ReadAll(resp.Body)
  19794. if ioErr != nil {
  19795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19797. return
  19798. }
  19799. var respJSON map[string]interface{}
  19800. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19803. return
  19804. }
  19805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19806. userJSONBytes, _ := json.Marshal(respJSON)
  19807. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19808. utils.ErrorLog("解析失败:%v", err)
  19809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19810. return
  19811. }
  19812. } else {
  19813. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19814. var dat map[string]interface{}
  19815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19816. fmt.Println(dat)
  19817. } else {
  19818. fmt.Println(err)
  19819. }
  19820. userJSONBytes, _ := json.Marshal(dat)
  19821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19822. utils.ErrorLog("解析失败:%v", err)
  19823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19824. return
  19825. }
  19826. }
  19827. if res.Infcode != 0 {
  19828. c.ServeSuccessJSON(map[string]interface{}{
  19829. "failed_code": -10,
  19830. "msg": res.ErrMsg,
  19831. })
  19832. return
  19833. } else {
  19834. //order.FaPiaoNumber = zero
  19835. //order.FaPiaoCode = last_order.FaPiaoCode
  19836. //service.UpdateOrder(order)
  19837. hisFundSettleListResult := &models.HisFundSettleListResult{
  19838. Number: res.Output.SetlListId,
  19839. Status: 1,
  19840. Ctime: time.Now().Unix(),
  19841. Mtime: time.Now().Unix(),
  19842. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19843. IsUpload: 1,
  19844. OrderId: order_id,
  19845. }
  19846. service.CreateUploadRecord(hisFundSettleListResult)
  19847. c.ServeSuccessJSON(map[string]interface{}{
  19848. "msg": "上传成功",
  19849. "result": hisFundSettleListResult,
  19850. })
  19851. return
  19852. }
  19853. }
  19854. func (c *HisApiController) GetSettleListHospital() {
  19855. order_id, _ := c.GetInt64("order_id")
  19856. admin_user_id, _ := c.GetInt64("admin_user_id")
  19857. order, _ := service.GetHisOrderByIDTwo(order_id)
  19858. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19859. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19860. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19861. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19862. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19863. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19864. if order.ID == 0 {
  19865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19866. return
  19867. }
  19868. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19869. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19870. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19871. fmt.Println(count)
  19872. var zero string
  19873. number := count + 1
  19874. if number >= 1000 {
  19875. zero = "0000" + strconv.FormatInt(number, 10)
  19876. } else if number >= 10000 {
  19877. zero = "000" + strconv.FormatInt(number, 10)
  19878. } else if number >= 100000 {
  19879. zero = "00" + strconv.FormatInt(number, 10)
  19880. } else if number >= 1000000 {
  19881. zero = "0" + strconv.FormatInt(number, 10)
  19882. } else {
  19883. zero = strconv.FormatInt(number, 10)
  19884. }
  19885. fmt.Println(zero)
  19886. struct4101 := service.Struct4101{
  19887. PsnNo: order.PsnNo,
  19888. MdtrtId: order.MdtrtId,
  19889. SetlId: order.SetlId,
  19890. PsnName: order.PsnName,
  19891. Gend: order.Gend,
  19892. Brdy: his.Brdy,
  19893. Age: int64(order.Age),
  19894. Naty: order.Naty,
  19895. PatnCertType: "01",
  19896. Certno: order.Certno,
  19897. Prfs: "90",
  19898. ConerName: roles[0].UserName,
  19899. PatnRlts: "99",
  19900. ConerAddr: miConfig.OrgName,
  19901. ConerTel: admin.Mobile,
  19902. HiType: order.Insutype,
  19903. Insuplc: miConfig.InsuplcAdmdvs,
  19904. MaindiagFlag: "1",
  19905. BillCode: order.SetlId,
  19906. BillNo: order.SetlId,
  19907. BizSn: order.Number,
  19908. PsnSelfPay: order.PsnPartAmt,
  19909. PsnOwnPay: order.PsnPartAmt,
  19910. AcctPay: order.AcctPay,
  19911. PsnCashpay: order.PsnCashPay,
  19912. HiPaymtd: "1",
  19913. Hsorg: miConfig.InsuplcAdmdvs,
  19914. HsorgOpter: miConfig.InsuplcAdmdvs,
  19915. MedinsFillPsn: curRoles.UserName,
  19916. MedinsFillDept: depart.Name,
  19917. IptMedType: "2",
  19918. AdmTime: his.InHosptialTime,
  19919. AdmEndTime: his.OutHosptialTime,
  19920. }
  19921. struct4101.SetlBegnDate = order.SetlTime
  19922. struct4101.SetlEndDate = order.SetlTime
  19923. //var rf []CustomFundPay
  19924. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19925. //
  19926. //var tempFunPays []service.CustomStruct
  19927. //for _, item := range rf {
  19928. // var tempFunPay service.CustomStruct
  19929. // tempFunPay.FundPayamt = item.FundPayamt
  19930. // tempFunPay.FundPayType = item.FundPayType
  19931. // tempFunPays = append(tempFunPays, tempFunPay)
  19932. //}
  19933. //struct4101.CustomStruct = tempFunPays
  19934. var tempDiaginfos []service.DiaginfoStructTwo
  19935. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19936. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19937. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19938. //for _, item := range infos {
  19939. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19940. //}
  19941. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19942. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19943. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19944. fmt.Println(diagnosis_ids_arr)
  19945. if order.UserOrgId == 10210 {
  19946. var diagnosis_ids_arr_two []int64
  19947. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19948. var config []*models.HisXtDiagnoseConfig
  19949. for _, id := range diagnosis_ids_arr_two {
  19950. //id, _ := strconv.ParseInt(item, 10, 64)
  19951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19952. if diagnosisConfig.ID > 0 {
  19953. config = append(config, &diagnosisConfig)
  19954. }
  19955. }
  19956. for index, item := range config {
  19957. if item.ID > 0 {
  19958. if index == 0 {
  19959. var tempDiaginfo service.DiaginfoStructTwo
  19960. tempDiaginfo.DiagCode = item.CountryCode
  19961. tempDiaginfo.DiagName = item.CountryContentName
  19962. tempDiaginfo.DiagType = "1"
  19963. tempDiaginfo.MaindiagFlag = "1"
  19964. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19965. } else {
  19966. var tempDiaginfo service.DiaginfoStructTwo
  19967. tempDiaginfo.DiagCode = item.CountryCode
  19968. tempDiaginfo.DiagName = item.CountryContentName
  19969. tempDiaginfo.DiagType = "1"
  19970. tempDiaginfo.MaindiagFlag = "0"
  19971. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19972. }
  19973. }
  19974. }
  19975. struct4101.Diseinfo = tempDiaginfos
  19976. } else {
  19977. var config []*models.HisXtDiagnoseConfig
  19978. for _, item := range diagnosis_ids_arr {
  19979. id, _ := strconv.ParseInt(item, 10, 64)
  19980. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19981. if diagnosisConfig.ID > 0 {
  19982. config = append(config, &diagnosisConfig)
  19983. }
  19984. }
  19985. for index, item := range config {
  19986. if item.ID > 0 {
  19987. if index == 0 {
  19988. var tempDiaginfo service.DiaginfoStructTwo
  19989. tempDiaginfo.DiagCode = item.CountryCode
  19990. tempDiaginfo.DiagName = item.CountryContentName
  19991. tempDiaginfo.DiagType = "1"
  19992. tempDiaginfo.MaindiagFlag = "1"
  19993. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19994. } else {
  19995. var tempDiaginfo service.DiaginfoStructTwo
  19996. tempDiaginfo.DiagCode = item.CountryCode
  19997. tempDiaginfo.DiagName = item.CountryContentName
  19998. tempDiaginfo.DiagType = "1"
  19999. tempDiaginfo.MaindiagFlag = "0"
  20000. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20001. }
  20002. }
  20003. }
  20004. struct4101.Diseinfo = tempDiaginfos
  20005. }
  20006. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20007. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20008. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20009. tempOpspdiseinfo2.OprnOprtCode = ""
  20010. tempOpspdiseinfo2.OprnOprtName = ""
  20011. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20012. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20013. var iteminfo service.IteminfoStruct
  20014. var bedCostTotal float64 = 0 //床位总费
  20015. var bedCostSelfTotal float64 = 0 //床位自费
  20016. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20017. var operationCostTotal float64 = 0 //手术费
  20018. var operationCostSelfTotal float64 = 0 //手术费
  20019. var operationCostPartSelfTotal float64 = 0 //手术费
  20020. var otherCostTotal float64 = 0 //其他费用
  20021. var otherCostSelfTotal float64 = 0 //其他费用
  20022. var otherCostPartSelfTotal float64 = 0 //其他费用
  20023. var materialCostTotal float64 = 0 //材料费
  20024. var materialCostSelfTotal float64 = 0 //材料费
  20025. var materialCostPartSelfTotal float64 = 0 //材料费
  20026. var westernMedicineCostTotal float64 = 0 //西药费
  20027. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20028. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20029. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20030. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20031. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20032. var checkCostTotal float64 = 0 //检查费
  20033. var checkCostSelfTotal float64 = 0 //检查费
  20034. var checkCostPartSelfTotal float64 = 0 //检查费
  20035. var laboratoryCostTotal float64 = 0 //化验费
  20036. var laboratoryCostSelfTotal float64 = 0 //化验费
  20037. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20038. var treatCostTotal float64 = 0 //治疗费用
  20039. var treatCostSelfTotal float64 = 0 //治疗费用
  20040. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20041. decimal.DivisionPrecision = 2
  20042. var bed_fulamt_ownpay_amt float64 = 0
  20043. var operation_fulamt_ownpay_amt float64 = 0
  20044. var other_fulamt_ownpay_amt float64 = 0
  20045. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20046. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20047. var check_fulamt_ownpay_amt float64 = 0
  20048. var material_fulamt_ownpay_amt float64 = 0
  20049. var laboratory_fulamt_ownpay_amt float64 = 0
  20050. var treat_fulamt_ownpay_amt float64 = 0
  20051. var bed_claa_sunmfee float64 = 0
  20052. var bed_clab_amt float64 = 0
  20053. var bed_other_amt float64 = 0
  20054. var operation_claa_sunmfee float64 = 0
  20055. var operation_clab_amt float64 = 0
  20056. var operation_other_amt float64 = 0
  20057. var other_claa_sunmfee float64 = 0
  20058. var other_clab_amt float64 = 0
  20059. var other_other_amt float64 = 0
  20060. var westernMedicine_claa_sunmfee float64 = 0
  20061. var westernMedicine_clab_amt float64 = 0
  20062. var westernMedicine_other_amt float64 = 0
  20063. var chineseTraditional_claa_sunmfee float64 = 0
  20064. var chineseTraditional_clab_amt float64 = 0
  20065. var chineseTraditional_other_amt float64 = 0
  20066. var check_claa_sunmfee float64 = 0
  20067. var check_clab_amt float64 = 0
  20068. var check_other_amt float64 = 0
  20069. var material_claa_sunmfee float64 = 0
  20070. var material_clab_amt float64 = 0
  20071. var material_other_amt float64 = 0
  20072. var laboratory_claa_sunmfee float64 = 0
  20073. var laboratory_clab_amt float64 = 0
  20074. var laboratory_other_amt float64 = 0
  20075. var treat_claa_sunmfee float64 = 0
  20076. var treat_clab_amt float64 = 0
  20077. var treat_other_amt float64 = 0
  20078. for _, item := range order.HisOrderInfo {
  20079. if item.MedChrgitmType == "01" { //床位费
  20080. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20081. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20082. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20083. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20084. if item.ChrgitmLv == "1" {
  20085. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20086. }
  20087. if item.ChrgitmLv == "2" {
  20088. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20089. }
  20090. if item.ChrgitmLv == "3" {
  20091. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20092. }
  20093. }
  20094. if item.MedChrgitmType == "03" { //检查费
  20095. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20096. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20097. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20098. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20099. if item.ChrgitmLv == "1" {
  20100. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20101. }
  20102. if item.ChrgitmLv == "2" {
  20103. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20104. }
  20105. if item.ChrgitmLv == "3" {
  20106. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20107. }
  20108. }
  20109. if item.MedChrgitmType == "04" { //化验费
  20110. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20111. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20112. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20113. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20114. if item.ChrgitmLv == "1" {
  20115. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20116. }
  20117. if item.ChrgitmLv == "2" {
  20118. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20119. }
  20120. if item.ChrgitmLv == "3" {
  20121. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20122. }
  20123. }
  20124. if item.MedChrgitmType == "05" { //治疗费
  20125. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20126. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20127. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20128. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20129. if item.ChrgitmLv == "1" {
  20130. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20131. }
  20132. if item.ChrgitmLv == "2" {
  20133. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20134. }
  20135. if item.ChrgitmLv == "3" {
  20136. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20137. }
  20138. }
  20139. if item.MedChrgitmType == "06" { //手术费
  20140. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20141. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20142. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20143. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20144. if item.ChrgitmLv == "1" {
  20145. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20146. }
  20147. if item.ChrgitmLv == "2" {
  20148. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20149. }
  20150. if item.ChrgitmLv == "3" {
  20151. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20152. }
  20153. }
  20154. if item.MedChrgitmType == "08" { //材料费
  20155. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20156. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20157. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20158. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20159. if item.ChrgitmLv == "1" {
  20160. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20161. }
  20162. if item.ChrgitmLv == "2" {
  20163. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20164. }
  20165. if item.ChrgitmLv == "3" {
  20166. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20167. }
  20168. }
  20169. if item.MedChrgitmType == "09" { //西药费
  20170. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20171. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20172. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20173. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20174. if item.ChrgitmLv == "1" {
  20175. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20176. }
  20177. if item.ChrgitmLv == "2" {
  20178. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20179. }
  20180. if item.ChrgitmLv == "3" {
  20181. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20182. }
  20183. }
  20184. if item.MedChrgitmType == "11" { //中成费
  20185. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20186. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20187. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20188. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20189. if item.ChrgitmLv == "1" {
  20190. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20191. }
  20192. if item.ChrgitmLv == "2" {
  20193. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20194. }
  20195. if item.ChrgitmLv == "3" {
  20196. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20197. }
  20198. }
  20199. if item.MedChrgitmType == "14" { //其他费
  20200. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20201. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20202. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20203. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20204. if item.ChrgitmLv == "1" {
  20205. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20206. }
  20207. if item.ChrgitmLv == "2" {
  20208. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20209. }
  20210. if item.ChrgitmLv == "3" {
  20211. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20212. }
  20213. }
  20214. }
  20215. var iteminfoStructs []service.IteminfoStruct
  20216. if bedCostTotal != 0 {
  20217. iteminfo.MedChrgitm = "01"
  20218. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20219. iteminfo.Amt = bedCostTotal
  20220. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20221. iteminfo.ClabAmt = bed_clab_amt
  20222. iteminfo.OthAmt = bed_other_amt
  20223. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20224. }
  20225. if checkCostTotal != 0 {
  20226. iteminfo.MedChrgitm = "03"
  20227. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20228. iteminfo.Amt = checkCostTotal
  20229. iteminfo.ClaaSumfee = check_claa_sunmfee
  20230. iteminfo.ClabAmt = check_clab_amt
  20231. iteminfo.OthAmt = check_other_amt
  20232. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20233. }
  20234. if laboratoryCostTotal != 0 {
  20235. iteminfo.MedChrgitm = "04"
  20236. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20237. iteminfo.Amt = laboratoryCostTotal
  20238. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20239. iteminfo.ClabAmt = laboratory_clab_amt
  20240. iteminfo.OthAmt = laboratory_other_amt
  20241. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20242. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20243. }
  20244. if treatCostTotal != 0 {
  20245. iteminfo.MedChrgitm = "05"
  20246. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20247. iteminfo.Amt = treatCostTotal
  20248. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20249. iteminfo.ClabAmt = treat_clab_amt
  20250. iteminfo.OthAmt = treat_other_amt
  20251. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20252. //(struct4101.IteminfoStruct, iteminfo)
  20253. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20254. }
  20255. if operationCostTotal != 0 {
  20256. iteminfo.MedChrgitm = "06"
  20257. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20258. iteminfo.Amt = operationCostTotal
  20259. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20260. iteminfo.ClabAmt = operation_clab_amt
  20261. iteminfo.OthAmt = operation_other_amt
  20262. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20263. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20264. }
  20265. if materialCostTotal != 0 {
  20266. iteminfo.MedChrgitm = "08"
  20267. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20268. iteminfo.Amt = materialCostTotal
  20269. iteminfo.ClaaSumfee = material_claa_sunmfee
  20270. iteminfo.ClabAmt = material_clab_amt
  20271. iteminfo.OthAmt = material_other_amt
  20272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20273. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20274. }
  20275. if westernMedicineCostTotal != 0 {
  20276. iteminfo.MedChrgitm = "09"
  20277. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20278. iteminfo.Amt = westernMedicineCostTotal
  20279. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20280. iteminfo.ClabAmt = westernMedicine_clab_amt
  20281. iteminfo.OthAmt = westernMedicine_other_amt
  20282. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20284. }
  20285. if chineseTraditionalMedicineCostTotal != 0 {
  20286. iteminfo.MedChrgitm = "11"
  20287. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20288. iteminfo.Amt = westernMedicineCostTotal
  20289. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20290. iteminfo.ClabAmt = westernMedicine_clab_amt
  20291. iteminfo.OthAmt = westernMedicine_other_amt
  20292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20293. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20294. }
  20295. if otherCostTotal != 0 {
  20296. iteminfo.MedChrgitm = "14"
  20297. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20298. iteminfo.Amt = otherCostTotal
  20299. iteminfo.ClaaSumfee = other_claa_sunmfee
  20300. iteminfo.ClabAmt = other_clab_amt
  20301. iteminfo.OthAmt = other_other_amt
  20302. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20303. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20304. }
  20305. struct4101.IteminfoStruct = iteminfoStructs
  20306. struct4101.Ntly = "中国"
  20307. struct4101.AdmCaty = "A03.06"
  20308. var resOther ResultSeventeenOther
  20309. var res ResultSeventeen
  20310. if miConfig.MdtrtareaAdmvs == "150499" {
  20311. var pp models.PublicParams
  20312. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20313. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20314. pp.FixmedinsName = miConfig.OrgName
  20315. pp.FixmedinsCode = miConfig.Code
  20316. pp.RequestUrl = miConfig.Url
  20317. pp.Cainfo = miConfig.Cainfo
  20318. pp.SecretKey = miConfig.SecretKey
  20319. pp.AccessKey = miConfig.AccessKey
  20320. pp.OpterName = curRoles.UserName
  20321. client := &http.Client{}
  20322. var req *http.Request
  20323. data := make(map[string]interface{})
  20324. data["struct4101"] = struct4101
  20325. data["pp"] = pp
  20326. bytesData, _ := json.Marshal(data)
  20327. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20328. resp, _ := client.Do(req)
  20329. defer resp.Body.Close()
  20330. body, ioErr := ioutil.ReadAll(resp.Body)
  20331. if ioErr != nil {
  20332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20334. return
  20335. }
  20336. var respJSON map[string]interface{}
  20337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20340. return
  20341. }
  20342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20343. userJSONBytes, _ := json.Marshal(respJSON)
  20344. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20345. utils.ErrorLog("解析失败:%v", err)
  20346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20347. return
  20348. }
  20349. res.InfRefmsgid = resOther.InfRefmsgid
  20350. res.Output = resOther.Output
  20351. res.ErrMsg = resOther.ErrMsg
  20352. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20353. res.Infcode = infocode
  20354. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20355. var pp models.PublicParams
  20356. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20357. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20358. pp.FixmedinsName = miConfig.OrgName
  20359. pp.FixmedinsCode = miConfig.Code
  20360. pp.RequestUrl = miConfig.Url
  20361. pp.Cainfo = miConfig.Cainfo
  20362. pp.SecretKey = miConfig.SecretKey
  20363. pp.AccessKey = miConfig.AccessKey
  20364. pp.OpterName = curRoles.UserName
  20365. result, _ := service.Jxyb4101(struct4101, pp)
  20366. var dat map[string]interface{}
  20367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20368. fmt.Println(dat)
  20369. } else {
  20370. fmt.Println(err)
  20371. }
  20372. userJSONBytes, _ := json.Marshal(dat)
  20373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20374. utils.ErrorLog("解析失败:%v", err)
  20375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20376. return
  20377. }
  20378. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20379. var pp models.PublicParams
  20380. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20381. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20382. pp.FixmedinsName = miConfig.OrgName
  20383. pp.FixmedinsCode = miConfig.Code
  20384. pp.RequestUrl = miConfig.Url
  20385. pp.Cainfo = miConfig.Cainfo
  20386. pp.SecretKey = miConfig.SecretKey
  20387. pp.AccessKey = miConfig.AccessKey
  20388. pp.OpterName = curRoles.UserName
  20389. result, _ := service.Jxyb4101(struct4101, pp)
  20390. var dat map[string]interface{}
  20391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20392. fmt.Println(dat)
  20393. } else {
  20394. fmt.Println(err)
  20395. }
  20396. userJSONBytes, _ := json.Marshal(dat)
  20397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20398. utils.ErrorLog("解析失败:%v", err)
  20399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20400. return
  20401. }
  20402. } else {
  20403. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20404. var dat map[string]interface{}
  20405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20406. fmt.Println(dat)
  20407. } else {
  20408. fmt.Println(err)
  20409. }
  20410. userJSONBytes, _ := json.Marshal(dat)
  20411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20412. utils.ErrorLog("解析失败:%v", err)
  20413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20414. return
  20415. }
  20416. }
  20417. if res.Infcode != 0 {
  20418. c.ServeSuccessJSON(map[string]interface{}{
  20419. "failed_code": -10,
  20420. "msg": res.ErrMsg,
  20421. })
  20422. return
  20423. } else {
  20424. if miConfig.MdtrtareaAdmvs != "150499" {
  20425. order.FaPiaoNumber = zero
  20426. order.FaPiaoCode = last_order.FaPiaoCode
  20427. service.UpdateOrder(order)
  20428. }
  20429. hisFundSettleListResult := &models.HisFundSettleListResult{
  20430. Number: res.Output.SetlListId,
  20431. Status: 1,
  20432. Ctime: time.Now().Unix(),
  20433. Mtime: time.Now().Unix(),
  20434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20435. IsUpload: 1,
  20436. OrderId: order_id,
  20437. }
  20438. service.CreateUploadRecord(hisFundSettleListResult)
  20439. c.ServeSuccessJSON(map[string]interface{}{
  20440. "msg": "上传成功",
  20441. "result": hisFundSettleListResult,
  20442. })
  20443. return
  20444. }
  20445. }
  20446. //func (c *HisApiController) GetBatchSettleList() {
  20447. // orders, _ := service.GetAllHisOrder(10106)
  20448. // for _, item := range orders {
  20449. // order_id := item.ID
  20450. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20451. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20452. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20453. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20454. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20455. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20456. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20457. //
  20458. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20459. //
  20460. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20461. //
  20462. // if order.ID == 0 {
  20463. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20464. // return
  20465. // }
  20466. // if his.BalanceAccountsType == 2 {
  20467. // continue
  20468. // }
  20469. // struct4101 := service.Struct4101{
  20470. // PsnNo: order.PsnNo,
  20471. // MdtrtId: order.MdtrtId,
  20472. // SetlId: order.SetlId,
  20473. // PsnName: order.PsnName,
  20474. // Gend: order.Gend,
  20475. // Brdy: his.Brdy,
  20476. // Age: his.Age,
  20477. // Naty: order.Naty,
  20478. // PatnCertType: "01",
  20479. // Certno: order.Certno,
  20480. // Prfs: "90",
  20481. // ConerName: roles[0].UserName,
  20482. // PatnRlts: "99",
  20483. // ConerAddr: miConfig.OrgName,
  20484. // ConerTel: admin.Mobile,
  20485. // HiType: order.Insutype,
  20486. // Insuplc: his.InsuplcAdmdvs,
  20487. // MaindiagFlag: "1",
  20488. // BillCode: order.SetlId,
  20489. // BillNo: order.SetlId,
  20490. // BizSn: order.Number,
  20491. // PsnSelfPay: order.PsnPartAmt,
  20492. // PsnOwnPay: order.PsnPartAmt,
  20493. // AcctPay: order.AcctPay,
  20494. // PsnCashpay: order.PsnCashPay,
  20495. // HiPaymtd: "1",
  20496. // Hsorg: his.InsuplcAdmdvs,
  20497. // HsorgOpter: his.InsuplcAdmdvs,
  20498. // MedinsFillPsn: curRoles.UserName,
  20499. // MedinsFillDept: depart.Name,
  20500. // IptMedType: "2",
  20501. // }
  20502. // struct4101.SetlBegnDate = order.SetlTime
  20503. // struct4101.SetlEndDate = order.SetlTime
  20504. // //if order.SettleType == 1 {
  20505. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20506. // // dateStr := t.Format("2006-01-02")
  20507. // // struct4101.SetlBegnDate = dateStr
  20508. // // struct4101.SetlEndDate = dateStr
  20509. // //} else {
  20510. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20511. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20512. // // dateStartStr := t.Format("2006-01-02")
  20513. // // dateEndStr := t2.Format("2006-01-02")
  20514. // // struct4101.SetlBegnDate = dateStartStr
  20515. // // struct4101.SetlEndDate = dateEndStr
  20516. // //}
  20517. //
  20518. // var rf []CustomFundPay
  20519. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20520. //
  20521. // var tempFunPays []service.CustomStruct
  20522. // var tempFunPay610100 service.CustomStruct
  20523. //
  20524. // for _, item := range rf {
  20525. // if item.FundPayType == "610100" {
  20526. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20527. // tempFunPay610100.FundPayType = item.FundPayType
  20528. // } else {
  20529. // var tempFunPay service.CustomStruct
  20530. // tempFunPay.FundPayamt = item.FundPayamt
  20531. // tempFunPay.FundPayType = item.FundPayType
  20532. // tempFunPays = append(tempFunPays, tempFunPay)
  20533. // }
  20534. // }
  20535. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20536. // struct4101.CustomStruct = tempFunPays
  20537. //
  20538. // var tempDiaginfos []service.DiaginfoStructTwo
  20539. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20540. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20541. //
  20542. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20543. // var config []*models.HisXtDiagnoseConfig
  20544. // for _, item := range diagnosis_ids {
  20545. // id, _ := strconv.ParseInt(item, 10, 64)
  20546. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20547. // config = append(config, &diagnosisConfig)
  20548. // }
  20549. //
  20550. // for index, item := range config {
  20551. // if index == 0 {
  20552. // var tempDiaginfo service.DiaginfoStructTwo
  20553. // tempDiaginfo.DiagCode = item.CountryCode
  20554. // tempDiaginfo.DiagName = item.CountryContentName
  20555. // tempDiaginfo.DiagType = "1"
  20556. // tempDiaginfo.MaindiagFlag = "1"
  20557. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20558. // } else {
  20559. //
  20560. // var tempDiaginfo service.DiaginfoStructTwo
  20561. // tempDiaginfo.DiagCode = item.CountryCode
  20562. // tempDiaginfo.DiagName = item.CountryContentName
  20563. // tempDiaginfo.DiagType = "2"
  20564. // tempDiaginfo.MaindiagFlag = "0"
  20565. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20566. // }
  20567. // }
  20568. // struct4101.Diseinfo = tempDiaginfos
  20569. //
  20570. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20571. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20572. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20573. // tempOpspdiseinfo2.OprnOprtCode = ""
  20574. // tempOpspdiseinfo2.OprnOprtName = ""
  20575. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20576. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20577. //
  20578. // var iteminfo service.IteminfoStruct
  20579. //
  20580. // var bedCostTotal float64 = 0 //床位总费
  20581. // var bedCostSelfTotal float64 = 0 //床位自费
  20582. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20583. //
  20584. // var examineCostTotal float64 = 0 //诊查总费
  20585. // var examineCostSelfTotal float64 = 0 //诊查自费
  20586. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20587. //
  20588. // var nursingCostTotal float64 = 0 //护理总费
  20589. // var nursingCostSelfTotal float64 = 0 //护理自费
  20590. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20591. //
  20592. // var chineseMedicineCostTotal float64 = 0 //中成药
  20593. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20594. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20595. //
  20596. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20597. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20598. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20599. //
  20600. // var registerCostTotal float64 = 0 //一般诊疗费
  20601. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20602. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20603. //
  20604. // var operationCostTotal float64 = 0 //手术费
  20605. // var operationCostSelfTotal float64 = 0 //手术费
  20606. // var operationCostPartSelfTotal float64 = 0 //手术费
  20607. //
  20608. // var otherCostTotal float64 = 0 //其他费用
  20609. // var otherCostSelfTotal float64 = 0 //其他费用
  20610. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20611. //
  20612. // var materialCostTotal float64 = 0 //材料费
  20613. // var materialCostSelfTotal float64 = 0 //材料费
  20614. // var materialCostPartSelfTotal float64 = 0 //材料费
  20615. //
  20616. // var westernMedicineCostTotal float64 = 0 //西药费
  20617. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20618. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20619. //
  20620. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20621. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20622. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20623. //
  20624. // var checkCostTotal float64 = 0 //检查费
  20625. // var checkCostSelfTotal float64 = 0 //检查费
  20626. // var checkCostPartSelfTotal float64 = 0 //检查费
  20627. //
  20628. // var laboratoryCostTotal float64 = 0 //化验费
  20629. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20630. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20631. //
  20632. // var treatCostTotal float64 = 0 //治疗费用
  20633. // var treatCostSelfTotal float64 = 0 //治疗费用
  20634. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20635. //
  20636. // decimal.DivisionPrecision = 2
  20637. //
  20638. // var bed_fulamt_ownpay_amt float64 = 0
  20639. //
  20640. // var examine_fulamt_ownpay_amt float64 = 0
  20641. //
  20642. // var nursing_fulamt_ownpay_amt float64 = 0
  20643. //
  20644. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20645. //
  20646. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20647. //
  20648. // var register_fulamt_ownpay_amt float64 = 0
  20649. //
  20650. // var operation_fulamt_ownpay_amt float64 = 0
  20651. // var other_fulamt_ownpay_amt float64 = 0
  20652. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20653. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20654. // var check_fulamt_ownpay_amt float64 = 0
  20655. // var material_fulamt_ownpay_amt float64 = 0
  20656. // var laboratory_fulamt_ownpay_amt float64 = 0
  20657. // var treat_fulamt_ownpay_amt float64 = 0
  20658. //
  20659. // var bed_claa_sunmfee float64 = 0
  20660. // var bed_clab_amt float64 = 0
  20661. // var bed_other_amt float64 = 0
  20662. //
  20663. // var examine_claa_sunmfee float64 = 0
  20664. // var examine_clab_amt float64 = 0
  20665. // var examine_other_amt float64 = 0
  20666. //
  20667. // var nursing_claa_sunmfee float64 = 0
  20668. // var nursing_clab_amt float64 = 0
  20669. // var nursing_other_amt float64 = 0
  20670. //
  20671. // var chinese_medicine_claa_sunmfee float64 = 0
  20672. // var chinese_medicine_clab_amt float64 = 0
  20673. // var chinese_medicine_other_amt float64 = 0
  20674. //
  20675. // var commonly_treatment_claa_sunmfee float64 = 0
  20676. // var commonly_treatment_clab_amt float64 = 0
  20677. // var commonly_treatment_other_amt float64 = 0
  20678. //
  20679. // var operation_claa_sunmfee float64 = 0
  20680. // var operation_clab_amt float64 = 0
  20681. // var operation_other_amt float64 = 0
  20682. //
  20683. // var other_claa_sunmfee float64 = 0
  20684. // var other_clab_amt float64 = 0
  20685. // var other_other_amt float64 = 0
  20686. //
  20687. // var westernMedicine_claa_sunmfee float64 = 0
  20688. // var westernMedicine_clab_amt float64 = 0
  20689. // var westernMedicine_other_amt float64 = 0
  20690. //
  20691. // var chineseTraditional_claa_sunmfee float64 = 0
  20692. // var chineseTraditional_clab_amt float64 = 0
  20693. // var chineseTraditional_other_amt float64 = 0
  20694. //
  20695. // var check_claa_sunmfee float64 = 0
  20696. // var check_clab_amt float64 = 0
  20697. // var check_other_amt float64 = 0
  20698. //
  20699. // var material_claa_sunmfee float64 = 0
  20700. // var material_clab_amt float64 = 0
  20701. // var material_other_amt float64 = 0
  20702. //
  20703. // var laboratory_claa_sunmfee float64 = 0
  20704. // var laboratory_clab_amt float64 = 0
  20705. // var laboratory_other_amt float64 = 0
  20706. //
  20707. // var treat_claa_sunmfee float64 = 0
  20708. // var treat_clab_amt float64 = 0
  20709. // var treat_other_amt float64 = 0
  20710. //
  20711. // var register_claa_sunmfee float64 = 0
  20712. // var register_clab_amt float64 = 0
  20713. // var register_other_amt float64 = 0
  20714. //
  20715. // for _, item := range order.HisOrderInfo {
  20716. // if item.MedChrgitmType == "01" { //床位费
  20717. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20718. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20719. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20720. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20721. // if item.ChrgitmLv == "1" {
  20722. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20723. // }
  20724. // if item.ChrgitmLv == "2" {
  20725. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20726. //
  20727. // }
  20728. // if item.ChrgitmLv == "3" {
  20729. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20730. // }
  20731. //
  20732. // }
  20733. //
  20734. // if item.MedChrgitmType == "02" { //诊查
  20735. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20736. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20737. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20738. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20739. // if item.ChrgitmLv == "1" {
  20740. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20741. // }
  20742. // if item.ChrgitmLv == "2" {
  20743. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20744. //
  20745. // }
  20746. // if item.ChrgitmLv == "3" {
  20747. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20748. // }
  20749. //
  20750. // }
  20751. //
  20752. // if item.MedChrgitmType == "03" { //检查费
  20753. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20754. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20755. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20756. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20757. // if item.ChrgitmLv == "1" {
  20758. //
  20759. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20760. //
  20761. // }
  20762. // if item.ChrgitmLv == "2" {
  20763. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20764. //
  20765. // }
  20766. // if item.ChrgitmLv == "3" {
  20767. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20768. // }
  20769. // }
  20770. //
  20771. // if item.MedChrgitmType == "04" { //化验费
  20772. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20773. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20774. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20775. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20776. // if item.ChrgitmLv == "1" {
  20777. //
  20778. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20779. //
  20780. // }
  20781. // if item.ChrgitmLv == "2" {
  20782. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20783. //
  20784. // }
  20785. // if item.ChrgitmLv == "3" {
  20786. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20787. // }
  20788. // }
  20789. //
  20790. // if item.MedChrgitmType == "05" { //治疗费
  20791. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20792. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20793. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20794. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20795. // if item.ChrgitmLv == "1" {
  20796. //
  20797. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20798. //
  20799. // }
  20800. // if item.ChrgitmLv == "2" {
  20801. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20802. //
  20803. // }
  20804. // if item.ChrgitmLv == "3" {
  20805. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20806. // }
  20807. // }
  20808. //
  20809. // if item.MedChrgitmType == "06" { //手术费
  20810. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20811. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20812. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20813. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20814. //
  20815. // if item.ChrgitmLv == "1" {
  20816. //
  20817. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20818. //
  20819. // }
  20820. // if item.ChrgitmLv == "2" {
  20821. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20822. //
  20823. // }
  20824. // if item.ChrgitmLv == "3" {
  20825. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20826. // }
  20827. // }
  20828. //
  20829. // if item.MedChrgitmType == "07" { //手术费
  20830. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20831. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20832. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20833. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20834. //
  20835. // if item.ChrgitmLv == "1" {
  20836. //
  20837. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20838. //
  20839. // }
  20840. // if item.ChrgitmLv == "2" {
  20841. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20842. //
  20843. // }
  20844. // if item.ChrgitmLv == "3" {
  20845. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20846. // }
  20847. // }
  20848. //
  20849. // if item.MedChrgitmType == "08" { //材料费
  20850. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20851. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20852. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20853. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20854. // if item.ChrgitmLv == "1" {
  20855. //
  20856. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20857. //
  20858. // }
  20859. // if item.ChrgitmLv == "2" {
  20860. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20861. //
  20862. // }
  20863. // if item.ChrgitmLv == "3" {
  20864. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20865. // }
  20866. // }
  20867. // if item.MedChrgitmType == "09" { //西药费
  20868. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20869. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20870. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20871. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20872. // if item.ChrgitmLv == "1" {
  20873. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20874. // }
  20875. // if item.ChrgitmLv == "2" {
  20876. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20877. // }
  20878. // if item.ChrgitmLv == "3" {
  20879. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20880. // }
  20881. // }
  20882. // if item.MedChrgitmType == "10" { //中药饮片
  20883. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20884. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20885. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20886. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20887. // if item.ChrgitmLv == "1" {
  20888. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20889. // }
  20890. // if item.ChrgitmLv == "2" {
  20891. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20892. // }
  20893. // if item.ChrgitmLv == "3" {
  20894. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20895. // }
  20896. // }
  20897. //
  20898. // if item.MedChrgitmType == "11" { //中成费
  20899. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20900. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20901. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20902. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20903. // if item.ChrgitmLv == "1" {
  20904. //
  20905. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20906. //
  20907. // }
  20908. // if item.ChrgitmLv == "2" {
  20909. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20910. //
  20911. // }
  20912. // if item.ChrgitmLv == "3" {
  20913. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20914. // }
  20915. // }
  20916. //
  20917. // if item.MedChrgitmType == "12" { //中成费
  20918. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20919. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20920. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20921. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20922. // if item.ChrgitmLv == "1" {
  20923. //
  20924. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20925. //
  20926. // }
  20927. // if item.ChrgitmLv == "2" {
  20928. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20929. //
  20930. // }
  20931. // if item.ChrgitmLv == "3" {
  20932. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20933. // }
  20934. // }
  20935. //
  20936. // if item.MedChrgitmType == "13" { //中成费
  20937. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20938. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20939. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20940. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20941. // if item.ChrgitmLv == "1" {
  20942. //
  20943. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20944. //
  20945. // }
  20946. // if item.ChrgitmLv == "2" {
  20947. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20948. //
  20949. // }
  20950. // if item.ChrgitmLv == "3" {
  20951. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20952. // }
  20953. // }
  20954. //
  20955. // if item.MedChrgitmType == "14" { //其他费
  20956. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20957. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20958. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20959. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20960. // if item.ChrgitmLv == "1" {
  20961. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20962. //
  20963. // }
  20964. // if item.ChrgitmLv == "2" {
  20965. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20966. //
  20967. // }
  20968. // if item.ChrgitmLv == "3" {
  20969. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20970. // }
  20971. // }
  20972. //
  20973. // }
  20974. //
  20975. // var iteminfoStructs []service.IteminfoStruct
  20976. //
  20977. // if bedCostTotal != 0 {
  20978. // iteminfo.MedChrgitm = "01"
  20979. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20980. // iteminfo.Amt = bedCostTotal
  20981. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20982. // iteminfo.ClabAmt = bed_clab_amt
  20983. // iteminfo.OthAmt = bed_other_amt
  20984. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20985. // }
  20986. //
  20987. // if examineCostTotal != 0 {
  20988. // iteminfo.MedChrgitm = "02"
  20989. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20990. // iteminfo.Amt = examineCostTotal
  20991. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20992. // iteminfo.ClabAmt = examine_clab_amt
  20993. // iteminfo.OthAmt = examine_other_amt
  20994. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20995. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20996. // }
  20997. //
  20998. // if checkCostTotal != 0 {
  20999. // iteminfo.MedChrgitm = "03"
  21000. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21001. // iteminfo.Amt = checkCostTotal
  21002. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21003. // iteminfo.ClabAmt = check_clab_amt
  21004. // iteminfo.OthAmt = check_other_amt
  21005. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21006. //
  21007. // }
  21008. //
  21009. // if laboratoryCostTotal != 0 {
  21010. // iteminfo.MedChrgitm = "04"
  21011. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21012. // iteminfo.Amt = laboratoryCostTotal
  21013. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21014. // iteminfo.ClabAmt = laboratory_clab_amt
  21015. // iteminfo.OthAmt = laboratory_other_amt
  21016. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21017. //
  21018. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21019. //
  21020. // }
  21021. //
  21022. // if treatCostTotal != 0 {
  21023. // iteminfo.MedChrgitm = "05"
  21024. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21025. // iteminfo.Amt = treatCostTotal
  21026. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21027. // iteminfo.ClabAmt = treat_clab_amt
  21028. // iteminfo.OthAmt = treat_other_amt
  21029. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21030. // //(struct4101.IteminfoStruct, iteminfo)
  21031. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21032. // }
  21033. //
  21034. // if operationCostTotal != 0 {
  21035. // iteminfo.MedChrgitm = "06"
  21036. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21037. // iteminfo.Amt = operationCostTotal
  21038. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21039. // iteminfo.ClabAmt = operation_clab_amt
  21040. // iteminfo.OthAmt = operation_other_amt
  21041. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21042. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21043. // }
  21044. //
  21045. // if nursingCostTotal != 0 {
  21046. // iteminfo.MedChrgitm = "07"
  21047. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21048. // iteminfo.Amt = nursingCostTotal
  21049. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21050. // iteminfo.ClabAmt = nursing_clab_amt
  21051. // iteminfo.OthAmt = nursing_other_amt
  21052. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21053. // }
  21054. //
  21055. // if materialCostTotal != 0 {
  21056. // iteminfo.MedChrgitm = "08"
  21057. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21058. // iteminfo.Amt = materialCostTotal
  21059. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21060. // iteminfo.ClabAmt = material_clab_amt
  21061. // iteminfo.OthAmt = material_other_amt
  21062. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21063. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21064. // }
  21065. //
  21066. // if westernMedicineCostTotal != 0 {
  21067. // iteminfo.MedChrgitm = "09"
  21068. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21069. // iteminfo.Amt = westernMedicineCostTotal
  21070. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21071. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21072. // iteminfo.OthAmt = westernMedicine_other_amt
  21073. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21074. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21075. //
  21076. // }
  21077. //
  21078. // if chineseMedicineCostTotal != 0 {
  21079. // iteminfo.MedChrgitm = "10"
  21080. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21081. // iteminfo.Amt = chineseMedicineCostTotal
  21082. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21083. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21084. // iteminfo.OthAmt = chinese_medicine_other_amt
  21085. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21086. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21087. //
  21088. // }
  21089. //
  21090. // if chineseTraditionalMedicineCostTotal != 0 {
  21091. // iteminfo.MedChrgitm = "11"
  21092. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21093. // iteminfo.Amt = westernMedicineCostTotal
  21094. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21095. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21096. // iteminfo.OthAmt = westernMedicine_other_amt
  21097. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21098. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21099. //
  21100. // }
  21101. //
  21102. // if commonlyTreatmentCostTotal != 0 {
  21103. // iteminfo.MedChrgitm = "12"
  21104. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21105. // iteminfo.Amt = commonlyTreatmentCostTotal
  21106. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21107. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21108. // iteminfo.OthAmt = commonly_treatment_other_amt
  21109. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21110. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21111. //
  21112. // }
  21113. //
  21114. // if registerCostTotal != 0 {
  21115. // iteminfo.MedChrgitm = "13"
  21116. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21117. // iteminfo.Amt = registerCostTotal
  21118. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21119. // iteminfo.ClabAmt = register_clab_amt
  21120. // iteminfo.OthAmt = register_other_amt
  21121. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21122. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21123. //
  21124. // }
  21125. //
  21126. // if otherCostTotal != 0 {
  21127. // iteminfo.MedChrgitm = "14"
  21128. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21129. // iteminfo.Amt = otherCostTotal
  21130. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21131. // iteminfo.ClabAmt = other_clab_amt
  21132. // iteminfo.OthAmt = other_other_amt
  21133. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21134. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21135. //
  21136. // }
  21137. // struct4101.IteminfoStruct = iteminfoStructs
  21138. // time_arr := strings.Split(order.SetlTime, " ")
  21139. // struct4101.AdmTime = time_arr[0]
  21140. // struct4101.AdmEndTime = time_arr[0]
  21141. //
  21142. // struct4101.DoctorName = doctor.UserName
  21143. // struct4101.DoctorCode = doctor.DoctorNumber
  21144. //
  21145. // struct4101.Ntly = "中国"
  21146. // struct4101.AdmCaty = "A03.06"
  21147. // var res ResultSeventeen
  21148. // if miConfig.MdtrtareaAdmvs == "421300" {
  21149. // data := make(map[string]interface{})
  21150. // data["struct4101"] = struct4101
  21151. // data["secret_key"] = miConfig.SecretKey
  21152. // data["org_name"] = miConfig.OrgName
  21153. // data["opera"] = curRoles.UserName
  21154. // data["code"] = miConfig.Code
  21155. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21156. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21157. //
  21158. // client := &http.Client{}
  21159. // bytesData, _ := json.Marshal(data)
  21160. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21161. // resp, _ := client.Do(req)
  21162. // defer resp.Body.Close()
  21163. // body, ioErr := ioutil.ReadAll(resp.Body)
  21164. // if ioErr != nil {
  21165. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21167. // return
  21168. // }
  21169. // var respJSON map[string]interface{}
  21170. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21171. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21173. // return
  21174. // }
  21175. //
  21176. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21177. // userJSONBytes, _ := json.Marshal(respJSON)
  21178. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21179. // utils.ErrorLog("解析失败:%v", err)
  21180. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21181. // adminUser := c.GetAdminUserInfo()
  21182. // errlog := &models.HisOrderError{
  21183. // UserOrgId: adminUser.CurrentOrgId,
  21184. // Ctime: time.Now().Unix(),
  21185. // Mtime: time.Now().Unix(),
  21186. // ErrMsg: res.ErrMsg + "解析失败",
  21187. // Status: 1,
  21188. // PatientId: order_id,
  21189. // Stage: 10088,
  21190. // }
  21191. // service.CreateErrMsgLog(errlog)
  21192. // continue
  21193. // }
  21194. //
  21195. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21196. // data := make(map[string]interface{})
  21197. // data["struct4101"] = struct4101
  21198. // data["secret_key"] = miConfig.SecretKey
  21199. // data["org_name"] = miConfig.OrgName
  21200. // data["opera"] = curRoles.UserName
  21201. // data["code"] = miConfig.Code
  21202. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21203. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21204. //
  21205. // client := &http.Client{}
  21206. // bytesData, _ := json.Marshal(data)
  21207. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21208. // resp, _ := client.Do(req)
  21209. // defer resp.Body.Close()
  21210. // body, ioErr := ioutil.ReadAll(resp.Body)
  21211. // if ioErr != nil {
  21212. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21214. // return
  21215. // }
  21216. // var respJSON map[string]interface{}
  21217. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21218. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21220. // return
  21221. // }
  21222. //
  21223. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21224. // userJSONBytes, _ := json.Marshal(respJSON)
  21225. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21226. // utils.ErrorLog("解析失败:%v", err)
  21227. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21228. // adminUser := c.GetAdminUserInfo()
  21229. // errlog := &models.HisOrderError{
  21230. // UserOrgId: adminUser.CurrentOrgId,
  21231. // Ctime: time.Now().Unix(),
  21232. // Mtime: time.Now().Unix(),
  21233. // ErrMsg: res.ErrMsg + "解析失败",
  21234. // Status: 1,
  21235. // PatientId: order_id,
  21236. // Stage: 10088,
  21237. // }
  21238. // service.CreateErrMsgLog(errlog)
  21239. // continue
  21240. // }
  21241. //
  21242. // } else {
  21243. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21244. // fmt.Println(result)
  21245. //
  21246. // var dat map[string]interface{}
  21247. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21248. // fmt.Println(dat)
  21249. // } else {
  21250. // fmt.Println(err)
  21251. // }
  21252. // userJSONBytes, _ := json.Marshal(dat)
  21253. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21254. // utils.ErrorLog("解析失败:%v", err)
  21255. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21256. // adminUser := c.GetAdminUserInfo()
  21257. // errlog := &models.HisOrderError{
  21258. // UserOrgId: adminUser.CurrentOrgId,
  21259. // Ctime: time.Now().Unix(),
  21260. // Mtime: time.Now().Unix(),
  21261. // ErrMsg: res.ErrMsg + "解析失败",
  21262. // Status: 1,
  21263. // PatientId: order_id,
  21264. // Stage: 10106,
  21265. // }
  21266. // service.CreateErrMsgLog(errlog)
  21267. // continue
  21268. // }
  21269. // }
  21270. //
  21271. // if res.Infcode != 0 {
  21272. // adminUser := c.GetAdminUserInfo()
  21273. // errlog := &models.HisOrderError{
  21274. // UserOrgId: adminUser.CurrentOrgId,
  21275. // Ctime: time.Now().Unix(),
  21276. // Mtime: time.Now().Unix(),
  21277. // ErrMsg: res.ErrMsg,
  21278. // Status: 1,
  21279. // PatientId: order_id,
  21280. // Stage: 10106,
  21281. // }
  21282. // service.CreateErrMsgLog(errlog)
  21283. // continue
  21284. // } else {
  21285. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21286. // Number: res.Output.SetlListId,
  21287. // Status: 1,
  21288. // Ctime: time.Now().Unix(),
  21289. // Mtime: time.Now().Unix(),
  21290. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21291. // IsUpload: 1,
  21292. // OrderId: order_id,
  21293. // }
  21294. // service.CreateUploadRecord(hisFundSettleListResult)
  21295. // continue
  21296. // }
  21297. // }
  21298. //}
  21299. func (c *HisApiController) GetOrgInfo() {
  21300. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21301. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21302. }
  21303. func (c *HisApiController) GetHisPatientInfo() {
  21304. medical_insurance_card := c.GetString("medical_insurance_card")
  21305. id_card_type, _ := c.GetInt64("id_card_type")
  21306. id_card := c.GetString("id_card")
  21307. adminInfo := c.GetAdminUserInfo()
  21308. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21309. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21310. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21311. IdCardNo := ""
  21312. if id_card_type == 1 {
  21313. IdCardNo = medical_insurance_card
  21314. } else if id_card_type == 2 {
  21315. IdCardNo = id_card
  21316. }
  21317. if config.IsOpen == 1 {
  21318. 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
  21319. resp, requestErr := http.Get(api)
  21320. if requestErr != nil {
  21321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21322. return
  21323. }
  21324. defer resp.Body.Close()
  21325. body, ioErr := ioutil.ReadAll(resp.Body)
  21326. if ioErr != nil {
  21327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21329. return
  21330. }
  21331. var respJSON map[string]interface{}
  21332. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21335. return
  21336. }
  21337. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21338. userJSONBytes, _ := json.Marshal(userJSON)
  21339. var res ResultTwo
  21340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21341. utils.ErrorLog("解析失败:%v", err)
  21342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21343. return
  21344. }
  21345. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21346. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21347. infoStr := string(Iinfos)
  21348. idetinfoStr := string(Idetinfos)
  21349. if res.Infcode == 0 {
  21350. his := models.VMHisPatient{
  21351. Status: 1,
  21352. Ctime: time.Now().Unix(),
  21353. Mtime: time.Now().Unix(),
  21354. PsnNo: res.Output.Baseinfo.PsnNo,
  21355. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21356. Certno: res.Output.Baseinfo.Certno,
  21357. PsnName: res.Output.Baseinfo.PsnName,
  21358. Gend: res.Output.Baseinfo.Gend,
  21359. Naty: res.Output.Baseinfo.Naty,
  21360. Iinfo: infoStr,
  21361. Idetinfo: idetinfoStr,
  21362. UserOrgId: adminInfo.CurrentOrgId,
  21363. IsReturn: 1,
  21364. IdCardType: id_card_type,
  21365. }
  21366. c.ServeSuccessJSON(map[string]interface{}{
  21367. "info": his,
  21368. })
  21369. } else {
  21370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21371. return
  21372. }
  21373. }
  21374. }
  21375. //func GetBasBaseInfo() (jsonStr string, err error) {
  21376. //
  21377. // handle := syscall.NewLazyDLL("SSCard.dll")
  21378. // add := handle.NewProc("ReadCardBas")
  21379. // str := make([]byte, 1024)
  21380. // str1 := make([]byte, 1024)
  21381. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21382. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21383. //
  21384. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21385. //
  21386. // fmt.Println("> Add(4,5)的结果为:", ret)
  21387. // handle.Release()
  21388. //
  21389. // return "", nil
  21390. //
  21391. //}
  21392. //func GetQRBaseInfo() (jsonStr string, err error) {
  21393. // handle := syscall.LoadDLL("SSCard.dll")
  21394. // ReadCardBas := handle.FindProc("GetQRBase")
  21395. //
  21396. // str := make([]byte, 256)
  21397. // str1 := make([]byte, 256)
  21398. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21399. //
  21400. // fmt.Println(string(str))
  21401. // fmt.Println(r)
  21402. // return string(str), nil
  21403. //}
  21404. //func CardInit() int {
  21405. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21406. // add := DllTestDef.MustFindProc("Init")
  21407. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21408. // if err != nil {
  21409. // fmt.Println("SSCard的运算结果为:", ret)
  21410. // }
  21411. // result := int(ret)
  21412. // return result
  21413. //}
  21414. //func CardInit() int {
  21415. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21416. // if err != nil {
  21417. // fmt.Println("SSCard的运算结果为:", ret)
  21418. // }
  21419. // fmt.Println(err)
  21420. // result := int(ret)
  21421. // return result
  21422. //}
  21423. func IntPtr(n int) uintptr {
  21424. return uintptr(n)
  21425. }
  21426. func StrPtr(s string) uintptr {
  21427. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21428. }
  21429. type Result2001 struct {
  21430. Cainfo interface{} `json:"cainfo"`
  21431. ErrMsg string `json:"err_msg"`
  21432. InfRefmsgid string `json:"inf_refmsgid"`
  21433. Infcode int64 `json:"infcode"`
  21434. Output struct {
  21435. Trtinfo struct {
  21436. PsnNo string `json:"psn_no"`
  21437. TrtChkType string `json:"trt_chk_type"`
  21438. FundPayType string `json:"fund_pay_type"`
  21439. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21440. Begndate string `json:"begndate"`
  21441. Enddate string `json:"enddate"`
  21442. TrtChkRslt string `json:"trt_chk_rslt"`
  21443. } `json:"trtinfo"`
  21444. } `json:"output"`
  21445. RefmsgTime string `json:"refmsg_time"`
  21446. RespondTime string `json:"respond_time"`
  21447. Signtype interface{} `json:"signtype"`
  21448. WarnMsg interface{} `json:"warn_msg"`
  21449. }
  21450. type Result2001Org10265 struct {
  21451. Cainfo interface{} `json:"cainfo"`
  21452. ErrMsg string `json:"err_msg"`
  21453. InfRefmsgid string `json:"inf_refmsgid"`
  21454. Infcode string `json:"infcode"`
  21455. Output struct {
  21456. Trtinfo struct {
  21457. PsnNo string `json:"psn_no"`
  21458. TrtChkType string `json:"trt_chk_type"`
  21459. FundPayType string `json:"fund_pay_type"`
  21460. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21461. Begndate string `json:"begndate"`
  21462. Enddate string `json:"enddate"`
  21463. TrtChkRslt string `json:"trt_chk_rslt"`
  21464. } `json:"trtinfo"`
  21465. } `json:"output"`
  21466. RefmsgTime string `json:"refmsg_time"`
  21467. RespondTime string `json:"respond_time"`
  21468. Signtype interface{} `json:"signtype"`
  21469. WarnMsg interface{} `json:"warn_msg"`
  21470. }
  21471. type ResultTwo struct {
  21472. ErrMsg string `json:"err_msg"`
  21473. InfRefmsgid string `json:"inf_refmsgid"`
  21474. Infcode int64 `json:"infcode"`
  21475. Output struct {
  21476. Baseinfo struct {
  21477. //Brdy string `json:"brdy"`
  21478. Certno string `json:"certno"`
  21479. Gend string `json:"gend"`
  21480. Naty string `json:"naty"`
  21481. PsnCertType string `json:"psn_cert_type"`
  21482. PsnName string `json:"psn_name"`
  21483. PsnNo string `json:"psn_no"`
  21484. } `json:"baseinfo"`
  21485. Idetinfo []interface{} `json:"idetinfo"`
  21486. Iinfo []struct {
  21487. Balc float64 `json:"balc"`
  21488. CvlservFlag string `json:"cvlserv_flag"`
  21489. EmpName string `json:"emp_name"`
  21490. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21491. Insutype string `json:"insutype"`
  21492. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21493. //PausInsuDate string `json:"paus_insu_date"`
  21494. //PsnInsuDate string `json:"psn_insu_date"`
  21495. PsnInsuStas string `json:"psn_insu_stas"`
  21496. PsnType string `json:"psn_type"`
  21497. } `json:"insuinfo"`
  21498. } `json:"output"`
  21499. RefmsgTime string `json:"refmsg_time"`
  21500. RespondTime string `json:"respond_time"`
  21501. Signtype interface{} `json:"signtype"`
  21502. WarnInfo interface{} `json:"warn_info"`
  21503. }
  21504. type ResultTwo10265 struct {
  21505. ErrMsg string `json:"err_msg"`
  21506. InfRefmsgid string `json:"inf_refmsgid"`
  21507. Infcode string `json:"infcode"`
  21508. Output struct {
  21509. Baseinfo struct {
  21510. //Brdy string `json:"brdy"`
  21511. Certno string `json:"certno"`
  21512. Gend string `json:"gend"`
  21513. Naty string `json:"naty"`
  21514. PsnCertType string `json:"psn_cert_type"`
  21515. PsnName string `json:"psn_name"`
  21516. PsnNo string `json:"psn_no"`
  21517. } `json:"baseinfo"`
  21518. Idetinfo []interface{} `json:"idetinfo"`
  21519. Iinfo []struct {
  21520. Balc float64 `json:"balc"`
  21521. CvlservFlag string `json:"cvlserv_flag"`
  21522. EmpName string `json:"emp_name"`
  21523. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21524. Insutype string `json:"insutype"`
  21525. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21526. PsnInsuStas string `json:"psn_insu_stas"`
  21527. PsnType string `json:"psn_type"`
  21528. } `json:"insuinfo"`
  21529. } `json:"output"`
  21530. RefmsgTime string `json:"refmsg_time"`
  21531. RespondTime string `json:"respond_time"`
  21532. Signtype interface{} `json:"signtype"`
  21533. WarnInfo interface{} `json:"warn_info"`
  21534. }
  21535. type ResultThree struct {
  21536. Cainfo interface{} `json:"cainfo"`
  21537. ErrMsg string `json:"err_msg"`
  21538. InfRefmsgid string `json:"inf_refmsgid"`
  21539. Infcode int64 `json:"infcode"`
  21540. Output struct {
  21541. Data struct {
  21542. IptOtpNo string `json:"ipt_otp_no"`
  21543. MdtrtID string `json:"mdtrt_id"`
  21544. PsnNo string `json:"psn_no"`
  21545. } `json:"data"`
  21546. } `json:"output"`
  21547. RefmsgTime string `json:"refmsg_time"`
  21548. RespondTime string `json:"respond_time"`
  21549. Signtype interface{} `json:"signtype"`
  21550. WarnMsg interface{} `json:"warn_msg"`
  21551. }
  21552. type ResultThree10265 struct {
  21553. Cainfo interface{} `json:"cainfo"`
  21554. ErrMsg string `json:"err_msg"`
  21555. InfRefmsgid string `json:"inf_refmsgid"`
  21556. Infcode string `json:"infcode"`
  21557. Output struct {
  21558. Data struct {
  21559. IptOtpNo string `json:"ipt_otp_no"`
  21560. MdtrtID string `json:"mdtrt_id"`
  21561. PsnNo string `json:"psn_no"`
  21562. } `json:"data"`
  21563. } `json:"output"`
  21564. RefmsgTime string `json:"refmsg_time"`
  21565. RespondTime string `json:"respond_time"`
  21566. Signtype interface{} `json:"signtype"`
  21567. WarnMsg interface{} `json:"warn_msg"`
  21568. }
  21569. type ResultFour struct {
  21570. Cainfo string `json:"cainfo"`
  21571. ErrMsg string `json:"err_msg"`
  21572. InfRefmsgid string `json:"inf_refmsgid"`
  21573. Infcode int64 `json:"infcode"`
  21574. Output struct {
  21575. Result []struct {
  21576. BasMednFlag string `json:"bas_medn_flag"`
  21577. ChldMedcFlag string `json:"chld_medc_flag"`
  21578. ChrgitmLv string `json:"chrgitm_lv"`
  21579. Cnt float64 `json:"cnt"`
  21580. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21581. DrtReimFlag string `json:"drt_reim_flag"`
  21582. FeedetlSn string `json:"feedetl_sn"`
  21583. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21584. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21585. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21586. ListSpItemFlag string `json:"list_sp_item_flag"`
  21587. LmtUsedFlag string `json:"lmt_used_flag"`
  21588. MedChrgitmType string `json:"med_chrgitm_type"`
  21589. Memo string `json:"memo"`
  21590. OverlmtAmt float64 `json:"overlmt_amt"`
  21591. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21592. Pric float64 `json:"pric"`
  21593. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21594. SelfpayProp float64 `json:"selfpay_prop"`
  21595. } `json:"result"`
  21596. } `json:"output"`
  21597. RefmsgTime string `json:"refmsg_time"`
  21598. RespondTime string `json:"respond_time"`
  21599. Signtype string `json:"signtype"`
  21600. WarnMsg string `json:"warn_msg"`
  21601. }
  21602. type ResultFour10265 struct {
  21603. Cainfo string `json:"cainfo"`
  21604. ErrMsg string `json:"err_msg"`
  21605. InfRefmsgid string `json:"inf_refmsgid"`
  21606. Infcode string `json:"infcode"`
  21607. Output struct {
  21608. Result []struct {
  21609. BasMednFlag string `json:"bas_medn_flag"`
  21610. ChldMedcFlag string `json:"chld_medc_flag"`
  21611. ChrgitmLv string `json:"chrgitm_lv"`
  21612. Cnt float64 `json:"cnt"`
  21613. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21614. DrtReimFlag string `json:"drt_reim_flag"`
  21615. FeedetlSn string `json:"feedetl_sn"`
  21616. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21617. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21618. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21619. ListSpItemFlag string `json:"list_sp_item_flag"`
  21620. LmtUsedFlag string `json:"lmt_used_flag"`
  21621. MedChrgitmType string `json:"med_chrgitm_type"`
  21622. Memo string `json:"memo"`
  21623. OverlmtAmt float64 `json:"overlmt_amt"`
  21624. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21625. Pric float64 `json:"pric"`
  21626. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21627. SelfpayProp float64 `json:"selfpay_prop"`
  21628. } `json:"result"`
  21629. } `json:"output"`
  21630. RefmsgTime string `json:"refmsg_time"`
  21631. RespondTime string `json:"respond_time"`
  21632. Signtype string `json:"signtype"`
  21633. WarnMsg string `json:"warn_msg"`
  21634. }
  21635. type ResultMemo struct {
  21636. InsuAdmdvs string `json:"insuAdmdvs"`
  21637. }
  21638. // [{"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}]
  21639. type ResultIDInfo struct {
  21640. Begntime string `json:"begntime"`
  21641. Endtime string `json:"endtime"`
  21642. Memo string `json:"memo"`
  21643. }
  21644. type ResultFive struct {
  21645. Balc float64 `json:"balc"`
  21646. CvlservFlag string `json:"cvlserv_flag"`
  21647. EmpName string `json:"emp_name"`
  21648. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21649. Insutype string `json:"insutype"`
  21650. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21651. PausInsuDate string `json:"paus_insu_date"`
  21652. PsnInsuDate string `json:"psn_insu_date"`
  21653. PsnInsuStas string `json:"psn_insu_stas"`
  21654. PsnType string `json:"psn_type"`
  21655. }
  21656. type ResultSix struct {
  21657. Cainfo interface{} `json:"cainfo"`
  21658. ErrMsg string `json:"err_msg"`
  21659. InfRefmsgid string `json:"inf_refmsgid"`
  21660. Infcode int64 `json:"infcode"`
  21661. Output struct {
  21662. } `json:"output"`
  21663. RefmsgTime string `json:"refmsg_time"`
  21664. RespondTime string `json:"respond_time"`
  21665. Signtype interface{} `json:"signtype"`
  21666. WarnMsg interface{} `json:"warn_msg"`
  21667. }
  21668. type FJ3507Result struct {
  21669. Cainfo interface{} `json:"cainfo"`
  21670. ErrMsg string `json:"err_msg"`
  21671. InfRefmsgid string `json:"inf_refmsgid"`
  21672. Infcode int64 `json:"infcode"`
  21673. Output struct {
  21674. retRslt string `json:"retRslt"`
  21675. msgRslt string `json:"msgRslt"`
  21676. } `json:"output"`
  21677. RefmsgTime string `json:"refmsg_time"`
  21678. RespondTime string `json:"respond_time"`
  21679. Signtype interface{} `json:"signtype"`
  21680. WarnMsg interface{} `json:"warn_msg"`
  21681. }
  21682. type FJ3507ResultFor10188 struct {
  21683. Cainfo interface{} `json:"cainfo"`
  21684. ErrMsg string `json:"err_msg"`
  21685. InfRefmsgid string `json:"inf_refmsgid"`
  21686. Infcode string `json:"infcode"`
  21687. RefmsgTime string `json:"refmsg_time"`
  21688. RespondTime string `json:"respond_time"`
  21689. Signtype interface{} `json:"signtype"`
  21690. WarnMsg interface{} `json:"warn_msg"`
  21691. }
  21692. type Result2406 struct {
  21693. Cainfo interface{} `json:"cainfo"`
  21694. ErrMsg string `json:"err_msg"`
  21695. InfRefmsgid string `json:"inf_refmsgid"`
  21696. Infcode int64 `json:"infcode"`
  21697. Output struct {
  21698. Result struct {
  21699. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21700. } `json:"result"`
  21701. } `json:"output"`
  21702. RefmsgTime string `json:"refmsg_time"`
  21703. RespondTime string `json:"respond_time"`
  21704. Signtype interface{} `json:"signtype"`
  21705. WarnMsg interface{} `json:"warn_msg"`
  21706. }
  21707. type GZResultSix struct {
  21708. Cainfo interface{} `json:"cainfo"`
  21709. ErrMsg string `json:"err_msg"`
  21710. InfRefmsgid string `json:"inf_refmsgid"`
  21711. Infcode int64 `json:"infcode"`
  21712. Output string `json:"output"`
  21713. RefmsgTime string `json:"refmsg_time"`
  21714. RespondTime string `json:"respond_time"`
  21715. Signtype interface{} `json:"signtype"`
  21716. WarnMsg interface{} `json:"warn_msg"`
  21717. }
  21718. type ResultSix10265 struct {
  21719. Cainfo interface{} `json:"cainfo"`
  21720. ErrMsg string `json:"err_msg"`
  21721. InfRefmsgid string `json:"inf_refmsgid"`
  21722. Infcode string `json:"infcode"`
  21723. Output struct {
  21724. } `json:"output"`
  21725. RefmsgTime string `json:"refmsg_time"`
  21726. RespondTime string `json:"respond_time"`
  21727. Signtype interface{} `json:"signtype"`
  21728. WarnMsg interface{} `json:"warn_msg"`
  21729. }
  21730. type ResultSeven struct {
  21731. Cainfo string `json:"cainfo"`
  21732. ErrMsg string `json:"err_msg"`
  21733. InfRefmsgid string `json:"inf_refmsgid"`
  21734. Infcode int64 `json:"infcode"`
  21735. Output struct {
  21736. Setlinfo struct {
  21737. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21738. AcctPay float64 `json:"acct_pay"`
  21739. ActPayDedc float64 `json:"act_pay_dedc"`
  21740. Age float64 `json:"age"`
  21741. Balc float64 `json:"balc"`
  21742. Certno string `json:"certno"`
  21743. ClrOptins string `json:"clr_optins"`
  21744. ClrType string `json:"clr_type"`
  21745. ClrWay string `json:"clr_way"`
  21746. CvlservFlag string `json:"cvlserv_flag"`
  21747. CvlservPay float64 `json:"cvlserv_pay"`
  21748. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21749. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21750. Gend string `json:"gend"`
  21751. HifesPay float64 `json:"hifes_pay"`
  21752. HifmiPay float64 `json:"hifmi_pay"`
  21753. HifpPay float64 `json:"hifp_pay"`
  21754. HospPartAmt float64 `json:"hosp_part_amt"`
  21755. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21756. Insutype string `json:"insutype"`
  21757. MafPay float64 `json:"maf_pay"`
  21758. MdtrtCertType string `json:"mdtrt_cert_type"`
  21759. HifobPay float64 `json:"hifob_pay"`
  21760. MdtrtID string `json:"mdtrt_id"`
  21761. MedType string `json:"med_type"`
  21762. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21763. MedinsSetlID string `json:"medins_setl_id"`
  21764. Naty string `json:"naty"`
  21765. OthPay float64 `json:"oth_pay"`
  21766. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21767. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21768. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21769. PsnCashPay float64 `json:"psn_cash_pay"`
  21770. PsnCertType string `json:"psn_cert_type"`
  21771. PsnName string `json:"psn_name"`
  21772. PsnNo string `json:"psn_no"`
  21773. PsnPartAmt float64 `json:"psn_part_amt"`
  21774. PsnType string `json:"psn_type"`
  21775. SetlID string `json:"setl_id"`
  21776. SetlTime string `json:"setl_time"`
  21777. } `json:"setlinfo"`
  21778. Setldetail interface{} `json:"setldetail"`
  21779. } `json:"output"`
  21780. RefmsgTime string `json:"refmsg_time"`
  21781. RespondTime string `json:"respond_time"`
  21782. Signtype interface{} `json:"signtype"`
  21783. WarnMsg interface{} `json:"warn_msg"`
  21784. }
  21785. type ResultSevenAH struct {
  21786. Cainfo string `json:"cainfo"`
  21787. ErrMsg string `json:"err_msg"`
  21788. InfRefmsgid string `json:"inf_refmsgid"`
  21789. Infcode int64 `json:"infcode"`
  21790. Output struct {
  21791. Setlinfo struct {
  21792. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21793. AcctPay float64 `json:"acct_pay"`
  21794. ActPayDedc float64 `json:"act_pay_dedc"`
  21795. Age float64 `json:"age"`
  21796. Balc float64 `json:"balc"`
  21797. Certno string `json:"certno"`
  21798. ClrOptins string `json:"clr_optins"`
  21799. ClrType string `json:"clr_type"`
  21800. ClrWay string `json:"clr_way"`
  21801. CvlservFlag string `json:"cvlserv_flag"`
  21802. CvlservPay float64 `json:"cvlserv_pay"`
  21803. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21804. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21805. Gend string `json:"gend"`
  21806. HifesPay float64 `json:"hifes_pay"`
  21807. HifmiPay float64 `json:"hifmi_pay"`
  21808. HifpPay float64 `json:"hifp_pay"`
  21809. HospPartAmt float64 `json:"hosp_part_amt"`
  21810. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21811. Insutype string `json:"insutype"`
  21812. MafPay float64 `json:"maf_pay"`
  21813. MdtrtCertType string `json:"mdtrt_cert_type"`
  21814. HifobPay float64 `json:"hifob_pay"`
  21815. MdtrtID string `json:"mdtrt_id"`
  21816. MedType string `json:"med_type"`
  21817. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21818. MedinsSetlID string `json:"medins_setl_id"`
  21819. Naty string `json:"naty"`
  21820. OthPay float64 `json:"oth_pay"`
  21821. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21822. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21823. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21824. PsnCashPay float64 `json:"psn_cash_pay"`
  21825. PsnCertType string `json:"psn_cert_type"`
  21826. PsnName string `json:"psn_name"`
  21827. PsnNo string `json:"psn_no"`
  21828. PsnPartAmt float64 `json:"psn_part_amt"`
  21829. PsnType string `json:"psn_type"`
  21830. SetlID string `json:"setl_id"`
  21831. SetlTime int64 `json:"setl_time"`
  21832. } `json:"setlinfo"`
  21833. Setldetail interface{} `json:"setldetail"`
  21834. } `json:"output"`
  21835. RefmsgTime string `json:"refmsg_time"`
  21836. RespondTime string `json:"respond_time"`
  21837. Signtype interface{} `json:"signtype"`
  21838. WarnMsg interface{} `json:"warn_msg"`
  21839. }
  21840. type ResultSeven10265 struct {
  21841. Cainfo string `json:"cainfo"`
  21842. ErrMsg string `json:"err_msg"`
  21843. InfRefmsgid string `json:"inf_refmsgid"`
  21844. Infcode string `json:"infcode"`
  21845. Output struct {
  21846. Setlinfo struct {
  21847. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21848. AcctPay float64 `json:"acct_pay"`
  21849. ActPayDedc float64 `json:"act_pay_dedc"`
  21850. Age float64 `json:"age"`
  21851. Balc float64 `json:"balc"`
  21852. Certno string `json:"certno"`
  21853. ClrOptins string `json:"clr_optins"`
  21854. ClrType string `json:"clr_type"`
  21855. ClrWay string `json:"clr_way"`
  21856. CvlservFlag string `json:"cvlserv_flag"`
  21857. CvlservPay float64 `json:"cvlserv_pay"`
  21858. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21859. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21860. Gend string `json:"gend"`
  21861. HifesPay float64 `json:"hifes_pay"`
  21862. HifmiPay float64 `json:"hifmi_pay"`
  21863. HifpPay float64 `json:"hifp_pay"`
  21864. HospPartAmt float64 `json:"hosp_part_amt"`
  21865. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21866. Insutype string `json:"insutype"`
  21867. MafPay float64 `json:"maf_pay"`
  21868. MdtrtCertType string `json:"mdtrt_cert_type"`
  21869. HifobPay float64 `json:"hifob_pay"`
  21870. MdtrtID string `json:"mdtrt_id"`
  21871. MedType string `json:"med_type"`
  21872. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21873. MedinsSetlID string `json:"medins_setl_id"`
  21874. Naty string `json:"naty"`
  21875. OthPay float64 `json:"oth_pay"`
  21876. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21877. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21878. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21879. PsnCashPay float64 `json:"psn_cash_pay"`
  21880. PsnCertType string `json:"psn_cert_type"`
  21881. PsnName string `json:"psn_name"`
  21882. PsnNo string `json:"psn_no"`
  21883. PsnPartAmt float64 `json:"psn_part_amt"`
  21884. PsnType string `json:"psn_type"`
  21885. SetlID string `json:"setl_id"`
  21886. SetlTime string `json:"setl_time"`
  21887. } `json:"setlinfo"`
  21888. Setldetail interface{} `json:"setldetail"`
  21889. } `json:"output"`
  21890. RefmsgTime string `json:"refmsg_time"`
  21891. RespondTime string `json:"respond_time"`
  21892. Signtype interface{} `json:"signtype"`
  21893. WarnMsg interface{} `json:"warn_msg"`
  21894. }
  21895. type ResultSeven10265Two struct {
  21896. Cainfo string `json:"cainfo"`
  21897. ErrMsg string `json:"err_msg"`
  21898. InfRefmsgid string `json:"inf_refmsgid"`
  21899. Infcode string `json:"infcode"`
  21900. Output struct {
  21901. Setlinfo struct {
  21902. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21903. AcctPay float64 `json:"acct_pay"`
  21904. ActPayDedc float64 `json:"act_pay_dedc"`
  21905. Age float64 `json:"age"`
  21906. Balc float64 `json:"balc"`
  21907. Certno string `json:"certno"`
  21908. ClrOptins string `json:"clr_optins"`
  21909. ClrType string `json:"clr_type"`
  21910. ClrWay string `json:"clr_way"`
  21911. CvlservFlag string `json:"cvlserv_flag"`
  21912. CvlservPay float64 `json:"cvlserv_pay"`
  21913. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21914. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21915. Gend string `json:"gend"`
  21916. HifesPay float64 `json:"hifes_pay"`
  21917. HifmiPay float64 `json:"hifmi_pay"`
  21918. HifpPay float64 `json:"hifp_pay"`
  21919. HospPartAmt string `json:"hosp_part_amt"`
  21920. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21921. Insutype string `json:"insutype"`
  21922. MafPay float64 `json:"maf_pay"`
  21923. MdtrtCertType string `json:"mdtrt_cert_type"`
  21924. HifobPay float64 `json:"hifob_pay"`
  21925. MdtrtID string `json:"mdtrt_id"`
  21926. MedType string `json:"med_type"`
  21927. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21928. MedinsSetlID string `json:"medins_setl_id"`
  21929. Naty string `json:"naty"`
  21930. OthPay float64 `json:"oth_pay"`
  21931. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21932. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21933. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21934. PsnCashPay float64 `json:"psn_cash_pay"`
  21935. PsnCertType string `json:"psn_cert_type"`
  21936. PsnName string `json:"psn_name"`
  21937. PsnNo string `json:"psn_no"`
  21938. PsnPartAmt float64 `json:"psn_part_amt"`
  21939. PsnType string `json:"psn_type"`
  21940. SetlID string `json:"setl_id"`
  21941. SetlTime string `json:"setl_time"`
  21942. } `json:"setlinfo"`
  21943. Setldetail interface{} `json:"setldetail"`
  21944. } `json:"output"`
  21945. RefmsgTime string `json:"refmsg_time"`
  21946. RespondTime string `json:"respond_time"`
  21947. Signtype interface{} `json:"signtype"`
  21948. WarnMsg interface{} `json:"warn_msg"`
  21949. }
  21950. type GZResultSeven10265Two struct {
  21951. Cainfo string `json:"cainfo"`
  21952. ErrMsg string `json:"err_msg"`
  21953. InfRefmsgid string `json:"inf_refmsgid"`
  21954. Infcode int64 `json:"infcode"`
  21955. Output struct {
  21956. Setlinfo struct {
  21957. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21958. AcctPay float64 `json:"acct_pay"`
  21959. ActPayDedc float64 `json:"act_pay_dedc"`
  21960. Age float64 `json:"age"`
  21961. Balc float64 `json:"balc"`
  21962. Certno string `json:"certno"`
  21963. ClrOptins string `json:"clr_optins"`
  21964. ClrType string `json:"clr_type"`
  21965. ClrWay string `json:"clr_way"`
  21966. CvlservFlag string `json:"cvlserv_flag"`
  21967. CvlservPay float64 `json:"cvlserv_pay"`
  21968. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21969. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21970. Gend string `json:"gend"`
  21971. HifesPay float64 `json:"hifes_pay"`
  21972. HifmiPay float64 `json:"hifmi_pay"`
  21973. HifpPay float64 `json:"hifp_pay"`
  21974. HospPartAmt float64 `json:"hosp_part_amt"`
  21975. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21976. Insutype string `json:"insutype"`
  21977. MafPay float64 `json:"maf_pay"`
  21978. MdtrtCertType string `json:"mdtrt_cert_type"`
  21979. HifobPay float64 `json:"hifob_pay"`
  21980. MdtrtID string `json:"mdtrt_id"`
  21981. MedType string `json:"med_type"`
  21982. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21983. MedinsSetlID string `json:"medins_setl_id"`
  21984. Naty string `json:"naty"`
  21985. OthPay float64 `json:"oth_pay"`
  21986. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21987. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21988. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21989. PsnCashPay float64 `json:"psn_cash_pay"`
  21990. PsnCertType string `json:"psn_cert_type"`
  21991. PsnName string `json:"psn_name"`
  21992. PsnNo string `json:"psn_no"`
  21993. PsnPartAmt float64 `json:"psn_part_amt"`
  21994. PsnType string `json:"psn_type"`
  21995. SetlID string `json:"setl_id"`
  21996. SetlTime string `json:"setl_time"`
  21997. } `json:"setlinfo"`
  21998. Setldetail interface{} `json:"setldetail"`
  21999. } `json:"output"`
  22000. RefmsgTime string `json:"refmsg_time"`
  22001. RespondTime string `json:"respond_time"`
  22002. Signtype interface{} `json:"signtype"`
  22003. WarnMsg interface{} `json:"warn_msg"`
  22004. }
  22005. type ResultEight struct {
  22006. Cainfo string `json:"cainfo"`
  22007. ErrMsg string `json:"err_msg"`
  22008. InfRefmsgid string `json:"inf_refmsgid"`
  22009. Infcode int64 `json:"infcode"`
  22010. Output struct {
  22011. Stmtinfo struct {
  22012. SetlOptins string `json:"setl_optins"`
  22013. StmtRslt string `json:"stmt_rslt"`
  22014. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22015. } `json:"stmtinfo"`
  22016. } `json:"output"`
  22017. RefmsgTime string `json:"refmsg_time"`
  22018. RespondTime string `json:"respond_time"`
  22019. Signtype interface{} `json:"signtype"`
  22020. WarnMsg interface{} `json:"warn_msg"`
  22021. }
  22022. type ResultEightFor10188 struct {
  22023. Cainfo string `json:"cainfo"`
  22024. ErrMsg string `json:"err_msg"`
  22025. InfRefmsgid string `json:"inf_refmsgid"`
  22026. Infcode string `json:"infcode"`
  22027. Output struct {
  22028. Stmtinfo struct {
  22029. SetlOptins string `json:"setl_optins"`
  22030. StmtRslt string `json:"stmt_rslt"`
  22031. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22032. } `json:"stmtinfo"`
  22033. } `json:"output"`
  22034. RefmsgTime string `json:"refmsg_time"`
  22035. RespondTime string `json:"respond_time"`
  22036. Signtype interface{} `json:"signtype"`
  22037. WarnMsg interface{} `json:"warn_msg"`
  22038. }
  22039. type ResultNine struct {
  22040. Cainfo string `json:"cainfo"`
  22041. ErrMsg string `json:"err_msg"`
  22042. InfRefmsgid string `json:"inf_refmsgid"`
  22043. Infcode int64 `json:"infcode"`
  22044. Output struct {
  22045. FileQuryNo string `json:"file_qury_no"`
  22046. } `json:"output"`
  22047. RefmsgTime string `json:"refmsg_time"`
  22048. RespondTime string `json:"respond_time"`
  22049. Signtype interface{} `json:"signtype"`
  22050. WarnMsg interface{} `json:"warn_msg"`
  22051. }
  22052. type ResultTen struct {
  22053. Cainfo string `json:"cainfo"`
  22054. ErrMsg string `json:"err_msg"`
  22055. InfRefmsgid string `json:"inf_refmsgid"`
  22056. Infcode int64 `json:"infcode"`
  22057. Output struct {
  22058. Fileinfo struct {
  22059. DldEndtime string `json:"dld_endtime"`
  22060. FileQuryNo string `json:"file_qury_no"`
  22061. Filename string `json:"filename"`
  22062. } `json:"fileinfo"`
  22063. } `json:"output"`
  22064. RefmsgTime string `json:"refmsg_time"`
  22065. RespondTime string `json:"respond_time"`
  22066. Signtype interface{} `json:"signtype"`
  22067. WarnMsg interface{} `json:"warn_msg"`
  22068. }
  22069. type Result5262 struct {
  22070. ErrMsg string `json:"err_msg"`
  22071. InfRefmsgid string `json:"inf_refmsgid"`
  22072. Infcode int64 `json:"infcode"`
  22073. Output struct {
  22074. PageInfo struct {
  22075. Size int `json:"size"`
  22076. RecordCounts int `json:"record_counts"`
  22077. } `json:"page_info"`
  22078. Idetinfo []interface{} `json:"idetinfo"`
  22079. Result []struct {
  22080. SetlID string `json:"setl_id"`
  22081. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22082. MdtrtID string `json:"mdtrt_id"`
  22083. InitSetlID string `json:"init_setl_id,omitempty"`
  22084. PsnNo string `json:"psn_no"`
  22085. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22086. PsnName string `json:"psn_name"`
  22087. PsnCertType string `json:"psn_cert_type"`
  22088. Certno string `json:"certno"`
  22089. Gend string `json:"gend,omitempty"`
  22090. Naty string `json:"naty,omitempty"`
  22091. Brdy string `json:"brdy,omitempty"`
  22092. Age float64 `json:"age,omitempty"`
  22093. Insutype string `json:"insutype,omitempty"`
  22094. PsnType string `json:"psn_type"`
  22095. CvlservFlag string `json:"cvlserv_flag"`
  22096. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22097. SpPsnType string `json:"sp_psn_type,omitempty"`
  22098. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22099. ClctGrde string `json:"clct_grde,omitempty"`
  22100. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22101. NwbFlag string `json:"nwb_flag,omitempty"`
  22102. InsuAdmdvs string `json:"insu_admdvs"`
  22103. EmpNo string `json:"emp_no,omitempty"`
  22104. EmpName string `json:"emp_name,omitempty"`
  22105. EmpType string `json:"emp_type,omitempty"`
  22106. EconType string `json:"econ_type,omitempty"`
  22107. AfilIndu string `json:"afil_indu,omitempty"`
  22108. AfilRlts string `json:"afil_rlts,omitempty"`
  22109. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22110. PayLoc string `json:"pay_loc,omitempty"`
  22111. FixmedinsCode string `json:"fixmedins_code"`
  22112. FixmedinsName string `json:"fixmedins_name"`
  22113. HospLv string `json:"hosp_lv,omitempty"`
  22114. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22115. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22116. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22117. Begndate string `json:"begndate"`
  22118. Enddate string `json:"enddate"`
  22119. SetlTime string `json:"setl_time"`
  22120. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22121. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22122. MedType string `json:"med_type"`
  22123. SetlType string `json:"setl_type,omitempty"`
  22124. ClrType string `json:"clr_type,omitempty"`
  22125. ClrWay string `json:"clr_way,omitempty"`
  22126. PsnSetlway string `json:"psn_setlway,omitempty"`
  22127. ClrOptins string `json:"clr_optins,omitempty"`
  22128. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22129. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22130. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22131. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22132. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22133. DedcStd float64 `json:"dedc_std,omitempty"`
  22134. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22135. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22136. HifpPay float64 `json:"hifp_pay,omitempty"`
  22137. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22138. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22139. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22140. HifesPay float64 `json:"hifes_pay,omitempty"`
  22141. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22142. HifobPay float64 `json:"hifob_pay,omitempty"`
  22143. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22144. MafPay float64 `json:"maf_pay,omitempty"`
  22145. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22146. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22147. PsnPay float64 `json:"psn_pay,omitempty"`
  22148. AcctPay float64 `json:"acct_pay,omitempty"`
  22149. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22150. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22151. Balc float64 `json:"balc,omitempty"`
  22152. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22153. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22154. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22155. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22156. Year string `json:"year,omitempty"`
  22157. DiseNo string `json:"dise_no,omitempty"`
  22158. DiseName string `json:"dise_name,omitempty"`
  22159. Invono string `json:"invono,omitempty"`
  22160. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22161. ValiFlag string `json:"vali_flag,omitempty"`
  22162. Memo string `json:"memo,omitempty"`
  22163. Rid string `json:"rid"`
  22164. UpdtTime string `json:"updt_time,omitempty"`
  22165. CrterID string `json:"crter_id,omitempty"`
  22166. CrterName string `json:"crter_name,omitempty"`
  22167. CrteTime string `json:"crte_time,omitempty"`
  22168. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22169. OpterID string `json:"opter_id,omitempty"`
  22170. OpterName string `json:"opter_name,omitempty"`
  22171. OptTime string `json:"opt_time,omitempty"`
  22172. OptinsNo string `json:"optins_no,omitempty"`
  22173. PoolareaNo string `json:"poolarea_no,omitempty"`
  22174. } `json:"result"`
  22175. } `json:"output"`
  22176. RefmsgTime string `json:"refmsg_time"`
  22177. RespondTime string `json:"respond_time"`
  22178. Signtype interface{} `json:"signtype"`
  22179. WarnInfo interface{} `json:"warn_info"`
  22180. }
  22181. type Result5267 struct {
  22182. ErrMsg string `json:"err_msg"`
  22183. InfRefmsgid string `json:"inf_refmsgid"`
  22184. Infcode int64 `json:"infcode"`
  22185. Output struct {
  22186. PageInfo struct {
  22187. Size int `json:"size"`
  22188. RecordCounts int `json:"record_counts"`
  22189. } `json:"pageinfo"`
  22190. Result []struct {
  22191. SetlID string `json:"setl_id"`
  22192. ClrOptins string `json:"clr_optins"`
  22193. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22194. MdtrtID string `json:"mdtrt_id"`
  22195. InitSetlID string `json:"init_setl_id,omitempty"`
  22196. PsnNo string `json:"psn_no"`
  22197. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22198. PsnName string `json:"psn_name"`
  22199. PsnCertType string `json:"psn_cert_type"`
  22200. Certno string `json:"certno"`
  22201. Gend string `json:"gend,omitempty"`
  22202. Naty string `json:"naty,omitempty"`
  22203. Brdy string `json:"brdy,omitempty"`
  22204. Age float64 `json:"age,omitempty"`
  22205. Insutype string `json:"insutype,omitempty"`
  22206. PsnType string `json:"psn_type"`
  22207. CvlservFlag string `json:"cvlserv_flag"`
  22208. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22209. SpPsnType string `json:"sp_psn_type,omitempty"`
  22210. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22211. ClctGrde string `json:"clct_grde,omitempty"`
  22212. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22213. NwbFlag string `json:"nwb_flag,omitempty"`
  22214. InsuAdmdvs string `json:"insu_admdvs"`
  22215. EmpNo string `json:"emp_no,omitempty"`
  22216. EmpName string `json:"emp_name,omitempty"`
  22217. EmpType string `json:"emp_type,omitempty"`
  22218. EconType string `json:"econ_type,omitempty"`
  22219. AfilIndu string `json:"afil_indu,omitempty"`
  22220. AfilRlts string `json:"afil_rlts,omitempty"`
  22221. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22222. PayLoc string `json:"pay_loc,omitempty"`
  22223. FixmedinsCode string `json:"fixmedins_code"`
  22224. FixmedinsName string `json:"fixmedins_name"`
  22225. HospLv string `json:"hosp_lv,omitempty"`
  22226. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22227. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22228. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22229. Begndate string `json:"begndate,omitempty"`
  22230. Enddate string `json:"enddate,omitempty"`
  22231. SetlTime string `json:"setl_time,omitempty"`
  22232. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22233. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22234. MedType string `json:"med_type"`
  22235. SetlType string `json:"setl_type,omitempty"`
  22236. ClrType string `json:"clr_type,omitempty"`
  22237. ClrWay string `json:"clr_way,omitempty"`
  22238. PsnSetlway string `json:"psn_setlway,omitempty"`
  22239. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22240. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22241. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22242. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22243. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22244. DedcStd float64 `json:"dedc_std,omitempty"`
  22245. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22246. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22247. HifpPay float64 `json:"hifp_pay,omitempty"`
  22248. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22249. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22250. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22251. HifesPay float64 `json:"hifes_pay,omitempty"`
  22252. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22253. HifobPay float64 `json:"hifob_pay,omitempty"`
  22254. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22255. MafPay float64 `json:"maf_pay,omitempty"`
  22256. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22257. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22258. PsnPay float64 `json:"psn_pay,omitempty"`
  22259. AcctPay float64 `json:"acct_pay,omitempty"`
  22260. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22261. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22262. Balc float64 `json:"balc,omitempty"`
  22263. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22264. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22265. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22266. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22267. Year string `json:"year,omitempty"`
  22268. DiseNo string `json:"dise_no,omitempty"`
  22269. DiseName string `json:"dise_name,omitempty"`
  22270. Invono string `json:"invono,omitempty"`
  22271. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22272. Memo string `json:"memo,omitempty"`
  22273. UpdtTime string `json:"updt_time,omitempty"`
  22274. OpterID string `json:"opter_id,omitempty"`
  22275. OpterName string `json:"opter_name,omitempty"`
  22276. OptTime string `json:"opt_time,omitempty"`
  22277. OptinsNo string `json:"optins_no,omitempty"`
  22278. PoolareaNo string `json:"poolarea_no,omitempty"`
  22279. } `json:"result"`
  22280. } `json:"output"`
  22281. RefmsgTime string `json:"refmsg_time"`
  22282. RespondTime string `json:"respond_time"`
  22283. Signtype interface{} `json:"signtype"`
  22284. WarnInfo interface{} `json:"warn_info"`
  22285. }
  22286. // type Autogenerated struct {
  22287. // Output struct {
  22288. // Setlinfo struct {
  22289. // SetlTime string `json:"setl_time"`
  22290. // CvlservPay float64 `json:"cvlserv_pay"`
  22291. // Year string `json:"year"`
  22292. // MedType string `json:"med_type"`
  22293. // PsnPay float64 `json:"psn_pay"`
  22294. // OpterID string `json:"opter_id"`
  22295. // Begndate string `json:"begndate"`
  22296. // FlxempeFlag string `json:"flxempe_flag"`
  22297. // HifmiPay float64 `json:"hifmi_pay"`
  22298. // PsnNo string `json:"psn_no"`
  22299. // ActPayDedc float64 `json:"act_pay_dedc"`
  22300. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22301. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22302. // ClrWay string `json:"clr_way"`
  22303. // OthPay float64 `json:"oth_pay"`
  22304. // Gend string `json:"gend"`
  22305. // MdtrtID string `json:"mdtrt_id"`
  22306. // AcctPay float64 `json:"acct_pay"`
  22307. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22308. // Insutype string `json:"insutype"`
  22309. // Invono interface{} `json:"invono"`
  22310. // Enddate string `json:"enddate"`
  22311. // CashPayamt float64 `json:"cash_payamt"`
  22312. // PsnType string `json:"psn_type"`
  22313. // FixmedinsName string `json:"fixmedins_name"`
  22314. // HifpPay float64 `json:"hifp_pay"`
  22315. // NewFlag interface{} `json:"new_flag"`
  22316. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22317. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22318. // PayLoc string `json:"pay_loc"`
  22319. // ClrType string `json:"clr_type"`
  22320. // RefdSetlFlag string `json:"refd_setl_flag"`
  22321. // CvlservFlag string `json:"cvlserv_flag"`
  22322. // EmpName string `json:"emp_name"`
  22323. // Brdy string `json:"brdy"`
  22324. // Naty string `json:"naty"`
  22325. // Certno string `json:"certno"`
  22326. // DiseCode string `json:"dise_code"`
  22327. // FixmedinsCode string `json:"fixmedins_code"`
  22328. // DedcHospLv string `json:"dedc_hosp_lv"`
  22329. // OpterName string `json:"opter_name"`
  22330. // Balc float64 `json:"balc"`
  22331. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22332. // PsnCertType string `json:"psn_cert_type"`
  22333. // HifobPay float64 `json:"hifob_pay"`
  22334. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22335. // HifesPay float64 `json:"hifes_pay"`
  22336. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22337. // OptTime string `json:"opt_time"`
  22338. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22339. // SetlID string `json:"setl_id"`
  22340. // MafPay float64 `json:"maf_pay"`
  22341. // PsnName string `json:"psn_name"`
  22342. // InsuOptins interface{} `json:"insu_optins"`
  22343. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22344. // ClrOptins string `json:"clr_optins"`
  22345. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22346. // DiseName string `json:"dise_name"`
  22347. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22348. // Age float64 `json:"age"`
  22349. // DtrtCertType string `json:"dtrt_cert_type"`
  22350. // HospLv string `json:"hosp_lv"`
  22351. // } `json:"setlinfo"`
  22352. // Setldetail []struct {
  22353. // FundPayType string `json:"fund_pay_type"`
  22354. // FundPayamt float64 `json:"fund_payamt"`
  22355. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22356. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22357. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22358. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22359. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22360. // } `json:"setldetail"`
  22361. // } `json:"output"`
  22362. // Infcode int `json:"infcode"`
  22363. // WarnMsg interface{} `json:"warn_msg"`
  22364. // Cainfo interface{} `json:"cainfo"`
  22365. // ErrMsg interface{} `json:"err_msg"`
  22366. // RefmsgTime string `json:"refmsg_time"`
  22367. // Signtype interface{} `json:"signtype"`
  22368. // RespondTime string `json:"respond_time"`
  22369. // InfRefmsgid string `json:"inf_refmsgid"`
  22370. // }
  22371. type Result002 struct {
  22372. Cainfo interface{} `json:"cainfo"`
  22373. ErrMsg string `json:"err_msg"`
  22374. InfRefmsgid string `json:"inf_refmsgid"`
  22375. Infcode int64 `json:"infcode"`
  22376. Output struct {
  22377. RxFile string `json:"rx_file"`
  22378. SignDigest string `json:"sign_digest"`
  22379. SignCertSn string `json:"sign_cert_sn"`
  22380. SignCertDn string `json:"sign_cert_dn"`
  22381. } `json:"output"`
  22382. RefmsgTime string `json:"refmsg_time"`
  22383. RespondTime string `json:"respond_time"`
  22384. Signtype interface{} `json:"signtype"`
  22385. WarnMsg interface{} `json:"warn_msg"`
  22386. }
  22387. type Result003 struct {
  22388. Cainfo interface{} `json:"cainfo"`
  22389. ErrMsg string `json:"err_msg"`
  22390. InfRefmsgid string `json:"inf_refmsgid"`
  22391. Infcode int64 `json:"infcode"`
  22392. Output struct {
  22393. HiRxno string `json:"hi_rxno"`
  22394. RxStasCodg string `json:"rx_stas_codg"`
  22395. RxStasName string `json:"rx_stas_name"`
  22396. } `json:"output"`
  22397. RefmsgTime string `json:"refmsg_time"`
  22398. RespondTime string `json:"respond_time"`
  22399. Signtype interface{} `json:"signtype"`
  22400. WarnMsg interface{} `json:"warn_msg"`
  22401. }
  22402. type ResultEleven struct {
  22403. Cainfo string `json:"cainfo"`
  22404. ErrMsg string `json:"err_msg"`
  22405. InfRefmsgid string `json:"inf_refmsgid"`
  22406. Infcode int64 `json:"infcode"`
  22407. Output struct {
  22408. Setlinfo struct {
  22409. SetlTime string `json:"setl_time"`
  22410. CvlservPay float64 `json:"cvlserv_pay"`
  22411. Year string `json:"year"`
  22412. MedType string `json:"med_type"`
  22413. PsnPay float64 `json:"psn_pay"`
  22414. OpterID string `json:"opter_id"`
  22415. Begndate string `json:"begndate"`
  22416. FlxempeFlag string `json:"flxempe_flag"`
  22417. HifmiPay float64 `json:"hifmi_pay"`
  22418. PsnNo string `json:"psn_no"`
  22419. ActPayDedc float64 `json:"act_pay_dedc"`
  22420. MedinsSetlID interface{} `json:"medins_setl_id"`
  22421. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22422. ClrWay string `json:"clr_way"`
  22423. OthPay float64 `json:"oth_pay"`
  22424. Gend string `json:"gend"`
  22425. MdtrtID string `json:"mdtrt_id"`
  22426. AcctPay float64 `json:"acct_pay"`
  22427. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22428. Insutype string `json:"insutype"`
  22429. Invono interface{} `json:"invono"`
  22430. Enddate string `json:"enddate"`
  22431. CashPayamt float64 `json:"cash_payamt"`
  22432. PsnType string `json:"psn_type"`
  22433. FixmedinsName string `json:"fixmedins_name"`
  22434. HifpPay float64 `json:"hifp_pay"`
  22435. NewFlag interface{} `json:"new_flag"`
  22436. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22437. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22438. PayLoc string `json:"pay_loc"`
  22439. ClrType string `json:"clr_type"`
  22440. RefdSetlFlag string `json:"refd_setl_flag"`
  22441. CvlservFlag string `json:"cvlserv_flag"`
  22442. EmpName string `json:"emp_name"`
  22443. Brdy string `json:"brdy"`
  22444. Naty string `json:"naty"`
  22445. Certno string `json:"certno"`
  22446. DiseCode string `json:"dise_code"`
  22447. FixmedinsCode string `json:"fixmedins_code"`
  22448. DedcHospLv string `json:"dedc_hosp_lv"`
  22449. OpterName string `json:"opter_name"`
  22450. Balc float64 `json:"balc"`
  22451. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22452. PsnCertType string `json:"psn_cert_type"`
  22453. HifobPay float64 `json:"hifob_pay"`
  22454. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22455. HifesPay float64 `json:"hifes_pay"`
  22456. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22457. OptTime string `json:"opt_time"`
  22458. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22459. SetlID string `json:"setl_id"`
  22460. MafPay float64 `json:"maf_pay"`
  22461. PsnName string `json:"psn_name"`
  22462. InsuOptins interface{} `json:"insu_optins"`
  22463. PrefFundPay interface{} `json:"pref_fund_pay"`
  22464. ClrOptins string `json:"clr_optins"`
  22465. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22466. DiseName string `json:"dise_name"`
  22467. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22468. Age float64 `json:"age"`
  22469. DtrtCertType string `json:"dtrt_cert_type"`
  22470. HospLv string `json:"hosp_lv"`
  22471. PsnCashPay float64 `json:"psn_cash_pay"`
  22472. } `json:"setlinfo"`
  22473. } `json:"output"`
  22474. RefmsgTime string `json:"refmsg_time"`
  22475. RespondTime string `json:"respond_time"`
  22476. Signtype interface{} `json:"signtype"`
  22477. WarnMsg interface{} `json:"warn_msg"`
  22478. }
  22479. type ResultElevenah struct {
  22480. Cainfo string `json:"cainfo"`
  22481. ErrMsg string `json:"err_msg"`
  22482. InfRefmsgid string `json:"inf_refmsgid"`
  22483. Infcode int64 `json:"infcode"`
  22484. Output struct {
  22485. Setlinfo struct {
  22486. SetlTime int64 `json:"setl_time"`
  22487. CvlservPay float64 `json:"cvlserv_pay"`
  22488. Year string `json:"year"`
  22489. MedType string `json:"med_type"`
  22490. PsnPay float64 `json:"psn_pay"`
  22491. OpterID string `json:"opter_id"`
  22492. Begndate int64 `json:"begndate"`
  22493. FlxempeFlag string `json:"flxempe_flag"`
  22494. HifmiPay float64 `json:"hifmi_pay"`
  22495. PsnNo string `json:"psn_no"`
  22496. ActPayDedc float64 `json:"act_pay_dedc"`
  22497. MedinsSetlID interface{} `json:"medins_setl_id"`
  22498. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22499. ClrWay string `json:"clr_way"`
  22500. OthPay float64 `json:"oth_pay"`
  22501. Gend string `json:"gend"`
  22502. MdtrtID string `json:"mdtrt_id"`
  22503. AcctPay float64 `json:"acct_pay"`
  22504. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22505. Insutype string `json:"insutype"`
  22506. Invono interface{} `json:"invono"`
  22507. Enddate int64 `json:"enddate"`
  22508. CashPayamt float64 `json:"cash_payamt"`
  22509. PsnType string `json:"psn_type"`
  22510. FixmedinsName string `json:"fixmedins_name"`
  22511. HifpPay float64 `json:"hifp_pay"`
  22512. NewFlag interface{} `json:"new_flag"`
  22513. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22514. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22515. PayLoc string `json:"pay_loc"`
  22516. ClrType string `json:"clr_type"`
  22517. RefdSetlFlag string `json:"refd_setl_flag"`
  22518. CvlservFlag string `json:"cvlserv_flag"`
  22519. EmpName string `json:"emp_name"`
  22520. Brdy int64 `json:"brdy"`
  22521. Naty string `json:"naty"`
  22522. Certno string `json:"certno"`
  22523. DiseCode string `json:"dise_code"`
  22524. FixmedinsCode string `json:"fixmedins_code"`
  22525. DedcHospLv string `json:"dedc_hosp_lv"`
  22526. OpterName string `json:"opter_name"`
  22527. Balc float64 `json:"balc"`
  22528. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22529. PsnCertType string `json:"psn_cert_type"`
  22530. HifobPay float64 `json:"hifob_pay"`
  22531. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22532. HifesPay float64 `json:"hifes_pay"`
  22533. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22534. OptTime int64 `json:"opt_time"`
  22535. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22536. SetlID string `json:"setl_id"`
  22537. MafPay float64 `json:"maf_pay"`
  22538. PsnName string `json:"psn_name"`
  22539. InsuOptins interface{} `json:"insu_optins"`
  22540. PrefFundPay interface{} `json:"pref_fund_pay"`
  22541. ClrOptins string `json:"clr_optins"`
  22542. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22543. DiseName string `json:"dise_name"`
  22544. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22545. Age float64 `json:"age"`
  22546. DtrtCertType string `json:"dtrt_cert_type"`
  22547. HospLv string `json:"hosp_lv"`
  22548. PsnCashPay float64 `json:"psn_cash_pay"`
  22549. } `json:"setlinfo"`
  22550. } `json:"output"`
  22551. RefmsgTime string `json:"refmsg_time"`
  22552. RespondTime string `json:"respond_time"`
  22553. Signtype interface{} `json:"signtype"`
  22554. WarnMsg interface{} `json:"warn_msg"`
  22555. }
  22556. type ResultEleven10265 struct {
  22557. Cainfo string `json:"cainfo"`
  22558. ErrMsg string `json:"err_msg"`
  22559. InfRefmsgid string `json:"inf_refmsgid"`
  22560. Infcode string `json:"infcode"`
  22561. Output struct {
  22562. Setlinfo struct {
  22563. SetlTime string `json:"setl_time"`
  22564. CvlservPay float64 `json:"cvlserv_pay"`
  22565. Year string `json:"year"`
  22566. MedType string `json:"med_type"`
  22567. PsnPay float64 `json:"psn_pay"`
  22568. OpterID string `json:"opter_id"`
  22569. Begndate string `json:"begndate"`
  22570. FlxempeFlag string `json:"flxempe_flag"`
  22571. HifmiPay float64 `json:"hifmi_pay"`
  22572. PsnNo string `json:"psn_no"`
  22573. ActPayDedc float64 `json:"act_pay_dedc"`
  22574. MedinsSetlID interface{} `json:"medins_setl_id"`
  22575. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22576. ClrWay string `json:"clr_way"`
  22577. OthPay float64 `json:"oth_pay"`
  22578. Gend string `json:"gend"`
  22579. MdtrtID string `json:"mdtrt_id"`
  22580. AcctPay float64 `json:"acct_pay"`
  22581. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22582. Insutype string `json:"insutype"`
  22583. Invono interface{} `json:"invono"`
  22584. Enddate string `json:"enddate"`
  22585. CashPayamt float64 `json:"cash_payamt"`
  22586. PsnType string `json:"psn_type"`
  22587. FixmedinsName string `json:"fixmedins_name"`
  22588. HifpPay float64 `json:"hifp_pay"`
  22589. NewFlag interface{} `json:"new_flag"`
  22590. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22591. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22592. PayLoc string `json:"pay_loc"`
  22593. ClrType string `json:"clr_type"`
  22594. RefdSetlFlag string `json:"refd_setl_flag"`
  22595. CvlservFlag string `json:"cvlserv_flag"`
  22596. EmpName string `json:"emp_name"`
  22597. Brdy string `json:"brdy"`
  22598. Naty string `json:"naty"`
  22599. Certno string `json:"certno"`
  22600. DiseCode string `json:"dise_code"`
  22601. FixmedinsCode string `json:"fixmedins_code"`
  22602. DedcHospLv string `json:"dedc_hosp_lv"`
  22603. OpterName string `json:"opter_name"`
  22604. Balc float64 `json:"balc"`
  22605. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22606. PsnCertType string `json:"psn_cert_type"`
  22607. HifobPay float64 `json:"hifob_pay"`
  22608. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22609. HifesPay float64 `json:"hifes_pay"`
  22610. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22611. OptTime string `json:"opt_time"`
  22612. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22613. SetlID string `json:"setl_id"`
  22614. MafPay float64 `json:"maf_pay"`
  22615. PsnName string `json:"psn_name"`
  22616. InsuOptins interface{} `json:"insu_optins"`
  22617. PrefFundPay interface{} `json:"pref_fund_pay"`
  22618. ClrOptins string `json:"clr_optins"`
  22619. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22620. DiseName string `json:"dise_name"`
  22621. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22622. Age float64 `json:"age"`
  22623. DtrtCertType string `json:"dtrt_cert_type"`
  22624. HospLv string `json:"hosp_lv"`
  22625. PsnCashPay float64 `json:"psn_cash_pay"`
  22626. } `json:"setlinfo"`
  22627. } `json:"output"`
  22628. RefmsgTime string `json:"refmsg_time"`
  22629. RespondTime string `json:"respond_time"`
  22630. Signtype interface{} `json:"signtype"`
  22631. WarnMsg interface{} `json:"warn_msg"`
  22632. }
  22633. type ResultTwelve struct {
  22634. Cainfo string `json:"cainfo"`
  22635. ErrMsg string `json:"err_msg"`
  22636. InfRefmsgid string `json:"inf_refmsgid"`
  22637. Infcode int64 `json:"infcode"`
  22638. Output struct {
  22639. MdtrtId string `json:"mdtrt_id"`
  22640. ChrgBchno string `json:"chrg_bchno"`
  22641. PsnNo string `json:"psn_no"`
  22642. } `json:"output"`
  22643. RefmsgTime string `json:"refmsg_time"`
  22644. RespondTime string `json:"respond_time"`
  22645. Signtype interface{} `json:"signtype"`
  22646. WarnMsg interface{} `json:"warn_msg"`
  22647. }
  22648. type ResultThirteen struct {
  22649. ErrMsg string `json:"err_msg"`
  22650. InfRefmsgid string `json:"inf_refmsgid"`
  22651. Infcode int64 `json:"infcode"`
  22652. Output struct {
  22653. Result struct {
  22654. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22655. } `json:"result"`
  22656. } `json:"output"`
  22657. RefmsgTime string `json:"refmsg_time"`
  22658. RespondTime string `json:"respond_time"`
  22659. Signtype interface{} `json:"signtype"`
  22660. WarnInfo interface{} `json:"warn_info"`
  22661. }
  22662. type ResultThirteen10265 struct {
  22663. ErrMsg string `json:"err_msg"`
  22664. InfRefmsgid string `json:"inf_refmsgid"`
  22665. Infcode string `json:"infcode"`
  22666. Output struct {
  22667. Result struct {
  22668. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22669. } `json:"result"`
  22670. } `json:"output"`
  22671. RefmsgTime string `json:"refmsg_time"`
  22672. RespondTime string `json:"respond_time"`
  22673. Signtype interface{} `json:"signtype"`
  22674. WarnInfo interface{} `json:"warn_info"`
  22675. }
  22676. type ResultFourteen struct {
  22677. ErrMsg string `json:"err_msg"`
  22678. InfRefmsgid string `json:"inf_refmsgid"`
  22679. Infcode int64 `json:"infcode"`
  22680. Output struct {
  22681. } `json:"output"`
  22682. RefmsgTime string `json:"refmsg_time"`
  22683. RespondTime string `json:"respond_time"`
  22684. Signtype interface{} `json:"signtype"`
  22685. WarnInfo interface{} `json:"warn_info"`
  22686. }
  22687. type ResultCFYLJG001 struct {
  22688. ErrMsg string `json:"err_msg"`
  22689. InfRefmsgid string `json:"inf_refmsgid"`
  22690. Infcode int64 `json:"infcode"`
  22691. Output struct {
  22692. RxTraceCode string `json:"rx_trace_code"`
  22693. HiRxno string `json:"hi_rxno"`
  22694. } `json:"output"`
  22695. RefmsgTime string `json:"refmsg_time"`
  22696. RespondTime string `json:"respond_time"`
  22697. Signtype interface{} `json:"signtype"`
  22698. WarnInfo interface{} `json:"warn_info"`
  22699. }
  22700. type ResultCFYLJG007 struct {
  22701. ErrMsg string `json:"err_msg"`
  22702. InfRefmsgid string `json:"inf_refmsgid"`
  22703. Infcode int64 `json:"infcode"`
  22704. Output struct {
  22705. HiRxno string `json:"hi_rxno"`
  22706. RxStasName string `json:"rx_stas_name"`
  22707. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22708. Seltdelts []interface{} `json:"seltdelts"`
  22709. RxUsedStasName string `json:"rx_used_stas_name"`
  22710. RxStasCodg string `json:"rx_stas_codg"`
  22711. } `json:"output"`
  22712. RefmsgTime string `json:"refmsg_time"`
  22713. RespondTime string `json:"respond_time"`
  22714. Signtype interface{} `json:"signtype"`
  22715. WarnInfo interface{} `json:"warn_info"`
  22716. }
  22717. type ResultCFYLJG002 struct {
  22718. ErrMsg string `json:"err_msg"`
  22719. InfRefmsgid string `json:"inf_refmsgid"`
  22720. Infcode int64 `json:"infcode"`
  22721. Output struct {
  22722. RxFile string `json:"rx_file"`
  22723. SignDigest string `json:"sign_digest"`
  22724. SignCertSn string `json:"sign_cert_sn"`
  22725. SignCertDn string `json:"sign_cert_dn"`
  22726. } `json:"output"`
  22727. RefmsgTime string `json:"refmsg_time"`
  22728. RespondTime string `json:"respond_time"`
  22729. Signtype interface{} `json:"signtype"`
  22730. WarnInfo interface{} `json:"warn_info"`
  22731. }
  22732. type ResultCFYLJG003 struct {
  22733. ErrMsg string `json:"err_msg"`
  22734. InfRefmsgid string `json:"inf_refmsgid"`
  22735. Infcode int64 `json:"infcode"`
  22736. Output struct {
  22737. HiRxno string `json:"hi_rxno"`
  22738. RxStasCodg string `json:"rx_stas_codg"`
  22739. RxStasName string `json:"rx_stas_name"`
  22740. } `json:"output"`
  22741. RefmsgTime string `json:"refmsg_time"`
  22742. RespondTime string `json:"respond_time"`
  22743. Signtype interface{} `json:"signtype"`
  22744. WarnInfo interface{} `json:"warn_info"`
  22745. }
  22746. type ResultCFYLJG004 struct {
  22747. ErrMsg string `json:"err_msg"`
  22748. InfRefmsgid string `json:"inf_refmsgid"`
  22749. Infcode int64 `json:"infcode"`
  22750. Output struct {
  22751. HiRxno string `json:"hi_rxno"`
  22752. RxStasCodg string `json:"rx_stas_codg"`
  22753. RxStasName string `json:"rx_stas_name"`
  22754. } `json:"output"`
  22755. RefmsgTime string `json:"refmsg_time"`
  22756. RespondTime string `json:"respond_time"`
  22757. Signtype interface{} `json:"signtype"`
  22758. WarnInfo interface{} `json:"warn_info"`
  22759. }
  22760. type ResultCFYLJG008 struct {
  22761. ErrMsg string `json:"err_msg"`
  22762. InfRefmsgid string `json:"inf_refmsgid"`
  22763. Infcode int64 `json:"infcode"`
  22764. Output struct {
  22765. PoolareaNo string `json:"poolareaNo"`
  22766. AdmdvsName string `json:"admdvsName"`
  22767. Count string `json:"count"`
  22768. } `json:"output"`
  22769. RefmsgTime string `json:"refmsg_time"`
  22770. RespondTime string `json:"respond_time"`
  22771. Signtype interface{} `json:"signtype"`
  22772. WarnInfo interface{} `json:"warn_info"`
  22773. }
  22774. type ResultCFYLJG005 struct {
  22775. ErrMsg string `json:"err_msg"`
  22776. InfRefmsgid string `json:"inf_refmsgid"`
  22777. Infcode int64 `json:"infcode"`
  22778. Output struct {
  22779. HiRxNo string `json:"hi_rxno"`
  22780. FixMedinsCode string `json:"fixmedins_code"`
  22781. FixMedinsName string `json:"fixmedins_name"`
  22782. RxStasCodg string `json:"rx_stas_codg"`
  22783. RxStasName string `json:"rx_stas_name"`
  22784. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22785. RxUserdStasName string `json:"rx_userd_stas_name"`
  22786. PrscTime string `json:"prsc_time"`
  22787. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22788. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22789. RxUsedWayName string `json:"rx_used_way_name"`
  22790. RxFrquCodg string `json:"rx_frqu_codg"`
  22791. RxFrquName string `json:"rx_frqu_name"`
  22792. RxDosunt string `json:"rx_dosunt"`
  22793. RxDoscnt float64 `json:"rx_doscnt"`
  22794. RxDrordDscr string `json:"rx_drord_dscr"`
  22795. ValiDays int64 `json:"vali_days"`
  22796. ValiEndTime string `json:"vali_end_time"`
  22797. ReptFlag string `json:"rept_flag"`
  22798. MaxReptCnt int64 `json:"max_rept_cnt"`
  22799. ReptdCnt int64 `json:"reptd_cnt"`
  22800. MinInrvDays int64 `json:"min_inrv_days"`
  22801. RxTypeCode string `json:"rx_type_code"`
  22802. RxTypeName string `json:"rx_type_name"`
  22803. LongRxFlag string `json:"long_rx_flag"`
  22804. RxDetlList []struct {
  22805. MedListCodg string `json:"med_list_codg"`
  22806. MedinsListCodg string `json:"medins_list_codg"`
  22807. HospPrepFlag string `json:"hosp_prep_flag"`
  22808. RxItemTypeCode string `json:"rx_item_type_code"`
  22809. RxItemTypeName string `json:"rx_item_type_name"`
  22810. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22811. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22812. TcmHerbFoote string `json:"tcmherb_foote"`
  22813. MednTypeCode string `json:"medn_type_code"`
  22814. MednTypeName string `json:"medn_type_name"`
  22815. MainMedcFlag string `json:"main_medc_flag"`
  22816. UrgtFlag string `json:"urgt_flag"`
  22817. BasMednFlag string `json:"bas_medn_flag"`
  22818. ImpDrugFlag string `json:"imp_drug_flag"`
  22819. ProdBarc string `json:"prod_barc"`
  22820. DrugProdname string `json:"drug_prodname"`
  22821. GennameCodg string `json:"genname_codg"`
  22822. DrugGenname string `json:"drug_genname"`
  22823. DrugDosform string `json:"drug_dosform"`
  22824. DrugSpec string `json:"drug_spec"`
  22825. PrdrName string `json:"prdr_name"`
  22826. MedcWayCodg string `json:"medc_way_codg"`
  22827. MedcWayDscr string `json:"medc_way_dscr"`
  22828. MedcBegntime string `json:"medc_begntime"`
  22829. MedcEndtime string `json:"medc_endtime"`
  22830. MedcDays float64 `json:"medc_days"`
  22831. DrugPric float64 `json:"drug_pric"`
  22832. DrugSumamt float64 `json:"drug_sumamt"`
  22833. DrugCnt float64 `json:"drug_cnt"`
  22834. DrugDosunt string `json:"drug_dosunt"`
  22835. SinDoscnt float64 `json:"sin_doscnt"`
  22836. SinDosunt string `json:"sin_dosunt"`
  22837. UsedFrquCodg string `json:"used_frqu_codg"`
  22838. UsedFrquName string `json:"used_frqu_name"`
  22839. DrugTotlcnt string `json:"drug_totlcnt"`
  22840. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22841. DiseCodg string `json:"dise_codg"`
  22842. HospApprFlag string `json:"hosp_appr_flag"`
  22843. } `json:"rx_detl_list"`
  22844. RxOtpinfo struct {
  22845. MedType string `json:"med_type"`
  22846. IptOtpNo string `json:"ipt_otp_no"`
  22847. OtpIptFlag string `json:"otp_ipt_flag"`
  22848. PatnName string `json:"patn_name"`
  22849. PatnAge float64 `json:"patn_age"`
  22850. PatnHgt float64 `json:"patn_hgt"`
  22851. PatnWt float64 `json:"patn_wt"`
  22852. Gend string `json:"gend"`
  22853. GesoVal float64 `json:"geso_val"`
  22854. NwbFlag string `json:"nwb_flag"`
  22855. NwbAge string `json:"nwb_age"`
  22856. SuckPrdFlag string `json:"suck_prd_flag"`
  22857. AlgsHis string `json:"algs_his"`
  22858. Insutype string `json:"insutype"`
  22859. PrscDeptName string `json:"prsc_dept_name"`
  22860. PrscDrName string `json:"prsc_dr_name"`
  22861. PharName string `json:"phar_name"`
  22862. PharChkTime string `json:"phar_chk_time"`
  22863. MdtrtTime string `json:"mdtrt_time"`
  22864. DiseCodg string `json:"dise_codg"`
  22865. DiseName string `json:"dise_name"`
  22866. SpDiseFlag string `json:"sp_dise_flag"`
  22867. MaindiagCode string `json:"maindiag_code"`
  22868. MaindiagName string `json:"maindiag_name"`
  22869. DiseCondDscr string `json:"dise_cond_dscr"`
  22870. FstdiagFlag string `json:"fstdiag_flag"`
  22871. } `json:"rx_otpinfo"`
  22872. RxDiseList []struct {
  22873. DiagType string `json:"diag_type"`
  22874. MaindiagFlag string `json:"maindiag_flag"`
  22875. DiagSrtNo string `json:"diag_srt_no"`
  22876. DiagCode string `json:"diag_code"`
  22877. DiagName string `json:"diag_name"`
  22878. DiagDept string `json:"diag_dept"`
  22879. DiagDrNo string `json:"diag_dr_no"`
  22880. DiagDrName string `json:"diag_dr_name"`
  22881. DiagTime string `json:"diag_time"`
  22882. TcmDiseCode string `json:"tcm_dise_code"`
  22883. TcmDiseName string `json:"tcm_dise_name"`
  22884. TcmSympCode string `json:"tcmsymp_code"`
  22885. TcmSymp string `json:"tcmsymp"`
  22886. } `json:"rx_dise_list"`
  22887. } `json:"output"`
  22888. RefmsgTime string `json:"refmsg_time"`
  22889. RespondTime string `json:"respond_time"`
  22890. Signtype interface{} `json:"signtype"`
  22891. WarnInfo interface{} `json:"warn_info"`
  22892. }
  22893. type ResultCFYLJG006 struct {
  22894. ErrMsg string `json:"err_msg"`
  22895. InfRefmsgid string `json:"inf_refmsgid"`
  22896. Infcode int64 `json:"infcode"`
  22897. Output struct {
  22898. HiRxNo string `json:"hi_rxno"`
  22899. PharCode string `json:"phar_code"`
  22900. PharName string `json:"phar_name"`
  22901. RxChkOpnn string `json:"rx_chk_opnn"`
  22902. RxChkTime string `json:"rx_chk_time"`
  22903. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22904. RxChkStasName string `json:"rx_chk_stas_name"`
  22905. RxStasCodg string `json:"rx_stas_codg"`
  22906. RxStasName string `json:"rx_stas_name"`
  22907. } `json:"output"`
  22908. RefmsgTime string `json:"refmsg_time"`
  22909. RespondTime string `json:"respond_time"`
  22910. Signtype interface{} `json:"signtype"`
  22911. WarnInfo interface{} `json:"warn_info"`
  22912. }
  22913. type ResultFourteen10265 struct {
  22914. ErrMsg string `json:"err_msg"`
  22915. InfRefmsgid string `json:"inf_refmsgid"`
  22916. Infcode string `json:"infcode"`
  22917. Output struct {
  22918. } `json:"output"`
  22919. RefmsgTime string `json:"refmsg_time"`
  22920. RespondTime string `json:"respond_time"`
  22921. Signtype interface{} `json:"signtype"`
  22922. WarnInfo interface{} `json:"warn_info"`
  22923. }
  22924. type ResultSixteen struct {
  22925. Cainfo string `json:"cainfo"`
  22926. ErrMsg string `json:"err_msg"`
  22927. InfRefmsgid string `json:"inf_refmsgid"`
  22928. Infcode int64 `json:"infcode"`
  22929. Output struct {
  22930. Setlinfo struct {
  22931. MdtrtID string `json:"mdtrt_id"`
  22932. SetlID string `json:"setl_id"`
  22933. ClrOptins string `json:"clr_optins"`
  22934. SetlTime string `json:"setl_time"`
  22935. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22936. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22937. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22938. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22939. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22940. ActPayDedc float64 `json:"act_pay_dedc"`
  22941. HifpPay float64 `json:"hifp_pay"`
  22942. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22943. Lfpay float64 `json:"selfpay"`
  22944. CvlservPay float64 `json:"cvlserv_pay"`
  22945. HifesPay float64 `json:"hifes_pay"`
  22946. HifmiPay float64 `json:"hifmi_pay"`
  22947. HifobPay float64 `json:"hifob_pay"`
  22948. MafPay float64 `json:"maf_pay"`
  22949. OthPay float64 `json:"oth_pay"`
  22950. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22951. PsnPartAmt float64 `json:"psn_part_amt"`
  22952. AcctPay float64 `json:"acct_pay"`
  22953. Balc float64 `json:"balc"`
  22954. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22955. HospPartAmt float64 `json:"hosp_part_amt"`
  22956. MedinsSetlID string `json:"medins_setl_id"`
  22957. PdnCashPay string `json:"pdn_cash_pay"`
  22958. } `json:"setlinfo"`
  22959. } `json:"output"`
  22960. RefmsgTime string `json:"refmsg_time"`
  22961. RespondTime string `json:"respond_time"`
  22962. Signtype interface{} `json:"signtype"`
  22963. WarnMsg interface{} `json:"warn_msg"`
  22964. }
  22965. type ResultSixteen10265 struct {
  22966. Cainfo string `json:"cainfo"`
  22967. ErrMsg string `json:"err_msg"`
  22968. InfRefmsgid string `json:"inf_refmsgid"`
  22969. Infcode string `json:"infcode"`
  22970. Output struct {
  22971. Setlinfo struct {
  22972. MdtrtID string `json:"mdtrt_id"`
  22973. SetlID string `json:"setl_id"`
  22974. ClrOptins string `json:"clr_optins"`
  22975. SetlTime string `json:"setl_time"`
  22976. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22977. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22978. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22979. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22980. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22981. ActPayDedc float64 `json:"act_pay_dedc"`
  22982. HifpPay float64 `json:"hifp_pay"`
  22983. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22984. Lfpay float64 `json:"selfpay"`
  22985. CvlservPay float64 `json:"cvlserv_pay"`
  22986. HifesPay float64 `json:"hifes_pay"`
  22987. HifmiPay float64 `json:"hifmi_pay"`
  22988. HifobPay float64 `json:"hifob_pay"`
  22989. MafPay float64 `json:"maf_pay"`
  22990. OthPay float64 `json:"oth_pay"`
  22991. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22992. PsnPartAmt float64 `json:"psn_part_amt"`
  22993. AcctPay float64 `json:"acct_pay"`
  22994. Balc float64 `json:"balc"`
  22995. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22996. HospPartAmt float64 `json:"hosp_part_amt"`
  22997. MedinsSetlID string `json:"medins_setl_id"`
  22998. PdnCashPay string `json:"pdn_cash_pay"`
  22999. } `json:"setlinfo"`
  23000. } `json:"output"`
  23001. RefmsgTime string `json:"refmsg_time"`
  23002. RespondTime string `json:"respond_time"`
  23003. Signtype interface{} `json:"signtype"`
  23004. WarnMsg interface{} `json:"warn_msg"`
  23005. }
  23006. type ResultSixteen10265Two struct {
  23007. Cainfo string `json:"cainfo"`
  23008. ErrMsg string `json:"err_msg"`
  23009. InfRefmsgid string `json:"inf_refmsgid"`
  23010. Infcode string `json:"infcode"`
  23011. Output struct {
  23012. Setlinfo interface{} `json:"setlinfo"`
  23013. } `json:"output"`
  23014. RefmsgTime string `json:"refmsg_time"`
  23015. RespondTime string `json:"respond_time"`
  23016. Signtype interface{} `json:"signtype"`
  23017. WarnMsg interface{} `json:"warn_msg"`
  23018. }
  23019. type ResultgzSixteen10265Two struct {
  23020. Cainfo string `json:"cainfo"`
  23021. ErrMsg string `json:"err_msg"`
  23022. InfRefmsgid string `json:"inf_refmsgid"`
  23023. Infcode int64 `json:"infcode"`
  23024. Output struct {
  23025. Setlinfo interface{} `json:"setlinfo"`
  23026. } `json:"output"`
  23027. RefmsgTime string `json:"refmsg_time"`
  23028. RespondTime string `json:"respond_time"`
  23029. Signtype interface{} `json:"signtype"`
  23030. WarnMsg interface{} `json:"warn_msg"`
  23031. }
  23032. type ResultSeventeen struct {
  23033. ErrMsg string `json:"err_msg"`
  23034. InfRefmsgid string `json:"inf_refmsgid"`
  23035. Infcode int64 `json:"infcode"`
  23036. Output struct {
  23037. SetlListId string `json:"setl_list_id"`
  23038. } `json:"output"`
  23039. RefmsgTime string `json:"refmsg_time"`
  23040. RespondTime string `json:"respond_time"`
  23041. Signtype string `json:"signtype"`
  23042. WarnInfo string `json:"warn_info"`
  23043. }
  23044. type ResultSeventeenOther struct {
  23045. ErrMsg string `json:"err_msg"`
  23046. InfRefmsgid string `json:"inf_refmsgid"`
  23047. Infcode string `json:"infcode"`
  23048. Output struct {
  23049. SetlListId string `json:"setl_list_id"`
  23050. } `json:"output"`
  23051. RefmsgTime string `json:"refmsg_time"`
  23052. RespondTime string `json:"respond_time"`
  23053. Signtype string `json:"signtype"`
  23054. WarnInfo string `json:"warn_info"`
  23055. }
  23056. type Result90991 struct {
  23057. ErrMsg string `json:"err_msg"`
  23058. InfRefmsgid string `json:"inf_refmsgid"`
  23059. Infcode int64 `json:"infcode"`
  23060. Output struct {
  23061. Result struct {
  23062. PsnNo string `json:"psn_no"`
  23063. CardStat string `json:"card_stat"`
  23064. Certno string `json:"certno"`
  23065. PsnName string `json:"psn_name"`
  23066. CheckStat string `json:"check_stat"`
  23067. SscnoCheckStat string `json:"sscno_check_stat"`
  23068. } `json:"result"`
  23069. } `json:"output"`
  23070. RefmsgTime string `json:"refmsg_time"`
  23071. RespondTime string `json:"respond_time"`
  23072. Signtype interface{} `json:"signtype"`
  23073. WarnInfo interface{} `json:"warn_info"`
  23074. }
  23075. type Result90100 struct {
  23076. ErrMsg string `json:"err_msg"`
  23077. InfRefmsgid string `json:"inf_refmsgid"`
  23078. Infcode int64 `json:"infcode"`
  23079. Output struct {
  23080. PoolareaNo string `json:"poolarea_no"`
  23081. PoolareaNoName string `json:"poolarea_no_name"`
  23082. Insutype string `json:"insutype"`
  23083. InsutypeName string `json:"insutype_name"`
  23084. ClctType string `json:"clct_type"`
  23085. ClctTypeName string `json:"clct_type_name"`
  23086. ClctFlag string `json:"clct_flag"`
  23087. ClctFlagName string `json:"clct_flag_name"`
  23088. AccrymBegn string `json:"accrym_begn"`
  23089. AccrymEnd string `json:"accrym_end"`
  23090. ClctTime string `json:"clct_time"`
  23091. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23092. } `json:"output"`
  23093. RefmsgTime string `json:"refmsg_time"`
  23094. RespondTime string `json:"respond_time"`
  23095. Signtype interface{} `json:"signtype"`
  23096. WarnInfo interface{} `json:"warn_info"`
  23097. }
  23098. type Custom struct {
  23099. DetItemFeeSumamt string
  23100. Cut string
  23101. FeedetlSn string
  23102. Price string
  23103. MedListCodg string
  23104. Type int64
  23105. AdviceId int64
  23106. ProjectId int64
  23107. ItemId int64
  23108. }
  23109. type Result5301 struct {
  23110. ErrMsg string `json:"err_msg"`
  23111. InfRefmsgid string `json:"inf_refmsgid"`
  23112. Infcode int64 `json:"infcode"`
  23113. Output struct {
  23114. Result []struct {
  23115. OpspDiseCode string `json:"opsp_dise_code"`
  23116. OpspDiseName string `json:"opsp_dise_name"`
  23117. Begndate string `json:"begndate"`
  23118. Enddate string `json:"enddate"`
  23119. } `json:"feedetail"`
  23120. } `json:"output"`
  23121. RefmsgTime string `json:"refmsg_time"`
  23122. RespondTime string `json:"respond_time"`
  23123. Signtype interface{} `json:"signtype"`
  23124. WarnInfo interface{} `json:"warn_info"`
  23125. }
  23126. type Result5301For10265 struct {
  23127. ErrMsg string `json:"err_msg"`
  23128. InfRefmsgid string `json:"inf_refmsgid"`
  23129. Infcode string `json:"infcode"`
  23130. Output struct {
  23131. Result []struct {
  23132. OpspDiseCode string `json:"opsp_dise_code"`
  23133. OpspDiseName string `json:"opsp_dise_name"`
  23134. Begndate string `json:"begndate"`
  23135. Enddate string `json:"enddate"`
  23136. } `json:"feedetail"`
  23137. } `json:"output"`
  23138. RefmsgTime string `json:"refmsg_time"`
  23139. RespondTime string `json:"respond_time"`
  23140. Signtype interface{} `json:"signtype"`
  23141. WarnInfo interface{} `json:"warn_info"`
  23142. }
  23143. //获取个人信息----挂号-----上传就诊信息
  23144. func (c *HisApiController) GetRegisterInfo() {
  23145. id, _ := c.GetInt64("id")
  23146. record_time := c.GetString("record_time")
  23147. settlementValue, _ := c.GetInt64("settlement_value")
  23148. medical_insurance_card := c.GetString("medical_insurance_card")
  23149. name := c.GetString("name")
  23150. id_card_type, _ := c.GetInt64("id_card_type")
  23151. certificates, _ := c.GetInt64("certificates")
  23152. medical_care, _ := c.GetInt64("medical_care")
  23153. birthday := c.GetString("birthday")
  23154. id_card := c.GetString("id_card")
  23155. register_type, _ := c.GetInt64("register")
  23156. doctor, _ := c.GetInt64("doctor")
  23157. department, _ := c.GetInt64("department")
  23158. gender, _ := c.GetInt64("sex")
  23159. registration_fee, _ := c.GetFloat("registration_fee")
  23160. medical_expenses, _ := c.GetFloat("medical_expenses")
  23161. social_type, _ := c.GetInt64("social_type")
  23162. admin_user_id, _ := c.GetInt64("admin_user_id")
  23163. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23164. mdtrt_type := c.GetString("mdtrt_type")
  23165. if id_card_type == 5 {
  23166. id_card_type = 4
  23167. }
  23168. timeLayout := "2006-01-02"
  23169. loc, _ := time.LoadLocation("Local")
  23170. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23171. birthUnix := birthdays.Unix()
  23172. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23173. if err != nil {
  23174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23175. return
  23176. }
  23177. recordDateTime := theTime.Unix()
  23178. adminInfo := c.GetAdminUserInfo()
  23179. var patient service.Patients
  23180. if id == 0 {
  23181. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23182. } else {
  23183. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23184. }
  23185. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23186. if patientPrescription.ID == 0 {
  23187. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23188. }
  23189. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23190. if patient.ID == 0 {
  23191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23192. return
  23193. }
  23194. if len(patient.IdCardNo) == 0 {
  23195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23196. return
  23197. }
  23198. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23199. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23200. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23201. //就诊结算未完成,不能进行二次挂号
  23202. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23203. if len(his) >= 1 {
  23204. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23205. if len(his) >= 1 && order.ID == 0 {
  23206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23207. return
  23208. }
  23209. }
  23210. //var register_log string
  23211. if config.IsOpen == 1 {
  23212. var res ResultTwo
  23213. var res10265 ResultTwo10265
  23214. var PsnNo string
  23215. var PsnCertType string
  23216. var Certno string
  23217. var PsnName string
  23218. var Gend string
  23219. var Naty string
  23220. var Brdy string
  23221. var Age float64
  23222. var infoStr string
  23223. var idetinfoStr string
  23224. var infocode int64
  23225. var verify_number string
  23226. fmt.Println(verify_number)
  23227. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23228. psn_info, _ := service.GetPsnByPatientId(id)
  23229. PsnNo = psn_info.PsnNo
  23230. PsnCertType = psn_info.PsnCertType
  23231. Certno = psn_info.Certno
  23232. PsnName = psn_info.PsnName
  23233. Gend = psn_info.Gend
  23234. Naty = psn_info.Naty
  23235. Brdy = psn_info.Brdy
  23236. Age = psn_info.Age
  23237. infoStr = psn_info.Insuinfo
  23238. idetinfoStr = psn_info.Idetinfo
  23239. infocode = 0
  23240. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23241. psn_info, _ := service.GetPsnByPatientId(id)
  23242. PsnNo = psn_info.PsnNo
  23243. PsnCertType = psn_info.PsnCertType
  23244. Certno = psn_info.Certno
  23245. PsnName = psn_info.PsnName
  23246. Gend = psn_info.Gend
  23247. Naty = psn_info.Naty
  23248. Brdy = psn_info.Brdy
  23249. Age = psn_info.Age
  23250. infoStr = psn_info.Insuinfo
  23251. idetinfoStr = psn_info.Idetinfo
  23252. infocode = 0
  23253. verify_number = psn_info.VerifyNumber
  23254. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23255. if id_card_type == 2 {
  23256. //请求内网数据
  23257. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23258. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23259. "&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
  23260. resp, requestErr := http.Get(api)
  23261. if requestErr != nil {
  23262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23263. return
  23264. }
  23265. body, ioErr := ioutil.ReadAll(resp.Body)
  23266. if ioErr != nil {
  23267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23269. return
  23270. }
  23271. var respJSON map[string]interface{}
  23272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23275. return
  23276. }
  23277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23278. result_byte, _ := json.Marshal(respJSON)
  23279. result := string(result_byte)
  23280. var dat map[string]interface{}
  23281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23282. fmt.Println(dat)
  23283. } else {
  23284. fmt.Println(err)
  23285. }
  23286. userJSONBytes, _ := json.Marshal(dat)
  23287. var res ResultTwo
  23288. var resTwo10265 ResultTwo10265
  23289. if miConfig.Code == "H15049901371" {
  23290. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23291. utils.ErrorLog("解析失败:%v", err)
  23292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23293. return
  23294. }
  23295. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23296. res.Infcode = Infcode
  23297. res.ErrMsg = resTwo10265.ErrMsg
  23298. res.Output = resTwo10265.Output
  23299. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23300. res.RespondTime = resTwo10265.RespondTime
  23301. res.WarnInfo = resTwo10265.WarnInfo
  23302. } else {
  23303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23304. utils.ErrorLog("解析失败:%v", err)
  23305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23306. return
  23307. }
  23308. }
  23309. //var insutypes []string
  23310. //var insutype string
  23311. //var is390 int = 0
  23312. //var is310 int = 0
  23313. //for _, item := range res.Output.Iinfo {
  23314. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23315. // insutypes = append(insutypes, item.Insutype)
  23316. // }
  23317. //}
  23318. //if len(insutypes) == 1 {
  23319. // insutype = insutypes[0]
  23320. //} else {
  23321. // for _, i := range insutypes {
  23322. // if i == "390" {
  23323. // is390 = 1
  23324. // }
  23325. //
  23326. // if i == "310" {
  23327. // is310 = 1
  23328. // }
  23329. // }
  23330. //}
  23331. //if is390 == 1 {
  23332. // insutype = "390"
  23333. //}
  23334. //if is310 == 1 {
  23335. // insutype = "310"
  23336. //}
  23337. //if len(insutypes) == 0 {
  23338. // insutype = "310"
  23339. //}
  23340. PsnNo = res.Output.Baseinfo.PsnNo
  23341. PsnCertType = res.Output.Baseinfo.PsnCertType
  23342. Certno = res.Output.Baseinfo.Certno
  23343. PsnName = res.Output.Baseinfo.PsnName
  23344. Gend = res.Output.Baseinfo.Gend
  23345. Naty = res.Output.Baseinfo.Naty
  23346. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23347. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23348. infoStr = string(Iinfos)
  23349. idetinfoStr = string(Idetinfos)
  23350. infocode = res.Infcode
  23351. //infocode = 0
  23352. //verify_number = psn_info.VerifyNumber
  23353. } else {
  23354. psn_info, _ := service.GetPsnByPatientId(id)
  23355. PsnNo = psn_info.PsnNo
  23356. PsnCertType = psn_info.PsnCertType
  23357. Certno = psn_info.Certno
  23358. PsnName = psn_info.PsnName
  23359. Gend = psn_info.Gend
  23360. Naty = psn_info.Naty
  23361. Brdy = psn_info.Brdy
  23362. Age = psn_info.Age
  23363. infoStr = psn_info.Insuinfo
  23364. idetinfoStr = psn_info.Idetinfo
  23365. infocode = 0
  23366. verify_number = psn_info.VerifyNumber
  23367. }
  23368. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23369. if id_card_type == 1 {
  23370. psn_info, _ := service.GetPsnByPatientId(id)
  23371. PsnNo = psn_info.PsnNo
  23372. PsnCertType = psn_info.PsnCertType
  23373. Certno = psn_info.Certno
  23374. PsnName = psn_info.PsnName
  23375. Gend = psn_info.Gend
  23376. Naty = psn_info.Naty
  23377. Brdy = psn_info.Brdy
  23378. Age = psn_info.Age
  23379. infoStr = psn_info.Insuinfo
  23380. idetinfoStr = psn_info.Idetinfo
  23381. infocode = 0
  23382. verify_number = psn_info.VerifyNumber
  23383. } else if id_card_type == 2 {
  23384. 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)
  23385. fmt.Println(errMsgLog)
  23386. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23388. utils.ErrorLog("解析失败:%v", err)
  23389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23390. return
  23391. }
  23392. PsnNo = res.Output.Baseinfo.PsnNo
  23393. PsnCertType = res.Output.Baseinfo.PsnCertType
  23394. Certno = res.Output.Baseinfo.Certno
  23395. PsnName = res.Output.Baseinfo.PsnName
  23396. Gend = res.Output.Baseinfo.Gend
  23397. Naty = res.Output.Baseinfo.Naty
  23398. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23399. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23400. infoStr = string(Iinfos)
  23401. idetinfoStr = string(Idetinfos)
  23402. infocode = res.Infcode
  23403. }
  23404. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23405. if id_card_type == 1 {
  23406. psn_info, _ := service.GetPsnByPatientId(id)
  23407. PsnNo = psn_info.PsnNo
  23408. PsnCertType = psn_info.PsnCertType
  23409. Certno = psn_info.Certno
  23410. PsnName = psn_info.PsnName
  23411. Gend = psn_info.Gend
  23412. Naty = psn_info.Naty
  23413. Brdy = psn_info.Brdy
  23414. Age = psn_info.Age
  23415. infoStr = psn_info.Insuinfo
  23416. idetinfoStr = psn_info.Idetinfo
  23417. infocode = 0
  23418. verify_number = psn_info.VerifyNumber
  23419. } else if id_card_type == 2 {
  23420. 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, "")
  23421. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23422. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23423. utils.ErrorLog("解析失败:%v", err)
  23424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23425. return
  23426. }
  23427. PsnNo = res.Output.Baseinfo.PsnNo
  23428. PsnCertType = res.Output.Baseinfo.PsnCertType
  23429. Certno = res.Output.Baseinfo.Certno
  23430. PsnName = res.Output.Baseinfo.PsnName
  23431. Gend = res.Output.Baseinfo.Gend
  23432. Naty = res.Output.Baseinfo.Naty
  23433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23435. infoStr = string(Iinfos)
  23436. idetinfoStr = string(Idetinfos)
  23437. infocode = res.Infcode
  23438. } else {
  23439. psn_info, _ := service.GetPsnByPatientId(id)
  23440. PsnNo = psn_info.PsnNo
  23441. PsnCertType = psn_info.PsnCertType
  23442. Certno = psn_info.Certno
  23443. PsnName = psn_info.PsnName
  23444. Gend = psn_info.Gend
  23445. Naty = psn_info.Naty
  23446. Brdy = psn_info.Brdy
  23447. Age = psn_info.Age
  23448. infoStr = psn_info.Insuinfo
  23449. idetinfoStr = psn_info.Idetinfo
  23450. infocode = 0
  23451. verify_number = psn_info.VerifyNumber
  23452. }
  23453. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23454. if id_card_type == 1 {
  23455. psn_info, _ := service.GetPsnByPatientId(id)
  23456. PsnNo = psn_info.PsnNo
  23457. PsnCertType = psn_info.PsnCertType
  23458. Certno = psn_info.Certno
  23459. PsnName = psn_info.PsnName
  23460. Gend = psn_info.Gend
  23461. Naty = psn_info.Naty
  23462. Brdy = psn_info.Brdy
  23463. Age = psn_info.Age
  23464. infoStr = psn_info.Insuinfo
  23465. idetinfoStr = psn_info.Idetinfo
  23466. infocode = 0
  23467. verify_number = psn_info.VerifyNumber
  23468. } else if id_card_type == 2 {
  23469. psn_info, _ := service.GetPsnByPatientId(id)
  23470. PsnNo = psn_info.PsnNo
  23471. PsnCertType = psn_info.PsnCertType
  23472. Certno = psn_info.Certno
  23473. PsnName = psn_info.PsnName
  23474. Gend = psn_info.Gend
  23475. Naty = psn_info.Naty
  23476. Brdy = psn_info.Brdy
  23477. Age = psn_info.Age
  23478. infoStr = psn_info.Insuinfo
  23479. idetinfoStr = psn_info.Idetinfo
  23480. infocode = 0
  23481. verify_number = psn_info.VerifyNumber
  23482. } else {
  23483. psn_info, _ := service.GetPsnByPatientId(id)
  23484. PsnNo = psn_info.PsnNo
  23485. PsnCertType = psn_info.PsnCertType
  23486. Certno = psn_info.Certno
  23487. PsnName = psn_info.PsnName
  23488. Gend = psn_info.Gend
  23489. Naty = psn_info.Naty
  23490. Brdy = psn_info.Brdy
  23491. Age = psn_info.Age
  23492. infoStr = psn_info.Insuinfo
  23493. idetinfoStr = psn_info.Idetinfo
  23494. infocode = 0
  23495. verify_number = psn_info.VerifyNumber
  23496. }
  23497. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23498. psn_info, _ := service.GetPsnByPatientId(id)
  23499. PsnNo = psn_info.PsnNo
  23500. PsnCertType = psn_info.PsnCertType
  23501. Certno = psn_info.Certno
  23502. PsnName = psn_info.PsnName
  23503. Gend = psn_info.Gend
  23504. Naty = psn_info.Naty
  23505. Brdy = psn_info.Brdy
  23506. Age = psn_info.Age
  23507. infoStr = psn_info.Insuinfo
  23508. idetinfoStr = psn_info.Idetinfo
  23509. infocode = 0
  23510. verify_number = psn_info.VerifyNumber
  23511. idetinfoStr = psn_info.Idetinfo
  23512. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23513. if id_card_type == 1 {
  23514. psn_info, _ := service.GetPsnByPatientId(id)
  23515. PsnNo = psn_info.PsnNo
  23516. PsnCertType = psn_info.PsnCertType
  23517. Certno = psn_info.Certno
  23518. PsnName = psn_info.PsnName
  23519. Gend = psn_info.Gend
  23520. Naty = psn_info.Naty
  23521. Brdy = psn_info.Brdy
  23522. Age = psn_info.Age
  23523. infoStr = psn_info.Insuinfo
  23524. idetinfoStr = psn_info.Idetinfo
  23525. infocode = 0
  23526. verify_number = psn_info.VerifyNumber
  23527. } else if id_card_type == 2 {
  23528. 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)
  23529. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23530. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23531. utils.ErrorLog("解析失败:%v", err)
  23532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23533. return
  23534. }
  23535. PsnNo = res.Output.Baseinfo.PsnNo
  23536. PsnCertType = res.Output.Baseinfo.PsnCertType
  23537. Certno = res.Output.Baseinfo.Certno
  23538. PsnName = res.Output.Baseinfo.PsnName
  23539. Gend = res.Output.Baseinfo.Gend
  23540. Naty = res.Output.Baseinfo.Naty
  23541. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23542. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23543. infoStr = string(Iinfos)
  23544. idetinfoStr = string(Idetinfos)
  23545. infocode = res.Infcode
  23546. } else if id_card_type == 4 {
  23547. psn_info, _ := service.GetPsnByPatientId(id)
  23548. PsnNo = psn_info.PsnNo
  23549. PsnCertType = psn_info.PsnCertType
  23550. Certno = psn_info.Certno
  23551. PsnName = psn_info.PsnName
  23552. Gend = psn_info.Gend
  23553. Naty = psn_info.Naty
  23554. Brdy = psn_info.Brdy
  23555. Age = psn_info.Age
  23556. infoStr = psn_info.Insuinfo
  23557. idetinfoStr = psn_info.Idetinfo
  23558. infocode = 0
  23559. verify_number = psn_info.VerifyNumber
  23560. }
  23561. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23562. var result string
  23563. var requestLog string
  23564. 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), "")
  23565. if id_card_type == 4 {
  23566. psn_info, _ := service.GetPsnByPatientId(id)
  23567. PsnNo = psn_info.PsnNo
  23568. PsnCertType = psn_info.PsnCertType
  23569. Certno = psn_info.Certno
  23570. PsnName = psn_info.PsnName
  23571. Gend = psn_info.Gend
  23572. Naty = psn_info.Naty
  23573. Brdy = psn_info.Brdy
  23574. Age = psn_info.Age
  23575. infoStr = psn_info.Insuinfo
  23576. idetinfoStr = psn_info.Idetinfo
  23577. infocode = 0
  23578. verify_number = psn_info.VerifyNumber
  23579. } else {
  23580. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23581. if miConfig.Code == "H15049901371" {
  23582. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23583. utils.ErrorLog("解析失败:%v", err)
  23584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23585. return
  23586. }
  23587. res.ErrMsg = res10265.ErrMsg
  23588. res.Output = res10265.Output
  23589. res.InfRefmsgid = res10265.InfRefmsgid
  23590. } else {
  23591. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23592. utils.ErrorLog("解析失败:%v", err)
  23593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23594. return
  23595. }
  23596. }
  23597. PsnNo = res.Output.Baseinfo.PsnNo
  23598. PsnCertType = res.Output.Baseinfo.PsnCertType
  23599. Certno = res.Output.Baseinfo.Certno
  23600. PsnName = res.Output.Baseinfo.PsnName
  23601. Gend = res.Output.Baseinfo.Gend
  23602. Naty = res.Output.Baseinfo.Naty
  23603. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23604. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23605. infoStr = string(Iinfos)
  23606. idetinfoStr = string(Idetinfos)
  23607. if miConfig.Code == "H15049901371" {
  23608. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23609. } else {
  23610. infocode = res.Infcode
  23611. }
  23612. }
  23613. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23614. psn_info, _ := service.GetPsnByPatientId(id)
  23615. PsnNo = psn_info.PsnNo
  23616. PsnCertType = psn_info.PsnCertType
  23617. Certno = psn_info.Certno
  23618. PsnName = psn_info.PsnName
  23619. Gend = psn_info.Gend
  23620. Naty = psn_info.Naty
  23621. Brdy = psn_info.Brdy
  23622. Age = psn_info.Age
  23623. infoStr = psn_info.Insuinfo
  23624. idetinfoStr = psn_info.Idetinfo
  23625. infocode = 0
  23626. verify_number = psn_info.VerifyNumber
  23627. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23628. psn_info, _ := service.GetPsnByPatientId(id)
  23629. PsnNo = psn_info.PsnNo
  23630. PsnCertType = psn_info.PsnCertType
  23631. Certno = psn_info.Certno
  23632. PsnName = psn_info.PsnName
  23633. Gend = psn_info.Gend
  23634. Naty = psn_info.Naty
  23635. Brdy = psn_info.Brdy
  23636. Age = psn_info.Age
  23637. infoStr = psn_info.Insuinfo
  23638. idetinfoStr = psn_info.Idetinfo
  23639. infocode = 0
  23640. verify_number = psn_info.VerifyNumber
  23641. } else {
  23642. var result string
  23643. var requestLog string
  23644. //if miConfig.UserOrgId == 10138 {
  23645. if id_card_type != 4 || id_card_type != 1 {
  23646. var insa string
  23647. if len(patient.InsuplcAdmdvs) > 0 {
  23648. insa = patient.InsuplcAdmdvs
  23649. } else {
  23650. insa = miConfig.InsuplcAdmdvs
  23651. }
  23652. //psn_info, _ := service.GetPsnByPatientId(id)
  23653. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23654. 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)
  23655. }
  23656. //}
  23657. //else {
  23658. // var insa string
  23659. // if len(patient.InsuplcAdmdvs) > 0 {
  23660. // insa = patient.InsuplcAdmdvs
  23661. // } else {
  23662. // insa = miConfig.InsuplcAdmdvs
  23663. // }
  23664. // 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)
  23665. //}
  23666. if id_card_type == 4 || id_card_type == 1 {
  23667. psn_info, _ := service.GetPsnByPatientId(id)
  23668. PsnNo = psn_info.PsnNo
  23669. PsnCertType = psn_info.PsnCertType
  23670. Certno = psn_info.Certno
  23671. PsnName = psn_info.PsnName
  23672. Gend = psn_info.Gend
  23673. Naty = psn_info.Naty
  23674. Brdy = psn_info.Brdy
  23675. Age = psn_info.Age
  23676. infoStr = psn_info.Insuinfo
  23677. idetinfoStr = psn_info.Idetinfo
  23678. infocode = 0
  23679. verify_number = psn_info.VerifyNumber
  23680. } else {
  23681. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23682. if miConfig.Code == "H15049901371" {
  23683. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23684. utils.ErrorLog("解析失败:%v", err)
  23685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23686. return
  23687. }
  23688. res.ErrMsg = res10265.ErrMsg
  23689. res.Output = res10265.Output
  23690. res.InfRefmsgid = res10265.InfRefmsgid
  23691. } else {
  23692. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23693. utils.ErrorLog("解析失败:%v", err)
  23694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23695. return
  23696. }
  23697. }
  23698. PsnNo = res.Output.Baseinfo.PsnNo
  23699. PsnCertType = res.Output.Baseinfo.PsnCertType
  23700. Certno = res.Output.Baseinfo.Certno
  23701. PsnName = res.Output.Baseinfo.PsnName
  23702. Gend = res.Output.Baseinfo.Gend
  23703. Naty = res.Output.Baseinfo.Naty
  23704. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23705. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23706. infoStr = string(Iinfos)
  23707. idetinfoStr = string(Idetinfos)
  23708. if miConfig.Code == "H15049901371" {
  23709. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23710. } else {
  23711. infocode = res.Infcode
  23712. }
  23713. }
  23714. }
  23715. if infocode == 0 {
  23716. his := models.VMHisPatient{
  23717. Name: name,
  23718. Gender: gender,
  23719. Birthday: birthUnix,
  23720. MedicalTreatmentType: medical_care,
  23721. IdType: certificates,
  23722. IdCardNo: id_card,
  23723. BalanceAccountsType: settlementValue,
  23724. SocialType: social_type,
  23725. MedicalInsuranceNumber: medical_insurance_card,
  23726. RegisterType: register_type,
  23727. RegisterCost: registration_fee,
  23728. TreatmentCost: medical_expenses,
  23729. Status: 1,
  23730. Ctime: time.Now().Unix(),
  23731. Mtime: time.Now().Unix(),
  23732. PsnNo: PsnNo,
  23733. PsnCertType: PsnCertType,
  23734. Certno: Certno,
  23735. PsnName: PsnName,
  23736. Gend: Gend,
  23737. Naty: Naty,
  23738. Brdy: Brdy,
  23739. Age: Age,
  23740. Iinfo: infoStr,
  23741. Idetinfo: idetinfoStr,
  23742. PatientId: patient.ID,
  23743. RecordDate: theTime.Unix(),
  23744. UserOrgId: adminInfo.CurrentOrgId,
  23745. AdminUserId: admin_user_id,
  23746. IsReturn: 1,
  23747. IdCardType: id_card_type,
  23748. Doctor: doctor,
  23749. Departments: department,
  23750. MdtrtGrpType: mdtrt_type,
  23751. }
  23752. timestamp := time.Now().Unix()
  23753. tempTime := time.Unix(timestamp, 0)
  23754. timeFormat := tempTime.Format("20060102150405")
  23755. chrgBchno := rand.Intn(100000) + 10000
  23756. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23757. his.Number = ipt_otp_no
  23758. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23759. department, _ := service.GetDepartMentDetail(department)
  23760. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23761. IdCardNo := ""
  23762. if id_card_type == 1 {
  23763. // IdCardNo = medical_insurance_card
  23764. IdCardNo = patient.IdCardNo
  23765. } else {
  23766. IdCardNo = patient.IdCardNo
  23767. }
  23768. var rf []*ResultFive
  23769. json.Unmarshal([]byte(his.Iinfo), &rf)
  23770. var insutypes []*ResultFive
  23771. var insutype string
  23772. var insuplc_admdvs_temp string
  23773. var is390 int = 0
  23774. var is310 int = 0
  23775. for _, item := range rf {
  23776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23777. insutypes = append(insutypes, item)
  23778. }
  23779. }
  23780. if len(insutypes) == 1 {
  23781. insutype = insutypes[0].Insutype
  23782. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23783. if insutype == "390" {
  23784. is390 = 1
  23785. }
  23786. if insutype == "310" {
  23787. is310 = 1
  23788. }
  23789. } else {
  23790. for _, i := range insutypes {
  23791. if i.Insutype == "390" {
  23792. is390 = 1
  23793. }
  23794. if i.Insutype == "310" {
  23795. is310 = 1
  23796. }
  23797. }
  23798. }
  23799. if is390 == 1 {
  23800. insutype = "390"
  23801. }
  23802. if is310 == 1 {
  23803. insutype = "310"
  23804. }
  23805. fmt.Println(social_type)
  23806. if social_type > 0 {
  23807. insutype = strconv.FormatInt(social_type, 10)
  23808. }
  23809. var infocode int64
  23810. var resThree ResultThree
  23811. var resThree10265 ResultThree10265
  23812. if len(insuplc_admdvs) == 0 {
  23813. psn_info, _ := service.GetPsnByPatientId(id)
  23814. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23815. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23816. //}
  23817. } else {
  23818. insuplc_admdvs_temp = insuplc_admdvs
  23819. }
  23820. if miConfig.MdtrtareaAdmvs == "421300" {
  23821. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23822. psn_info, _ := service.GetPsnByPatientId(id)
  23823. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23824. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23825. "&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
  23826. resp, requestErr := http.Get(api)
  23827. if requestErr != nil {
  23828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23829. return
  23830. }
  23831. body, ioErr := ioutil.ReadAll(resp.Body)
  23832. if ioErr != nil {
  23833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23835. return
  23836. }
  23837. var respJSON map[string]interface{}
  23838. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23841. return
  23842. }
  23843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23844. result, _ := json.Marshal(respJSON)
  23845. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23846. utils.ErrorLog("解析失败:%v", err)
  23847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23848. return
  23849. }
  23850. infocode = resThree.Infcode
  23851. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23852. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23853. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23854. // insuplc_admdvs_temp =
  23855. //}
  23856. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23857. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23858. //}
  23859. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23860. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23861. "&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
  23862. resp, requestErr := http.Get(api)
  23863. if requestErr != nil {
  23864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23865. return
  23866. }
  23867. body, ioErr := ioutil.ReadAll(resp.Body)
  23868. if ioErr != nil {
  23869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23871. return
  23872. }
  23873. var respJSON map[string]interface{}
  23874. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23877. return
  23878. }
  23879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23880. result, _ := json.Marshal(respJSON)
  23881. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23882. utils.ErrorLog("解析失败:%v", err)
  23883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23884. return
  23885. }
  23886. infocode = resThree.Infcode
  23887. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23888. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23889. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23890. // insuplc_admdvs_temp =
  23891. //}
  23892. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23893. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23894. //}
  23895. utils.ErrorLog("解析失败:%v", insutype)
  23896. utils.ErrorLog("解析失败:%v", PsnNo)
  23897. utils.ErrorLog("解析失败:%v", Certno)
  23898. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23899. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23900. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23901. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23902. utils.ErrorLog("解析失败:%v", PsnNo)
  23903. utils.ErrorLog("解析失败:%v", department.Number)
  23904. utils.ErrorLog("解析失败:%v", department.Name)
  23905. utils.ErrorLog("解析失败:%v", roles.UserName)
  23906. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23907. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23908. "&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
  23909. resp, requestErr := http.Get(api)
  23910. if requestErr != nil {
  23911. utils.ErrorLog("解析失败:%v", requestErr)
  23912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23913. return
  23914. }
  23915. body, ioErr := ioutil.ReadAll(resp.Body)
  23916. if ioErr != nil {
  23917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23919. return
  23920. }
  23921. var respJSON map[string]interface{}
  23922. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23925. return
  23926. }
  23927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23928. result, _ := json.Marshal(respJSON)
  23929. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23930. utils.ErrorLog("解析失败:%v", err)
  23931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23932. return
  23933. }
  23934. infocode = resThree.Infcode
  23935. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23936. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23937. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23938. // insuplc_admdvs_temp =
  23939. //}
  23940. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23941. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23942. //}
  23943. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23944. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23945. "&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
  23946. resp, requestErr := http.Get(api)
  23947. if requestErr != nil {
  23948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23949. return
  23950. }
  23951. body, ioErr := ioutil.ReadAll(resp.Body)
  23952. if ioErr != nil {
  23953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23955. return
  23956. }
  23957. var respJSON map[string]interface{}
  23958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23961. return
  23962. }
  23963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23964. result, _ := json.Marshal(respJSON)
  23965. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23966. utils.ErrorLog("解析失败:%v", err)
  23967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23968. return
  23969. }
  23970. infocode = resThree.Infcode
  23971. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23972. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23973. psn_info, _ := service.GetPsnByPatientId(id)
  23974. var verify_number string
  23975. if id_card_type == 4 {
  23976. verify_number = psn_info.VerifyNumber
  23977. } else if id_card_type == 1 {
  23978. bas := strings.Split(psn_info.CardInfo, "|")
  23979. cardNumber := bas[2]
  23980. verify_number = cardNumber
  23981. }
  23982. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23983. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23984. "&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
  23985. resp, requestErr := http.Get(api)
  23986. if requestErr != nil {
  23987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23988. return
  23989. }
  23990. body, ioErr := ioutil.ReadAll(resp.Body)
  23991. if ioErr != nil {
  23992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23994. return
  23995. }
  23996. var respJSON map[string]interface{}
  23997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. return
  24001. }
  24002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24003. result, _ := json.Marshal(respJSON)
  24004. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24005. // utils.ErrorLog("解析失败:%v", err)
  24006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24007. // return
  24008. //}
  24009. //infocode = resThree.Infcode
  24010. //result, _ := json.Marshal(respJSON)
  24011. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24012. utils.ErrorLog("解析失败:%v", err)
  24013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24014. return
  24015. }
  24016. resThree.ErrMsg = resThree10265.ErrMsg
  24017. resThree.Output = resThree10265.Output
  24018. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24019. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24020. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24021. psn_info, _ := service.GetPsnByPatientId(id)
  24022. his.PsnNo = psn_info.PsnNo
  24023. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24024. var cert_no string
  24025. if id_card_type == 3 {
  24026. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24027. cert_no = IdCardNo
  24028. } else if id_card_type == 4 {
  24029. cert_no = IdCardNo
  24030. psn_info.VerifyNumber = psn_info.VerifyNumber
  24031. } else {
  24032. bas := strings.Split(psn_info.CardInfo, "|")
  24033. cert_no = bas[2]
  24034. }
  24035. var hisPrescription []*models.HisPrescription
  24036. for _, item := range rf {
  24037. if item.Insutype == insutype {
  24038. //insuplc_admdvs = item.InsuplcAdmdvs
  24039. his.InsuplcAdmdvs = insuplc_admdvs
  24040. }
  24041. }
  24042. his.Insutype = insutype
  24043. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24044. fmt.Println(res3101)
  24045. fmt.Println(res3101.Infcode)
  24046. if res3101.Infcode == "0" {
  24047. fmt.Println("33333333")
  24048. if len(res3101.Output.Result) > 0 {
  24049. fmt.Println("222222")
  24050. for _, item := range res3101.Output.Result {
  24051. if len(res3101.ErrMsg) == 0 {
  24052. res3101.ErrMsg = item.VolaCont
  24053. } else {
  24054. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24055. }
  24056. }
  24057. c.ServeSuccessJSON(map[string]interface{}{
  24058. "failed_code": -10,
  24059. "msg": res3101.ErrMsg,
  24060. })
  24061. return
  24062. } else {
  24063. fmt.Println("11111")
  24064. var api string
  24065. if miConfig.MdtrtareaAdmvs == "320921" {
  24066. ipt_otp_no = timeFormat
  24067. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24068. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24069. "&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
  24070. } else {
  24071. ipt_otp_no = timeFormat
  24072. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24073. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24074. "&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
  24075. }
  24076. resp, requestErr := http.Get(api)
  24077. if requestErr != nil {
  24078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24079. return
  24080. }
  24081. body, ioErr := ioutil.ReadAll(resp.Body)
  24082. if ioErr != nil {
  24083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24085. return
  24086. }
  24087. var respJSON map[string]interface{}
  24088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24091. return
  24092. }
  24093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24094. result, _ := json.Marshal(respJSON)
  24095. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24096. utils.ErrorLog("解析失败:%v", err)
  24097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24098. return
  24099. }
  24100. resThree.ErrMsg = resThree10265.ErrMsg
  24101. resThree.Output = resThree10265.Output
  24102. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24103. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24104. }
  24105. } else if res3101.Infcode != "0" {
  24106. c.ServeSuccessJSON(map[string]interface{}{
  24107. "failed_code": -10,
  24108. "msg": res3101.ErrMsg,
  24109. })
  24110. return
  24111. }
  24112. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24113. psn_info, _ := service.GetPsnByPatientId(id)
  24114. var cert_no string
  24115. if id_card_type == 1 {
  24116. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24117. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24118. } else if id_card_type == 4 {
  24119. cert_no = psn_info.VerifyNumber
  24120. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24121. } else {
  24122. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24123. cert_no = psn_info.VerifyNumber
  24124. }
  24125. 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)
  24126. saveLog(result, requestLog, "2201", "挂号")
  24127. if miConfig.Code == "H15049901371" {
  24128. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24129. utils.ErrorLog("解析失败:%v", err)
  24130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24131. return
  24132. }
  24133. resThree.ErrMsg = resThree10265.ErrMsg
  24134. resThree.Output = resThree10265.Output
  24135. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24136. } else {
  24137. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24138. utils.ErrorLog("解析失败:%v", err)
  24139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24140. return
  24141. }
  24142. }
  24143. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24144. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24145. psn_info, _ := service.GetPsnByPatientId(id)
  24146. var result string
  24147. var requestLog string
  24148. if id_card_type == 1 {
  24149. bas := strings.Split(psn_info.CardInfo, "|")
  24150. basNumber := bas[2]
  24151. card_sn := bas[3]
  24152. 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)
  24153. saveLog(result, requestLog, "2201A", "挂号")
  24154. } else if id_card_type == 2 {
  24155. 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, "", "", "", "", "", "")
  24156. saveLog(result, requestLog, "2201A", "挂号")
  24157. } else {
  24158. 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)
  24159. saveLog(result, requestLog, "2201A", "挂号")
  24160. }
  24161. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24162. utils.ErrorLog("解析失败:%v", err)
  24163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24164. return
  24165. }
  24166. infocode = resThree.Infcode
  24167. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24168. psn_info, _ := service.GetPsnByPatientId(id)
  24169. var result string
  24170. var requestLog string
  24171. if id_card_type == 1 {
  24172. bas := strings.Split(psn_info.CardInfo, "|")
  24173. basNumber := bas[2]
  24174. card_sn := ""
  24175. 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)
  24176. saveLog(result, requestLog, "2201A", "挂号")
  24177. } else if id_card_type == 2 {
  24178. 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, "", "", "", "", "", "")
  24179. saveLog(result, requestLog, "2201A", "挂号")
  24180. } else {
  24181. 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)
  24182. saveLog(result, requestLog, "2201A", "挂号")
  24183. }
  24184. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24185. utils.ErrorLog("解析失败:%v", err)
  24186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24187. return
  24188. }
  24189. infocode = resThree.Infcode
  24190. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24191. psn_info, _ := service.GetPsnByPatientId(id)
  24192. his.PsnNo = psn_info.PsnNo
  24193. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24194. var cert_no string
  24195. if id_card_type == 1 {
  24196. bas := strings.Split(psn_info.CardInfo, "|")
  24197. cert_no = bas[2]
  24198. } else if id_card_type == 4 {
  24199. cert_no = psn_info.VerifyNumber
  24200. psn_info.VerifyNumber = psn_info.VerifyNumber
  24201. IdCardNo = psn_info.VerifyNumber
  24202. } else {
  24203. cert_no = IdCardNo
  24204. psn_info.VerifyNumber = cert_no
  24205. }
  24206. for _, item := range rf {
  24207. if item.Insutype == insutype {
  24208. his.InsuplcAdmdvs = insuplc_admdvs
  24209. }
  24210. }
  24211. his.Insutype = insutype
  24212. var api string
  24213. ipt_otp_no = timeFormat
  24214. 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 +
  24215. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24216. "&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
  24217. resp, requestErr := http.Get(api)
  24218. if requestErr != nil {
  24219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24220. return
  24221. }
  24222. body, ioErr := ioutil.ReadAll(resp.Body)
  24223. if ioErr != nil {
  24224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24226. return
  24227. }
  24228. var respJSON map[string]interface{}
  24229. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24232. return
  24233. }
  24234. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24235. if status == "0" {
  24236. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24237. c.ServeSuccessJSON(map[string]interface{}{
  24238. "failed_code": -10,
  24239. "msg": err_msg,
  24240. })
  24241. return
  24242. }
  24243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24244. result, _ := json.Marshal(respJSON)
  24245. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24246. utils.ErrorLog("解析失败:%v", err)
  24247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24248. return
  24249. }
  24250. infocode = resThree.Infcode
  24251. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24252. psn_info, _ := service.GetPsnByPatientId(id)
  24253. his.PsnNo = psn_info.PsnNo
  24254. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24255. var cert_no string
  24256. if id_card_type == 1 {
  24257. bas := strings.Split(psn_info.CardInfo, "|")
  24258. cert_no = bas[2]
  24259. } else if id_card_type == 4 {
  24260. cert_no = psn_info.VerifyNumber
  24261. psn_info.VerifyNumber = psn_info.VerifyNumber
  24262. IdCardNo = psn_info.VerifyNumber
  24263. } else {
  24264. cert_no = IdCardNo
  24265. psn_info.VerifyNumber = cert_no
  24266. }
  24267. for _, item := range rf {
  24268. if item.Insutype == insutype {
  24269. his.InsuplcAdmdvs = insuplc_admdvs
  24270. patient.InsuplcAdmdvs = insuplc_admdvs
  24271. }
  24272. }
  24273. his.Insutype = insutype
  24274. var api string
  24275. ipt_otp_no = timeFormat
  24276. 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 +
  24277. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24278. "&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
  24279. resp, requestErr := http.Get(api)
  24280. if requestErr != nil {
  24281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24282. return
  24283. }
  24284. body, ioErr := ioutil.ReadAll(resp.Body)
  24285. if ioErr != nil {
  24286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24288. return
  24289. }
  24290. var respJSON map[string]interface{}
  24291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24294. return
  24295. }
  24296. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24297. if status == "0" {
  24298. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24299. c.ServeSuccessJSON(map[string]interface{}{
  24300. "failed_code": -10,
  24301. "msg": err_msg,
  24302. })
  24303. return
  24304. }
  24305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24306. result, _ := json.Marshal(respJSON)
  24307. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24308. utils.ErrorLog("解析失败:%v", err)
  24309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24310. return
  24311. }
  24312. infocode = resThree.Infcode
  24313. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24314. psn_info, _ := service.GetPsnByPatientId(id)
  24315. var result string
  24316. var requestLog string
  24317. if id_card_type == 1 {
  24318. bas := strings.Split(psn_info.CardInfo, "|")
  24319. basNumber := bas[2]
  24320. card_sn := bas[3]
  24321. 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)
  24322. saveLog(result, requestLog, "2201A", "挂号")
  24323. } else if id_card_type == 2 {
  24324. 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, "", "")
  24325. saveLog(result, requestLog, "2201A", "挂号")
  24326. } else {
  24327. 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, "", "")
  24328. saveLog(result, requestLog, "2201A", "挂号")
  24329. }
  24330. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24331. utils.ErrorLog("解析失败:%v", err)
  24332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24333. return
  24334. }
  24335. infocode = resThree.Infcode
  24336. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24337. psn_info, _ := service.GetPsnByPatientId(id)
  24338. 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)
  24339. saveLog(result, requestLog, "2201A", "挂号")
  24340. if miConfig.Code == "H15049901371" {
  24341. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24342. utils.ErrorLog("解析失败:%v", err)
  24343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24344. return
  24345. }
  24346. resThree.ErrMsg = resThree10265.ErrMsg
  24347. resThree.Output = resThree10265.Output
  24348. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24349. } else {
  24350. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24351. utils.ErrorLog("解析失败:%v", err)
  24352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24353. return
  24354. }
  24355. }
  24356. if miConfig.Code == "H15049901371" {
  24357. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24358. } else {
  24359. infocode = resThree.Infcode
  24360. }
  24361. } else {
  24362. psn_info, _ := service.GetPsnByPatientId(id)
  24363. if id_card_type == 4 || id_card_type == 1 {
  24364. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24365. }
  24366. var rf []*ResultFive
  24367. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24368. var insutypes []*ResultFive
  24369. var insutype string
  24370. var is390 int = 0
  24371. var is310 int = 0
  24372. for _, item := range rf {
  24373. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24374. insutypes = append(insutypes, item)
  24375. }
  24376. }
  24377. if len(insutypes) == 1 {
  24378. insutype = insutypes[0].Insutype
  24379. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24380. } else {
  24381. for _, i := range insutypes {
  24382. if i.Insutype == "390" {
  24383. is390 = 1
  24384. }
  24385. if i.Insutype == "310" {
  24386. is310 = 1
  24387. }
  24388. }
  24389. }
  24390. if is390 == 1 {
  24391. insutype = "390"
  24392. }
  24393. if is310 == 1 {
  24394. insutype = "310"
  24395. }
  24396. fmt.Println(len(insutypes))
  24397. if len(insutypes) == 0 {
  24398. for index, item := range rf {
  24399. if index == 0 {
  24400. insutype = item.Insutype
  24401. insuplc_admdvs = item.InsuplcAdmdvs
  24402. }
  24403. }
  24404. fmt.Println(insutype)
  24405. fmt.Println(insuplc_admdvs)
  24406. }
  24407. if social_type > 0 {
  24408. insutype = strconv.FormatInt(social_type, 10)
  24409. }
  24410. fmt.Println("--------")
  24411. fmt.Println(psn_info)
  24412. fmt.Println(psn_info.PsnNo)
  24413. if miConfig.MdtrtareaAdmvs == "441202" {
  24414. var hisPrescription []*models.HisPrescription
  24415. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24416. if res3101.Infcode == 0 {
  24417. fmt.Println("33333333")
  24418. if len(res3101.Output.Result) > 0 {
  24419. fmt.Println("222222")
  24420. for _, item := range res3101.Output.Result {
  24421. if len(res3101.ErrMsg) == 0 {
  24422. res3101.ErrMsg = item.VolaCont
  24423. } else {
  24424. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24425. }
  24426. }
  24427. c.ServeSuccessJSON(map[string]interface{}{
  24428. "failed_code": -10,
  24429. "msg": res3101.ErrMsg,
  24430. })
  24431. return
  24432. } else {
  24433. hour := time.Now().Format("15")
  24434. min := time.Now().Format("04")
  24435. sec := time.Now().Format("05")
  24436. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24437. fmt.Println(record_time_two)
  24438. 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)
  24439. saveLog(result, requestLog, "2201A", "挂号")
  24440. if miConfig.Code == "H15049901371" {
  24441. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24442. utils.ErrorLog("解析失败:%v", err)
  24443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24444. return
  24445. }
  24446. resThree.ErrMsg = resThree10265.ErrMsg
  24447. resThree.Output = resThree10265.Output
  24448. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24449. } else {
  24450. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24451. utils.ErrorLog("解析失败:%v", err)
  24452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24453. return
  24454. }
  24455. }
  24456. if miConfig.Code == "H15049901371" {
  24457. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24458. } else {
  24459. infocode = resThree.Infcode
  24460. }
  24461. }
  24462. } else if res3101.Infcode != 0 {
  24463. c.ServeSuccessJSON(map[string]interface{}{
  24464. "failed_code": -10,
  24465. "msg": res3101.ErrMsg,
  24466. })
  24467. return
  24468. }
  24469. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24470. var hisPrescription []*models.HisPrescription
  24471. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24472. if res3101.Infcode == 0 {
  24473. fmt.Println("33333333")
  24474. if len(res3101.Output.Result) > 0 {
  24475. fmt.Println("222222")
  24476. for _, item := range res3101.Output.Result {
  24477. if len(res3101.ErrMsg) == 0 {
  24478. res3101.ErrMsg = item.VolaCont
  24479. } else {
  24480. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24481. }
  24482. }
  24483. c.ServeSuccessJSON(map[string]interface{}{
  24484. "failed_code": -10,
  24485. "msg": res3101.ErrMsg,
  24486. })
  24487. return
  24488. } else {
  24489. hour := time.Now().Format("15")
  24490. min := time.Now().Format("04")
  24491. sec := time.Now().Format("05")
  24492. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24493. fmt.Println(record_time_two)
  24494. 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)
  24495. saveLog(result, requestLog, "2201A", "挂号")
  24496. if miConfig.Code == "H15049901371" {
  24497. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24498. utils.ErrorLog("解析失败:%v", err)
  24499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24500. return
  24501. }
  24502. resThree.ErrMsg = resThree10265.ErrMsg
  24503. resThree.Output = resThree10265.Output
  24504. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24505. } else {
  24506. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24507. utils.ErrorLog("解析失败:%v", err)
  24508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24509. return
  24510. }
  24511. }
  24512. if miConfig.Code == "H15049901371" {
  24513. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24514. } else {
  24515. infocode = resThree.Infcode
  24516. }
  24517. }
  24518. } else if res3101.Infcode != 0 {
  24519. c.ServeSuccessJSON(map[string]interface{}{
  24520. "failed_code": -10,
  24521. "msg": res3101.ErrMsg,
  24522. })
  24523. return
  24524. }
  24525. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24526. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24527. psn_info, _ := service.GetPsnByPatientId(id)
  24528. var verify_number string
  24529. if id_card_type == 4 {
  24530. verify_number = psn_info.VerifyNumber
  24531. } else if id_card_type == 1 {
  24532. bas := strings.Split(psn_info.CardInfo, "|")
  24533. cardNumber := bas[2]
  24534. verify_number = cardNumber
  24535. } else {
  24536. verify_number = psn_info.Certno
  24537. }
  24538. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24539. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24540. "&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
  24541. resp, requestErr := http.Get(api)
  24542. if requestErr != nil {
  24543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24544. return
  24545. }
  24546. body, ioErr := ioutil.ReadAll(resp.Body)
  24547. if ioErr != nil {
  24548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24550. return
  24551. }
  24552. var respJSON map[string]interface{}
  24553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24556. return
  24557. }
  24558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24559. result, _ := json.Marshal(respJSON)
  24560. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24561. utils.ErrorLog("解析失败:%v", err)
  24562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24563. return
  24564. }
  24565. infocode = resThree.Infcode
  24566. } else {
  24567. hour := time.Now().Format("15")
  24568. min := time.Now().Format("04")
  24569. sec := time.Now().Format("05")
  24570. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24571. if id_card_type == 1 {
  24572. for _, item := range rf {
  24573. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24574. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24575. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24576. } else if strconv.FormatInt(social_type, 10) == "390" {
  24577. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24578. } else {
  24579. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24580. }
  24581. }
  24582. }
  24583. }
  24584. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24585. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24586. }
  24587. if id_card_type == 1 {
  24588. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24589. bas := strings.Split(psn_info.CardInfo, "|")
  24590. basNumber := bas[1]
  24591. IdCardNo = basNumber
  24592. }
  24593. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24594. IdCardNo = psn_info.VerifyNumber
  24595. }
  24596. if len(insuplc_admdvs_temp) == 0 {
  24597. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24598. }
  24599. var result string
  24600. var requestLog string
  24601. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24602. var hisPrescription []*models.HisPrescription
  24603. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24604. if res3101.Infcode == 0 {
  24605. if len(res3101.Output.Result) > 0 {
  24606. for _, item := range res3101.Output.Result {
  24607. if len(res3101.ErrMsg) == 0 {
  24608. res3101.ErrMsg = item.VolaCont
  24609. } else {
  24610. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24611. }
  24612. }
  24613. c.ServeSuccessJSON(map[string]interface{}{
  24614. "failed_code": -10,
  24615. "msg": res3101.ErrMsg,
  24616. })
  24617. return
  24618. } else {
  24619. hour := time.Now().Format("15")
  24620. min := time.Now().Format("04")
  24621. sec := time.Now().Format("05")
  24622. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24623. fmt.Println(record_time_two)
  24624. if his.IdCardType == 2 {
  24625. IdCardNo = psn_info.Certno
  24626. psn_info.VerifyNumber = psn_info.Certno
  24627. } else if his.IdCardType == 4 {
  24628. IdCardNo = psn_info.Certno
  24629. } else {
  24630. bas := strings.Split(psn_info.CardInfo, "|")
  24631. IdCardNo = bas[2]
  24632. }
  24633. 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)
  24634. saveLog(result, requestLog, "2201A", "挂号")
  24635. if miConfig.Code == "H15049901371" {
  24636. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24637. utils.ErrorLog("解析失败:%v", err)
  24638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24639. return
  24640. }
  24641. resThree.ErrMsg = resThree10265.ErrMsg
  24642. resThree.Output = resThree10265.Output
  24643. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24644. } else {
  24645. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24646. utils.ErrorLog("解析失败:%v", err)
  24647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24648. return
  24649. }
  24650. }
  24651. if miConfig.Code == "H15049901371" {
  24652. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24653. } else {
  24654. infocode = resThree.Infcode
  24655. }
  24656. }
  24657. } else if res3101.Infcode != 0 {
  24658. c.ServeSuccessJSON(map[string]interface{}{
  24659. "failed_code": -10,
  24660. "msg": res3101.ErrMsg,
  24661. })
  24662. return
  24663. }
  24664. } else {
  24665. psn_info, _ := service.GetPsnByPatientId(id)
  24666. var rf []*ResultFive
  24667. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24668. //var insutypes []*ResultFive
  24669. var insutype string
  24670. var insutypes []*ResultFive
  24671. var is390 int = 0
  24672. var is310 int = 0
  24673. for _, item := range rf {
  24674. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24675. insutypes = append(insutypes, item)
  24676. }
  24677. }
  24678. if len(insutypes) == 1 {
  24679. insutype = insutypes[0].Insutype
  24680. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24681. } else {
  24682. for _, i := range insutypes {
  24683. if i.Insutype == "390" {
  24684. is390 = 1
  24685. }
  24686. if i.Insutype == "310" {
  24687. is310 = 1
  24688. }
  24689. }
  24690. }
  24691. if is390 == 1 {
  24692. insutype = "390"
  24693. }
  24694. if is310 == 1 {
  24695. insutype = "310"
  24696. }
  24697. if len(insutypes) == 0 {
  24698. insutype = "310"
  24699. }
  24700. if social_type > 0 {
  24701. insutype = strconv.FormatInt(social_type, 10)
  24702. }
  24703. for _, item := range rf {
  24704. if item.Insutype == insutype {
  24705. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24706. }
  24707. }
  24708. 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)
  24709. saveLog(result, requestLog, "2201A", "挂号")
  24710. }
  24711. if miConfig.Code == "H15049901371" {
  24712. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24713. utils.ErrorLog("解析失败:%v", err)
  24714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24715. return
  24716. }
  24717. resThree.ErrMsg = resThree10265.ErrMsg
  24718. resThree.Output = resThree10265.Output
  24719. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24720. } else {
  24721. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24722. utils.ErrorLog("解析失败:%v", err)
  24723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24724. return
  24725. }
  24726. }
  24727. if miConfig.Code == "H15049901371" {
  24728. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24729. } else {
  24730. infocode = resThree.Infcode
  24731. }
  24732. }
  24733. }
  24734. if infocode == -1 {
  24735. adminUser := c.GetAdminUserInfo()
  24736. errlog := &models.HisOrderError{
  24737. UserOrgId: adminUser.CurrentOrgId,
  24738. Ctime: time.Now().Unix(),
  24739. Mtime: time.Now().Unix(),
  24740. ErrMsg: resThree.ErrMsg,
  24741. Status: 1,
  24742. PatientId: id,
  24743. RecordTime: recordDateTime,
  24744. Stage: 2,
  24745. }
  24746. service.CreateErrMsgLog(errlog)
  24747. c.ServeSuccessJSON(map[string]interface{}{
  24748. "failed_code": -10,
  24749. "msg": resThree.ErrMsg,
  24750. })
  24751. return
  24752. }
  24753. his.Number = resThree.Output.Data.MdtrtID
  24754. his.PsnNo = resThree.Output.Data.PsnNo
  24755. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24756. his.IdCardNo = patient.IdCardNo
  24757. his.PhoneNumber = patient.Phone
  24758. his.UserOrgId = adminInfo.CurrentOrgId
  24759. his.Insutype = insutype
  24760. his.Ctime = time.Now().Unix()
  24761. his.Mtime = time.Now().Unix()
  24762. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24763. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24764. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24765. }
  24766. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24767. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24768. }
  24769. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24770. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24771. }
  24772. his.Status = 1
  24773. his.MdtrtGrpType = mdtrt_type
  24774. service.UpdateHisPatientStatus(&his)
  24775. service.UpdateHisPatient123(&patient)
  24776. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24777. c.ServeSuccessJSON(map[string]interface{}{
  24778. "his_info": his,
  24779. })
  24780. } else {
  24781. adminUser := c.GetAdminUserInfo()
  24782. errlog := &models.HisOrderError{
  24783. UserOrgId: adminUser.CurrentOrgId,
  24784. Ctime: time.Now().Unix(),
  24785. Mtime: time.Now().Unix(),
  24786. ErrMsg: res.ErrMsg,
  24787. Status: 1,
  24788. PatientId: id,
  24789. RecordTime: recordDateTime,
  24790. Stage: 1,
  24791. }
  24792. service.CreateErrMsgLog(errlog)
  24793. c.ServeSuccessJSON(map[string]interface{}{
  24794. "failed_code": -10,
  24795. "msg": res.ErrMsg,
  24796. })
  24797. return
  24798. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24799. }
  24800. }
  24801. }
  24802. func (c *HisApiController) GetUploadInfo() {
  24803. id, _ := c.GetInt64("id")
  24804. record_time := c.GetString("record_time")
  24805. his_patient_id, _ := c.GetInt64("his_patient_id")
  24806. order_id, _ := c.GetInt64("order_id")
  24807. pay_way, _ := c.GetInt64("pay_way")
  24808. pay_ways := c.GetString("pay_ways")
  24809. oth_desc := c.GetString("oth_desc")
  24810. pay_price, _ := c.GetFloat("pay_price")
  24811. pay_card_no := c.GetString("pay_card_no")
  24812. discount_price, _ := c.GetFloat("discount_price")
  24813. preferential_price, _ := c.GetFloat("preferential_price")
  24814. reality_price, _ := c.GetFloat("reality_price")
  24815. found_price, _ := c.GetFloat("found_price")
  24816. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24817. private_price, _ := c.GetFloat("private_price")
  24818. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24819. admin_user_id, _ := c.GetInt64("admin_user_id")
  24820. fapiao_code := c.GetString("fapiao_code")
  24821. fapiao_number := c.GetString("fapiao_number")
  24822. diagnosis_id := c.GetString("diagnosis")
  24823. sick_type, _ := c.GetInt64("sick_type")
  24824. reg_type, _ := c.GetInt64("p_type")
  24825. begin_time := c.GetString("begin_time")
  24826. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24827. cash_pay := c.GetString("cash_pay")
  24828. band_card_pay := c.GetString("band_card_pay")
  24829. wechat_pay := c.GetString("wechat_pay")
  24830. ali_pay := c.GetString("ali_pay")
  24831. jifen_pay := c.GetString("jifen_pay")
  24832. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24833. fmt.Println(acct_used_flag)
  24834. id_str := c.GetString("ids")
  24835. ids_arr := strings.Split(id_str, ",")
  24836. timeLayout := "2006-01-02"
  24837. loc, _ := time.LoadLocation("Local")
  24838. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24839. if err != nil {
  24840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24841. return
  24842. }
  24843. recordDateTime := theTime.Unix()
  24844. adminUser := c.GetAdminUserInfo()
  24845. var tempOrder models.HisOrder
  24846. tempOrder, _ = service.GetHisOrderByID(order_id)
  24847. var prescriptions []*models.HisPrescription
  24848. var start_time int64
  24849. var end_time int64
  24850. //押金模块
  24851. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24852. tmp_decimal := c.GetString("tmp_decimal")
  24853. var decimal float64 //本次使用的押金
  24854. var errmsg error
  24855. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24856. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24857. return
  24858. }
  24859. if len(tmp_decimal) > 0 {
  24860. if tmp_decimal[0] == 45 {
  24861. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24862. return
  24863. }
  24864. }
  24865. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24866. fmt.Println(errs)
  24867. decimal = tt
  24868. //if adminUser.CurrentOrgId == 10106{
  24869. // if len(fapiao_code) == 0{
  24870. // fapiao_code = "144072080589"
  24871. // }
  24872. // if len(fapiao_number) == 0{
  24873. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24874. // if order.ID == 0{
  24875. // fapiao_number = "00001520"
  24876. // }else{
  24877. // //fapiao_code = "00001520"
  24878. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24879. // var zero string
  24880. // if fpNumber >= 1000{
  24881. // zero = "0000" + strconv.Itoa(fpNumber)
  24882. // }else if fpNumber >= 10000{
  24883. // zero = "000" + strconv.Itoa(fpNumber)
  24884. // } else if fpNumber >= 100000{
  24885. // zero = "00" + strconv.Itoa(fpNumber)
  24886. // } else if fpNumber >= 1000000{
  24887. // zero = "0" + strconv.Itoa(fpNumber)
  24888. // }else {
  24889. // zero = strconv.Itoa(fpNumber)
  24890. // }
  24891. // fapiao_number = zero
  24892. // }
  24893. // }
  24894. //}
  24895. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24896. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24897. var patientPrescription models.HisPrescriptionInfo
  24898. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24899. if patientPrescription.ID == 0 {
  24900. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24901. }
  24902. //if patientPrescription.Do
  24903. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24904. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24905. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24906. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24907. var config []*models.HisXtDiagnoseConfig
  24908. for _, item := range diagnosis_ids {
  24909. id, _ := strconv.ParseInt(item, 10, 64)
  24910. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24911. config = append(config, &diagnosisConfig)
  24912. }
  24913. sickConfig, _ := service.FindSickById(sick_type)
  24914. //if tempOrder.ID == 0 {
  24915. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24916. //}
  24917. if tempOrder.ID == 0 {
  24918. var result string
  24919. var requestLog string
  24920. var res2 ResultSix
  24921. var res3 GZResultSix
  24922. var ressix10265 ResultSix10265
  24923. if miConfig.MdtrtareaAdmvs == "421300" {
  24924. data := make(map[string]interface{})
  24925. client := &http.Client{}
  24926. data["psn_no"] = his.PsnNo
  24927. data["mdtrt_id"] = his.Number
  24928. data["opter"] = roles.UserName
  24929. data["org_name"] = miConfig.OrgName
  24930. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24931. data["doctor_id"] = doctor_info.DoctorNumber
  24932. data["doctor_name"] = doctor_info.UserName
  24933. data["department"] = department.Name
  24934. data["fixmedins_code"] = miConfig.Code
  24935. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24936. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24937. data["secret_key"] = miConfig.SecretKey
  24938. data["sick_code"] = sickConfig.CountryCode
  24939. data["sick_name"] = sickConfig.ClassName
  24940. data["dept"] = strconv.FormatInt(department.ID, 10)
  24941. data["config"] = config
  24942. data["begin_time"] = begin_time
  24943. bytesData, _ := json.Marshal(data)
  24944. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24945. resp, _ := client.Do(req)
  24946. defer resp.Body.Close()
  24947. body, ioErr := ioutil.ReadAll(resp.Body)
  24948. if ioErr != nil {
  24949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24951. return
  24952. }
  24953. var respJSON map[string]interface{}
  24954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24957. return
  24958. }
  24959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24960. userJSONBytes, _ := json.Marshal(respJSON)
  24961. fmt.Println("log")
  24962. fmt.Println(string(userJSONBytes))
  24963. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24964. utils.ErrorLog("解析失败:%v", err)
  24965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24966. return
  24967. }
  24968. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24969. data := make(map[string]interface{})
  24970. client := &http.Client{}
  24971. data["psn_no"] = his.PsnNo
  24972. data["mdtrt_id"] = his.Number
  24973. data["opter"] = roles.UserName
  24974. data["org_name"] = miConfig.OrgName
  24975. if reg_type == 11 && his.Insutype == "390" {
  24976. data["med_type"] = "110104"
  24977. } else {
  24978. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24979. }
  24980. data["doctor_id"] = doctor_info.DoctorNumber
  24981. data["doctor_name"] = doctor_info.UserName
  24982. data["department"] = department.Name
  24983. data["fixmedins_code"] = miConfig.Code
  24984. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24985. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24986. data["secret_key"] = miConfig.SecretKey
  24987. data["sick_code"] = sickConfig.CountryCode
  24988. data["sick_name"] = sickConfig.ClassName
  24989. data["dept"] = strconv.FormatInt(department.ID, 10)
  24990. data["config"] = config
  24991. data["begin_time"] = begin_time
  24992. bytesData, _ := json.Marshal(data)
  24993. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24994. resp, _ := client.Do(req)
  24995. defer resp.Body.Close()
  24996. body, ioErr := ioutil.ReadAll(resp.Body)
  24997. if ioErr != nil {
  24998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25000. return
  25001. }
  25002. var respJSON map[string]interface{}
  25003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25006. return
  25007. }
  25008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25009. userJSONBytes, _ := json.Marshal(respJSON)
  25010. fmt.Println("log")
  25011. fmt.Println(string(userJSONBytes))
  25012. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25013. utils.ErrorLog("解析失败:%v", err)
  25014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25015. return
  25016. }
  25017. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25018. data := make(map[string]interface{})
  25019. client := &http.Client{}
  25020. data["psn_no"] = his.PsnNo
  25021. data["mdtrt_id"] = his.Number
  25022. data["opter"] = roles.UserName
  25023. data["org_name"] = miConfig.OrgName
  25024. if reg_type == 11 && his.Insutype == "390" {
  25025. data["med_type"] = "110104"
  25026. } else {
  25027. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25028. }
  25029. data["doctor_id"] = doctor_info.DoctorNumber
  25030. data["doctor_name"] = doctor_info.UserName
  25031. data["department"] = department.Name
  25032. data["fixmedins_code"] = miConfig.Code
  25033. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25034. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25035. data["secret_key"] = miConfig.SecretKey
  25036. data["sick_code"] = sickConfig.CountryCode
  25037. data["sick_name"] = sickConfig.ClassName
  25038. data["dept"] = strconv.FormatInt(department.ID, 10)
  25039. data["config"] = config
  25040. data["begin_time"] = begin_time
  25041. bytesData, _ := json.Marshal(data)
  25042. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25043. resp, _ := client.Do(req)
  25044. defer resp.Body.Close()
  25045. body, ioErr := ioutil.ReadAll(resp.Body)
  25046. if ioErr != nil {
  25047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25049. return
  25050. }
  25051. var respJSON map[string]interface{}
  25052. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25055. return
  25056. }
  25057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25058. userJSONBytes, _ := json.Marshal(respJSON)
  25059. fmt.Println("log")
  25060. fmt.Println(string(userJSONBytes))
  25061. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25062. utils.ErrorLog("解析失败:%v", err)
  25063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25064. return
  25065. }
  25066. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25067. data := make(map[string]interface{})
  25068. client := &http.Client{}
  25069. data["psn_no"] = his.PsnNo
  25070. data["mdtrt_id"] = his.Number
  25071. data["opter"] = roles.UserName
  25072. data["org_name"] = miConfig.OrgName
  25073. if reg_type == 11 && his.Insutype == "390" {
  25074. data["med_type"] = "110104"
  25075. } else {
  25076. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25077. }
  25078. data["doctor_id"] = doctor_info.DoctorNumber
  25079. data["doctor_name"] = doctor_info.UserName
  25080. data["department"] = department.Name
  25081. data["fixmedins_code"] = miConfig.Code
  25082. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25083. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25084. data["secret_key"] = miConfig.SecretKey
  25085. data["sick_code"] = sickConfig.CountryCode
  25086. data["sick_name"] = sickConfig.ClassName
  25087. data["dept"] = strconv.FormatInt(department.ID, 10)
  25088. data["config"] = config
  25089. data["begin_time"] = begin_time
  25090. bytesData, _ := json.Marshal(data)
  25091. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25092. resp, _ := client.Do(req)
  25093. defer resp.Body.Close()
  25094. body, ioErr := ioutil.ReadAll(resp.Body)
  25095. if ioErr != nil {
  25096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25098. return
  25099. }
  25100. var respJSON map[string]interface{}
  25101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25104. return
  25105. }
  25106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25107. userJSONBytes, _ := json.Marshal(respJSON)
  25108. fmt.Println("log")
  25109. fmt.Println(string(userJSONBytes))
  25110. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25111. utils.ErrorLog("解析失败:%v", err)
  25112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25113. return
  25114. }
  25115. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25116. data := make(map[string]interface{})
  25117. client := &http.Client{}
  25118. data["psn_no"] = his.PsnNo
  25119. data["mdtrt_id"] = his.Number
  25120. data["doctor"] = roles.UserName
  25121. data["department"] = department.Name
  25122. data["org_name"] = miConfig.OrgName
  25123. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25124. data["doctor_id"] = doctor_info.DoctorNumber
  25125. data["new_doctor_name"] = doctor_info.UserName
  25126. data["fixmedins_code"] = miConfig.Code
  25127. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25128. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25129. data["secret_key"] = miConfig.SecretKey
  25130. data["sick_code"] = sickConfig.CountryCode
  25131. data["sick_name"] = sickConfig.ClassName
  25132. data["url"] = miConfig.Url
  25133. data["ak"] = miConfig.AccessKey
  25134. data["begin_time"] = begin_time
  25135. data["cainfo"] = miConfig.Cainfo
  25136. data["dept"] = strconv.FormatInt(department.ID, 10)
  25137. data["config"] = config
  25138. bytesData, _ := json.Marshal(data)
  25139. var req *http.Request
  25140. if miConfig.MdtrtareaAdmvs == "320921" {
  25141. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25142. //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 +
  25143. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25144. } else {
  25145. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25146. }
  25147. resp, _ := client.Do(req)
  25148. defer resp.Body.Close()
  25149. body, ioErr := ioutil.ReadAll(resp.Body)
  25150. if ioErr != nil {
  25151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25153. return
  25154. }
  25155. var respJSON map[string]interface{}
  25156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25159. return
  25160. }
  25161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25162. userJSONBytes, _ := json.Marshal(respJSON)
  25163. fmt.Println("log")
  25164. fmt.Println(string(userJSONBytes))
  25165. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25166. utils.ErrorLog("解析失败:%v", err)
  25167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25168. return
  25169. }
  25170. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25171. res2.Output = ressix10265.Output
  25172. res2.ErrMsg = ressix10265.ErrMsg
  25173. res2.Cainfo = ressix10265.Cainfo
  25174. res2.WarnMsg = ressix10265.WarnMsg
  25175. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25176. res2.Infcode = infocode
  25177. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25178. data := make(map[string]interface{})
  25179. client := &http.Client{}
  25180. data["psn_no"] = his.PsnNo
  25181. data["mdtrt_id"] = his.Number
  25182. data["doctor"] = roles.UserName
  25183. data["department"] = department.Name
  25184. data["org_name"] = miConfig.OrgName
  25185. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25186. data["doctor_id"] = doctor_info.DoctorNumber
  25187. data["new_doctor_name"] = doctor_info.UserName
  25188. data["fixmedins_code"] = miConfig.Code
  25189. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25190. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25191. data["secret_key"] = miConfig.SecretKey
  25192. data["sick_code"] = sickConfig.CountryCode
  25193. data["sick_name"] = sickConfig.ClassName
  25194. data["url"] = miConfig.Url
  25195. data["ak"] = miConfig.AccessKey
  25196. data["begin_time"] = begin_time
  25197. data["cainfo"] = miConfig.Cainfo
  25198. data["dept"] = strconv.FormatInt(department.ID, 10)
  25199. data["config"] = config
  25200. bytesData, _ := json.Marshal(data)
  25201. var req *http.Request
  25202. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25203. resp, _ := client.Do(req)
  25204. defer resp.Body.Close()
  25205. body, ioErr := ioutil.ReadAll(resp.Body)
  25206. if ioErr != nil {
  25207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25209. return
  25210. }
  25211. var respJSON map[string]interface{}
  25212. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25215. return
  25216. }
  25217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25218. userJSONBytes, _ := json.Marshal(respJSON)
  25219. fmt.Println("log")
  25220. fmt.Println(string(userJSONBytes))
  25221. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25222. utils.ErrorLog("解析失败:%v", err)
  25223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25224. return
  25225. }
  25226. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25227. res2.Output = ressix10265.Output
  25228. res2.ErrMsg = ressix10265.ErrMsg
  25229. res2.Cainfo = ressix10265.Cainfo
  25230. res2.WarnMsg = ressix10265.WarnMsg
  25231. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25232. res2.Infcode = infocode
  25233. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25234. 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)
  25235. saveLog(result, requestLog, "2203", "上传就诊信息")
  25236. var respJSON2 map[string]interface{}
  25237. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25240. return
  25241. }
  25242. userJSONBytes2, _ := json.Marshal(respJSON2)
  25243. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25244. utils.ErrorLog("解析失败:%v", err)
  25245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25246. return
  25247. }
  25248. 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)
  25249. fmt.Println(result2)
  25250. fmt.Println(src_request)
  25251. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25252. data := make(map[string]interface{})
  25253. client := &http.Client{}
  25254. data["psn_no"] = his.PsnNo
  25255. data["mdtrt_id"] = his.Number
  25256. data["doctor"] = roles.UserName
  25257. data["department"] = department.Name
  25258. data["org_name"] = miConfig.OrgName
  25259. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25260. data["doctor_id"] = doctor_info.DoctorNumber
  25261. data["new_doctor_name"] = doctor_info.UserName
  25262. data["fixmedins_code"] = miConfig.Code
  25263. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25264. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25265. data["secret_key"] = miConfig.SecretKey
  25266. data["sick_code"] = sickConfig.CountryCode
  25267. data["sick_name"] = sickConfig.ClassName
  25268. data["url"] = miConfig.Url
  25269. data["ak"] = miConfig.AccessKey
  25270. data["begin_time"] = begin_time
  25271. data["cainfo"] = miConfig.Cainfo
  25272. data["dept"] = strconv.FormatInt(department.ID, 10)
  25273. data["config"] = config
  25274. bytesData, _ := json.Marshal(data)
  25275. var req *http.Request
  25276. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25277. resp, _ := client.Do(req)
  25278. defer resp.Body.Close()
  25279. body, ioErr := ioutil.ReadAll(resp.Body)
  25280. if ioErr != nil {
  25281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25283. return
  25284. }
  25285. var respJSON map[string]interface{}
  25286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25289. return
  25290. }
  25291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25292. userJSONBytes, _ := json.Marshal(respJSON)
  25293. fmt.Println("log")
  25294. fmt.Println(string(userJSONBytes))
  25295. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25296. utils.ErrorLog("解析失败:%v", err)
  25297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25298. return
  25299. }
  25300. } else {
  25301. if miConfig.MdtrtareaAdmvs == "440781" { //
  25302. 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)
  25303. } else {
  25304. if miConfig.Code == "H15049901371" {
  25305. //赤峰地区国家医保医疗类别
  25306. //职工透析:医疗类别选特殊情况门诊990502
  25307. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25308. var med_type string
  25309. if his.Insutype == "390" {
  25310. if reg_type == 14 {
  25311. med_type = "9933"
  25312. } else if reg_type == 11 {
  25313. med_type = "11"
  25314. }
  25315. } else if his.Insutype == "310" {
  25316. if reg_type == 14 {
  25317. med_type = "990502"
  25318. } else if reg_type == 11 {
  25319. med_type = "11"
  25320. }
  25321. }
  25322. 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)
  25323. } else {
  25324. 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)
  25325. }
  25326. }
  25327. saveLog(result, requestLog, "2203", "上传就诊信息")
  25328. var respJSON2 map[string]interface{}
  25329. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25332. return
  25333. }
  25334. userJSONBytes2, _ := json.Marshal(respJSON2)
  25335. if miConfig.Code == "H15049901371" {
  25336. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25337. utils.ErrorLog("解析失败:%v", err)
  25338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25339. return
  25340. }
  25341. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25342. res2.Output = ressix10265.Output
  25343. res2.ErrMsg = ressix10265.ErrMsg
  25344. res2.Cainfo = ressix10265.Cainfo
  25345. res2.WarnMsg = ressix10265.WarnMsg
  25346. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25347. res2.Infcode = infocode
  25348. } else {
  25349. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25350. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25351. utils.ErrorLog("解析失败:%v", err)
  25352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25353. return
  25354. }
  25355. res2.Infcode = res3.Infcode
  25356. } else {
  25357. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25358. utils.ErrorLog("解析失败:%v", err)
  25359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25360. return
  25361. }
  25362. }
  25363. }
  25364. }
  25365. if res2.Infcode == -1 {
  25366. adminUser := c.GetAdminUserInfo()
  25367. errlog := &models.HisOrderError{
  25368. UserOrgId: adminUser.CurrentOrgId,
  25369. Ctime: time.Now().Unix(),
  25370. Mtime: time.Now().Unix(),
  25371. ErrMsg: res2.ErrMsg,
  25372. Status: 1,
  25373. PatientId: id,
  25374. RecordTime: recordDateTime,
  25375. Stage: 3,
  25376. }
  25377. service.CreateErrMsgLog(errlog)
  25378. c.ServeSuccessJSON(map[string]interface{}{
  25379. "failed_code": -10,
  25380. "msg": res2.ErrMsg,
  25381. })
  25382. return
  25383. } else {
  25384. his.Diagnosis = diagnosis_id
  25385. his.SickType = sickConfig.ID
  25386. //var p_type int64
  25387. //if reg_type == 1111 || reg_type == 1112 {
  25388. // p_type = 11
  25389. //
  25390. //}
  25391. his.PType = fmt.Sprintf("%d", reg_type)
  25392. service.UpdateHisPatientThree(&his)
  25393. data := make(map[string]interface{})
  25394. if settle_accounts_type == 1 { //日结
  25395. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25396. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25397. } else {
  25398. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25399. }
  25400. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25401. data["pre"] = prescriptions
  25402. } else { //月结
  25403. start_time_str := c.GetString("start_time")
  25404. end_time_str := c.GetString("end_time")
  25405. timeLayout := "2006-01-02"
  25406. loc, _ := time.LoadLocation("Local")
  25407. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25408. if err != nil {
  25409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25410. return
  25411. }
  25412. recordStartTime := theStartTime.Unix()
  25413. start_time = recordStartTime
  25414. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25415. if err != nil {
  25416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25417. return
  25418. }
  25419. recordEndTime := theEndTime.Unix()
  25420. end_time = recordEndTime
  25421. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25422. data["pre"] = prescriptions
  25423. }
  25424. timestamp := time.Now().Unix()
  25425. tempTime := time.Unix(timestamp, 0)
  25426. timeFormat := tempTime.Format("20060102150405")
  25427. chrgBchno := rand.Intn(100000) + 10000
  25428. new_chrg_bchno := ""
  25429. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25430. new_chrg_bchno = chrg_bchno
  25431. strconv.FormatInt(his.PatientId, 10)
  25432. client := &http.Client{}
  25433. if adminUser.CurrentOrgId == 10265 {
  25434. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25435. new_chrg_bchno = "0000"
  25436. }
  25437. }
  25438. data["psn_no"] = his.PsnNo
  25439. data["mdtrt_id"] = his.Number
  25440. data["chrg_bchno"] = new_chrg_bchno
  25441. data["org_name"] = miConfig.OrgName
  25442. data["doctor"] = doctor_info.UserName
  25443. data["doctor_id"] = doctor_info.DoctorNumber
  25444. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25445. data["fixmedins_code"] = miConfig.Code
  25446. data["dept_code"] = department.Number
  25447. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25448. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25449. data["secret_key"] = miConfig.SecretKey
  25450. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25451. data["url"] = miConfig.Url
  25452. data["ak"] = miConfig.AccessKey
  25453. data["new_doctor_name"] = patientPrescription.Doctor
  25454. data["diag_code"] = sickConfig.CountryCode
  25455. data["cainfo"] = miConfig.Cainfo
  25456. data["opter"] = roles.UserName
  25457. var ids []int64
  25458. for _, item := range prescriptions {
  25459. ids = append(ids, item.ID)
  25460. }
  25461. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25462. if config.IsOpen == 1 { //对接了医保,走医保流程
  25463. var res ResultFour
  25464. var resFour10265 ResultFour10265
  25465. if miConfig.MdtrtareaAdmvs == "421300" {
  25466. bytesData, _ := json.Marshal(data)
  25467. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25468. resp, _ := client.Do(req)
  25469. defer resp.Body.Close()
  25470. body, ioErr := ioutil.ReadAll(resp.Body)
  25471. if ioErr != nil {
  25472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25474. return
  25475. }
  25476. var respJSON map[string]interface{}
  25477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25480. return
  25481. }
  25482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25483. userJSONBytes, _ := json.Marshal(respJSON)
  25484. fmt.Println("log")
  25485. fmt.Println(string(userJSONBytes))
  25486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25487. utils.ErrorLog("解析失败:%v", err)
  25488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25489. return
  25490. }
  25491. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25492. bytesData, _ := json.Marshal(data)
  25493. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25494. resp, _ := client.Do(req)
  25495. defer resp.Body.Close()
  25496. body, ioErr := ioutil.ReadAll(resp.Body)
  25497. if ioErr != nil {
  25498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25500. return
  25501. }
  25502. var respJSON map[string]interface{}
  25503. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25506. return
  25507. }
  25508. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25509. userJSONBytes, _ := json.Marshal(respJSON)
  25510. fmt.Println("log")
  25511. fmt.Println(string(userJSONBytes))
  25512. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25513. utils.ErrorLog("解析失败:%v", err)
  25514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25515. return
  25516. }
  25517. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25518. bytesData, _ := json.Marshal(data)
  25519. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25520. resp, _ := client.Do(req)
  25521. defer resp.Body.Close()
  25522. body, ioErr := ioutil.ReadAll(resp.Body)
  25523. if ioErr != nil {
  25524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25526. return
  25527. }
  25528. var respJSON map[string]interface{}
  25529. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25532. return
  25533. }
  25534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25535. userJSONBytes, _ := json.Marshal(respJSON)
  25536. fmt.Println("log")
  25537. fmt.Println(string(userJSONBytes))
  25538. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25539. utils.ErrorLog("解析失败:%v", err)
  25540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25541. return
  25542. }
  25543. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25544. bytesData, _ := json.Marshal(data)
  25545. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25546. resp, _ := client.Do(req)
  25547. defer resp.Body.Close()
  25548. body, ioErr := ioutil.ReadAll(resp.Body)
  25549. if ioErr != nil {
  25550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25552. return
  25553. }
  25554. var respJSON map[string]interface{}
  25555. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25558. return
  25559. }
  25560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25561. userJSONBytes, _ := json.Marshal(respJSON)
  25562. fmt.Println("log")
  25563. fmt.Println(string(userJSONBytes))
  25564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25565. utils.ErrorLog("解析失败:%v", err)
  25566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25567. return
  25568. }
  25569. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25570. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25571. if result3101.Infcode == "0" {
  25572. if len(result3101.Output.Result) > 0 {
  25573. var errMsgs []string
  25574. for _, item := range result3101.Output.Result {
  25575. errMsgs = append(errMsgs, item.VolaCont)
  25576. }
  25577. c.ServeSuccessJSON(map[string]interface{}{
  25578. "failed_code": -10,
  25579. "msg": errMsgs,
  25580. })
  25581. return
  25582. }
  25583. }
  25584. bytesData, _ := json.Marshal(data)
  25585. var req *http.Request
  25586. if miConfig.MdtrtareaAdmvs == "320921" {
  25587. data["diag_code"] = sickConfig.CountryCode
  25588. fmt.Println(data)
  25589. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25590. } else {
  25591. data["diag_code"] = sickConfig.CountryCode
  25592. fmt.Println(data)
  25593. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25594. }
  25595. resp, _ := client.Do(req)
  25596. defer resp.Body.Close()
  25597. body, ioErr := ioutil.ReadAll(resp.Body)
  25598. if ioErr != nil {
  25599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25601. return
  25602. }
  25603. var respJSON map[string]interface{}
  25604. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25607. return
  25608. }
  25609. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25610. userJSONBytes, _ := json.Marshal(respJSON)
  25611. fmt.Println("log")
  25612. fmt.Println(string(userJSONBytes))
  25613. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25614. utils.ErrorLog("解析失败:%v", err)
  25615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25616. return
  25617. }
  25618. res.InfRefmsgid = resFour10265.InfRefmsgid
  25619. res.Output = resFour10265.Output
  25620. res.ErrMsg = resFour10265.ErrMsg
  25621. res.Cainfo = resFour10265.Cainfo
  25622. res.WarnMsg = resFour10265.WarnMsg
  25623. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25624. res.Infcode = infocode
  25625. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25626. var pagesize int = 2
  25627. var start int = 1
  25628. var stop int
  25629. var pagecount int
  25630. var curpage int
  25631. var isSuccess bool = true
  25632. data["doctor_id"] = doctor_info.DoctorNumber
  25633. //总页数,向上取整,注意除之前要先转换类型为float64
  25634. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25635. for curpage = 1; curpage <= pagecount; curpage++ {
  25636. if curpage == 1 {
  25637. start = 1
  25638. } else {
  25639. start = (curpage-1)*pagesize + 1
  25640. }
  25641. stop = curpage * pagesize
  25642. if stop > len(prescriptions) {
  25643. stop = len(prescriptions)
  25644. }
  25645. //var requestLog string
  25646. data["pre"] = prescriptions[start-1 : stop]
  25647. fmt.Println(data["pre"])
  25648. bytesData, _ := json.Marshal(data)
  25649. var req *http.Request
  25650. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25651. resp, _ := client.Do(req)
  25652. defer resp.Body.Close()
  25653. body, ioErr := ioutil.ReadAll(resp.Body)
  25654. if ioErr != nil {
  25655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25657. return
  25658. }
  25659. var respJSON map[string]interface{}
  25660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25663. return
  25664. }
  25665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25666. userJSONBytes, _ := json.Marshal(respJSON)
  25667. fmt.Println("log")
  25668. fmt.Println(string(userJSONBytes))
  25669. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25670. utils.ErrorLog("解析失败:%v", err)
  25671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25672. return
  25673. }
  25674. res.InfRefmsgid = resFour10265.InfRefmsgid
  25675. res.Output = resFour10265.Output
  25676. res.ErrMsg = resFour10265.ErrMsg
  25677. res.Cainfo = resFour10265.Cainfo
  25678. res.WarnMsg = resFour10265.WarnMsg
  25679. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25680. res.Infcode = infocode
  25681. if infocode == 0 {
  25682. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25683. } else {
  25684. isSuccess = false
  25685. errlog := &models.HisOrderError{
  25686. UserOrgId: adminUser.CurrentOrgId,
  25687. Ctime: time.Now().Unix(),
  25688. Mtime: time.Now().Unix(),
  25689. Number: chrg_bchno,
  25690. ErrMsg: "",
  25691. Status: 1,
  25692. PatientId: id,
  25693. RecordTime: recordDateTime,
  25694. Stage: 4,
  25695. }
  25696. service.CreateErrMsgLog(errlog)
  25697. c.ServeSuccessJSON(map[string]interface{}{
  25698. "failed_code": -10,
  25699. "msg": res.ErrMsg,
  25700. })
  25701. return
  25702. }
  25703. }
  25704. if isSuccess {
  25705. res.Infcode = 0
  25706. }
  25707. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25708. 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)
  25709. var dat map[string]interface{}
  25710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25711. fmt.Println(dat)
  25712. } else {
  25713. fmt.Println(err)
  25714. }
  25715. saveLog(result, request_log, "2204", "上传费用明细")
  25716. userJSONBytes, _ := json.Marshal(dat)
  25717. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25718. utils.ErrorLog("解析失败:%v", err)
  25719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25720. return
  25721. }
  25722. res.InfRefmsgid = resFour10265.InfRefmsgid
  25723. res.Output = resFour10265.Output
  25724. res.ErrMsg = resFour10265.ErrMsg
  25725. res.Cainfo = resFour10265.Cainfo
  25726. res.WarnMsg = resFour10265.WarnMsg
  25727. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25728. res.Infcode = infocode
  25729. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25730. bytesData, _ := json.Marshal(data)
  25731. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25732. resp, _ := client.Do(req)
  25733. defer resp.Body.Close()
  25734. body, ioErr := ioutil.ReadAll(resp.Body)
  25735. if ioErr != nil {
  25736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25738. return
  25739. }
  25740. var respJSON map[string]interface{}
  25741. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25744. return
  25745. }
  25746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25747. userJSONBytes, _ := json.Marshal(respJSON)
  25748. fmt.Println("log")
  25749. fmt.Println(string(userJSONBytes))
  25750. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25751. utils.ErrorLog("解析失败:%v", err)
  25752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25753. return
  25754. }
  25755. } else {
  25756. if miConfig.Code == "H15049901371" {
  25757. 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)
  25758. var dat map[string]interface{}
  25759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25760. fmt.Println(dat)
  25761. } else {
  25762. fmt.Println(err)
  25763. }
  25764. saveLog(result, request_log, "2204", "上传费用明细")
  25765. userJSONBytes, _ := json.Marshal(dat)
  25766. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25767. utils.ErrorLog("解析失败:%v", err)
  25768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25769. return
  25770. }
  25771. res.InfRefmsgid = resFour10265.InfRefmsgid
  25772. res.Output = resFour10265.Output
  25773. res.ErrMsg = resFour10265.ErrMsg
  25774. res.Cainfo = resFour10265.Cainfo
  25775. res.WarnMsg = resFour10265.WarnMsg
  25776. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25777. res.Infcode = infocode
  25778. } else {
  25779. 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)
  25780. var dat map[string]interface{}
  25781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25782. fmt.Println(dat)
  25783. } else {
  25784. fmt.Println(err)
  25785. }
  25786. saveLog(result, request_log, "2204", "上传费用明细")
  25787. userJSONBytes, _ := json.Marshal(dat)
  25788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25789. utils.ErrorLog("解析失败:%v", err)
  25790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25791. return
  25792. }
  25793. }
  25794. }
  25795. if res.Infcode == 0 {
  25796. order := &models.HisOrder{
  25797. UserOrgId: adminUser.CurrentOrgId,
  25798. HisPatientId: his.ID,
  25799. PatientId: his.PatientId,
  25800. SettleAccountsDate: recordDateTime,
  25801. MdtrtId: his.Number,
  25802. PsnNo: his.PsnNo,
  25803. MedType: strconv.FormatInt(reg_type, 10),
  25804. Ctime: time.Now().Unix(),
  25805. Mtime: time.Now().Unix(),
  25806. Status: 1,
  25807. Number: chrg_bchno,
  25808. Infcode: res.Infcode,
  25809. WarnMsg: res.WarnMsg,
  25810. Cainfo: res.Cainfo,
  25811. ErrMsg: res.ErrMsg,
  25812. RespondTime: res.RefmsgTime,
  25813. InfRefmsgid: res.InfRefmsgid,
  25814. OrderStatus: 1,
  25815. PayWay: pay_way,
  25816. PayWays: pay_ways,
  25817. OthDesc: oth_desc,
  25818. PayPrice: pay_price,
  25819. PayCardNo: pay_card_no,
  25820. DiscountPrice: discount_price,
  25821. PreferentialPrice: preferential_price,
  25822. RealityPrice: reality_price,
  25823. FoundPrice: found_price,
  25824. MedicalInsurancePrice: medical_insurance_price,
  25825. PrivatePrice: private_price,
  25826. IsMedicineInsurance: 1,
  25827. SettleType: settle_accounts_type,
  25828. SettleStartTime: start_time,
  25829. SettleEndTime: end_time,
  25830. Creator: roles.AdminUserId,
  25831. Modify: roles.AdminUserId,
  25832. FaPiaoNumber: fapiao_number,
  25833. FaPiaoCode: fapiao_code,
  25834. PType: 2,
  25835. Diagnosis: diagnosis_id,
  25836. CashPay: cash_pay,
  25837. WechatPay: wechat_pay,
  25838. AliPay: ali_pay,
  25839. JifenPay: jifen_pay,
  25840. BandCardPay: band_card_pay,
  25841. }
  25842. err = service.CreateOrder(order)
  25843. if err != nil {
  25844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25845. return
  25846. }
  25847. for _, item := range res.Output.Result {
  25848. temp := strings.Split(item.FeedetlSn, "-")
  25849. var advice_id int64 = 0
  25850. var project_id int64 = 0
  25851. var types int64 = 0
  25852. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25853. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25854. if temp[1] == "1" {
  25855. advice_id = id
  25856. project_id = 0
  25857. } else if temp[1] == "2" {
  25858. advice_id = 0
  25859. project_id = id
  25860. }
  25861. if item.MedChrgitmType == "9" {
  25862. item.MedChrgitmType = "09"
  25863. }
  25864. info := &models.HisOrderInfo{
  25865. OrderNumber: order.Number,
  25866. FeedetlSn: item.FeedetlSn,
  25867. UploadDate: time.Now().Unix(),
  25868. AdviceId: advice_id,
  25869. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25870. Cnt: item.Cnt,
  25871. Pric: float64(item.Pric),
  25872. PatientId: his.PatientId,
  25873. PricUplmtAmt: item.PricUplmtAmt,
  25874. SelfpayProp: item.SelfpayProp,
  25875. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25876. OverlmtAmt: item.OverlmtAmt,
  25877. PreselfpayAmt: item.PreselfpayAmt,
  25878. BasMednFlag: item.BasMednFlag,
  25879. MedChrgitmType: item.MedChrgitmType,
  25880. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25881. Status: 1,
  25882. Memo: item.Memo,
  25883. Mtime: time.Now().Unix(),
  25884. InscpScpAmt: item.InscpScpAmt,
  25885. DrtReimFlag: item.DrtReimFlag,
  25886. Ctime: time.Now().Unix(),
  25887. ListSpItemFlag: item.ListSpItemFlag,
  25888. ChldMedcFlag: item.ChldMedcFlag,
  25889. LmtUsedFlag: item.LmtUsedFlag,
  25890. ChrgitmLv: item.ChrgitmLv,
  25891. UserOrgId: adminUser.CurrentOrgId,
  25892. HisPatientId: his.ID,
  25893. OrderId: order.ID,
  25894. ProjectId: project_id,
  25895. Type: types,
  25896. }
  25897. service.CreateOrderInfo(info)
  25898. }
  25899. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25900. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25901. var total float64
  25902. for _, item := range prescriptions {
  25903. if item.Type == 1 { //药品
  25904. for _, subItem := range item.HisDoctorAdviceInfo {
  25905. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25906. total_one := price * subItem.PrescribingNumber
  25907. total = total + total_one
  25908. }
  25909. }
  25910. if item.Type == 2 { //项目
  25911. for _, subItem := range item.HisPrescriptionProject {
  25912. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25913. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25914. total_one := price * cnt
  25915. total = total + total_one
  25916. }
  25917. }
  25918. }
  25919. allTotal := fmt.Sprintf("%.2f", total)
  25920. //if adminUser.CurrentOrgId == 9919 {
  25921. //
  25922. // allTotal = fmt.Sprintf("%.2f", total)
  25923. //
  25924. //} else {
  25925. //
  25926. // allTotal = fmt.Sprintf("%.2f", total)
  25927. //
  25928. //}
  25929. if res.Infcode == 0 {
  25930. var rf []*ResultFive
  25931. json.Unmarshal([]byte(his.Iinfo), &rf)
  25932. chrg_bchno := chrg_bchno
  25933. cert_no := his.Certno
  25934. var insutypes []string
  25935. var insutype string
  25936. var is390 int = 0
  25937. var is310 int = 0
  25938. for _, item := range rf {
  25939. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25940. insutypes = append(insutypes, item.Insutype)
  25941. }
  25942. }
  25943. if len(insutypes) == 1 {
  25944. insutype = insutypes[0]
  25945. } else {
  25946. for _, i := range insutypes {
  25947. if i == "390" {
  25948. is390 = 1
  25949. }
  25950. if i == "310" {
  25951. is310 = 1
  25952. }
  25953. }
  25954. }
  25955. if is390 == 1 {
  25956. insutype = "390"
  25957. }
  25958. if is310 == 1 {
  25959. insutype = "310"
  25960. }
  25961. if len(insutypes) == 0 {
  25962. insutype = "310"
  25963. }
  25964. if len(insutypes) == 2 {
  25965. insutype = strconv.FormatInt(his.SocialType, 10)
  25966. }
  25967. insutype = strconv.FormatInt(his.SocialType, 10)
  25968. //insutype = "390"
  25969. if his.IdCardType == 1 {
  25970. // cert_no = his.MedicalInsuranceNumber
  25971. cert_no = his.Certno
  25972. } else {
  25973. cert_no = his.Certno
  25974. }
  25975. var res ResultSeven
  25976. var resSeven10265 ResultSeven10265
  25977. var gzresSeven10265Two GZResultSeven10265Two
  25978. var src_resquest string
  25979. var result2 string
  25980. if miConfig.MdtrtareaAdmvs == "421300" {
  25981. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25982. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25983. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25984. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25985. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25986. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25987. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25988. resp, requestErr := http.Get(api)
  25989. if requestErr != nil {
  25990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25991. return
  25992. }
  25993. body, ioErr := ioutil.ReadAll(resp.Body)
  25994. if ioErr != nil {
  25995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25997. return
  25998. }
  25999. var respJSON map[string]interface{}
  26000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26006. result, _ := json.Marshal(respJSON)
  26007. if miConfig.Code == "H15049901371" {
  26008. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26009. utils.ErrorLog("解析失败:%v", err)
  26010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26011. return
  26012. }
  26013. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26014. res.Output = resSeven10265.Output
  26015. res.ErrMsg = resSeven10265.ErrMsg
  26016. res.Cainfo = resSeven10265.Cainfo
  26017. res.WarnMsg = resSeven10265.WarnMsg
  26018. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26019. res.Infcode = infocode
  26020. } else {
  26021. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26022. utils.ErrorLog("解析失败:%v", err)
  26023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26024. return
  26025. }
  26026. }
  26027. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26028. if reg_type == 11 && his.Insutype == "390" {
  26029. reg_type = 110104
  26030. }
  26031. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26032. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26033. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26034. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26035. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26036. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26037. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26038. resp, requestErr := http.Get(api)
  26039. if requestErr != nil {
  26040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26041. return
  26042. }
  26043. body, ioErr := ioutil.ReadAll(resp.Body)
  26044. if ioErr != nil {
  26045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26047. return
  26048. }
  26049. var respJSON map[string]interface{}
  26050. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26053. return
  26054. }
  26055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26056. result, _ := json.Marshal(respJSON)
  26057. if miConfig.Code == "H15049901371" {
  26058. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26059. utils.ErrorLog("解析失败:%v", err)
  26060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26061. return
  26062. }
  26063. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26064. res.Output = resSeven10265.Output
  26065. res.ErrMsg = resSeven10265.ErrMsg
  26066. res.Cainfo = resSeven10265.Cainfo
  26067. res.WarnMsg = resSeven10265.WarnMsg
  26068. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26069. res.Infcode = infocode
  26070. } else {
  26071. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26072. utils.ErrorLog("解析失败:%v", err)
  26073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26074. return
  26075. }
  26076. }
  26077. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26078. if reg_type == 11 && his.Insutype == "390" {
  26079. reg_type = 110104
  26080. }
  26081. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26082. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26083. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26084. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26085. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26086. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26087. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26088. resp, requestErr := http.Get(api)
  26089. if requestErr != nil {
  26090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26091. return
  26092. }
  26093. body, ioErr := ioutil.ReadAll(resp.Body)
  26094. if ioErr != nil {
  26095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26097. return
  26098. }
  26099. var respJSON map[string]interface{}
  26100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26103. return
  26104. }
  26105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26106. result, _ := json.Marshal(respJSON)
  26107. if miConfig.Code == "H15049901371" {
  26108. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26109. utils.ErrorLog("解析失败:%v", err)
  26110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26111. return
  26112. }
  26113. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26114. res.Output = resSeven10265.Output
  26115. res.ErrMsg = resSeven10265.ErrMsg
  26116. res.Cainfo = resSeven10265.Cainfo
  26117. res.WarnMsg = resSeven10265.WarnMsg
  26118. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26119. res.Infcode = infocode
  26120. } else {
  26121. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26122. utils.ErrorLog("解析失败:%v", err)
  26123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26124. return
  26125. }
  26126. }
  26127. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26128. if reg_type == 11 && his.Insutype == "390" {
  26129. reg_type = 110104
  26130. }
  26131. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26132. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26133. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26134. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26135. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26136. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26137. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26138. resp, requestErr := http.Get(api)
  26139. if requestErr != nil {
  26140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26141. return
  26142. }
  26143. body, ioErr := ioutil.ReadAll(resp.Body)
  26144. if ioErr != nil {
  26145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26147. return
  26148. }
  26149. var respJSON map[string]interface{}
  26150. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26153. return
  26154. }
  26155. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26156. result, _ := json.Marshal(respJSON)
  26157. if miConfig.Code == "H15049901371" {
  26158. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26159. utils.ErrorLog("解析失败:%v", err)
  26160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26161. return
  26162. }
  26163. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26164. res.Output = resSeven10265.Output
  26165. res.ErrMsg = resSeven10265.ErrMsg
  26166. res.Cainfo = resSeven10265.Cainfo
  26167. res.WarnMsg = resSeven10265.WarnMsg
  26168. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26169. res.Infcode = infocode
  26170. } else {
  26171. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26172. utils.ErrorLog("解析失败:%v", err)
  26173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26174. return
  26175. }
  26176. }
  26177. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26178. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26179. if result3101.Infcode == "0" {
  26180. if len(result3101.Output.Result) > 0 {
  26181. var errMsgs []string
  26182. for _, item := range result3101.Output.Result {
  26183. errMsgs = append(errMsgs, item.VolaCont)
  26184. }
  26185. c.ServeSuccessJSON(map[string]interface{}{
  26186. "failed_code": -10,
  26187. "msg": errMsgs,
  26188. })
  26189. return
  26190. } else {
  26191. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26192. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26193. bas := strings.Split(psn_info.CardInfo, "|")
  26194. if his.IdCardType == 1 {
  26195. cert_no = bas[2]
  26196. } else if his.IdCardType == 3 {
  26197. cert_no = his.Certno
  26198. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26199. } else if his.IdCardType == 4 {
  26200. cert_no = his.Certno
  26201. psn_info.VerifyNumber = psn_info.VerifyNumber
  26202. }
  26203. var api string
  26204. if miConfig.MdtrtareaAdmvs == "320921" {
  26205. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26206. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26207. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26208. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26209. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26210. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26211. "&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
  26212. } else {
  26213. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26214. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26215. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26216. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26217. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26218. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26219. "&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
  26220. }
  26221. resp, requestErr := http.Get(api)
  26222. if requestErr != nil {
  26223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26224. return
  26225. }
  26226. body, ioErr := ioutil.ReadAll(resp.Body)
  26227. if ioErr != nil {
  26228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26230. return
  26231. }
  26232. var respJSON map[string]interface{}
  26233. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26236. return
  26237. }
  26238. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26239. result, _ := json.Marshal(respJSON)
  26240. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26241. utils.ErrorLog("解析失败:%v", err)
  26242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26243. return
  26244. }
  26245. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26246. res.Output = resSeven10265.Output
  26247. res.ErrMsg = resSeven10265.ErrMsg
  26248. res.Cainfo = resSeven10265.Cainfo
  26249. res.WarnMsg = resSeven10265.WarnMsg
  26250. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26251. res.Infcode = infocode
  26252. }
  26253. }
  26254. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26255. psn_info, _ := service.GetPsnByPatientId(id)
  26256. var verify_number string
  26257. if psn_info.IdCardType == 4 {
  26258. verify_number = psn_info.VerifyNumber
  26259. } else if psn_info.IdCardType == 1 {
  26260. bas := strings.Split(psn_info.CardInfo, "|")
  26261. cardNumber := bas[2]
  26262. verify_number = cardNumber
  26263. } else {
  26264. psn_info.IdCardType = 2
  26265. verify_number = psn_info.Certno
  26266. }
  26267. var api string
  26268. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26269. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26270. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26271. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26272. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26273. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26274. "&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
  26275. resp, requestErr := http.Get(api)
  26276. if requestErr != nil {
  26277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26278. return
  26279. }
  26280. body, ioErr := ioutil.ReadAll(resp.Body)
  26281. if ioErr != nil {
  26282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26284. return
  26285. }
  26286. var respJSON map[string]interface{}
  26287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26290. return
  26291. }
  26292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26293. result, _ := json.Marshal(respJSON)
  26294. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26295. utils.ErrorLog("解析失败:%v", err)
  26296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26297. return
  26298. }
  26299. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26300. res.Output = resSeven10265.Output
  26301. res.ErrMsg = resSeven10265.ErrMsg
  26302. res.Cainfo = resSeven10265.Cainfo
  26303. res.WarnMsg = resSeven10265.WarnMsg
  26304. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26305. res.Infcode = infocode
  26306. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26307. var cert_no string
  26308. if his.IdCardType == 4 {
  26309. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26310. cert_no = psn_info.VerifyNumber
  26311. 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)
  26312. } else if his.IdCardType == 1 {
  26313. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26314. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26315. 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)
  26316. }
  26317. //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)
  26318. var dat map[string]interface{}
  26319. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26320. fmt.Println(dat)
  26321. } else {
  26322. fmt.Println(err)
  26323. }
  26324. saveLog(result2, src_resquest, "2207", "结算")
  26325. userJSONBytes, _ := json.Marshal(dat)
  26326. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26327. utils.ErrorLog("解析失败:%v", err)
  26328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26329. return
  26330. }
  26331. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26332. res.Output = resSeven10265.Output
  26333. res.ErrMsg = resSeven10265.ErrMsg
  26334. res.Cainfo = resSeven10265.Cainfo
  26335. res.WarnMsg = resSeven10265.WarnMsg
  26336. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26337. res.Infcode = infocode
  26338. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26339. res2 := c.GetoleInfo()
  26340. if res2.Infcode == 0 {
  26341. var result string
  26342. var request_log string
  26343. var result_log string
  26344. if res2.Output.MdtrtCertType == "02" {
  26345. 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)
  26346. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26347. } else if res2.Output.MdtrtCertType == "01" {
  26348. 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)
  26349. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26350. } else {
  26351. 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)
  26352. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26353. }
  26354. var dat map[string]interface{}
  26355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26356. fmt.Println(dat)
  26357. } else {
  26358. fmt.Println(err)
  26359. }
  26360. userJSONBytes, _ := json.Marshal(dat)
  26361. var res5 ResultTwo
  26362. //var resTwo10265 ResultTwo10265
  26363. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26364. utils.ErrorLog("解析失败:%v", err)
  26365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26366. return
  26367. }
  26368. if res5.Infcode == -1 {
  26369. c.ServeSuccessJSON(map[string]interface{}{
  26370. "failed_code": -10,
  26371. "msg": res5.ErrMsg,
  26372. })
  26373. return
  26374. }
  26375. var insutypes []string
  26376. var insutype string
  26377. var is390 int = 0
  26378. var is310 int = 0
  26379. for _, item := range res5.Output.Iinfo {
  26380. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26381. insutypes = append(insutypes, item.Insutype)
  26382. }
  26383. }
  26384. if len(insutypes) == 1 {
  26385. insutype = insutypes[0]
  26386. } else {
  26387. for _, i := range insutypes {
  26388. if i == "390" {
  26389. is390 = 1
  26390. }
  26391. if i == "310" {
  26392. is310 = 1
  26393. }
  26394. }
  26395. }
  26396. if is390 == 1 {
  26397. insutype = "390"
  26398. }
  26399. if is310 == 1 {
  26400. insutype = "310"
  26401. }
  26402. if len(insutypes) == 0 {
  26403. insutype = "310"
  26404. }
  26405. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26406. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26407. infoStr := string(Iinfos)
  26408. idetinfoStr := string(Idetinfos)
  26409. psn := &models.HisPsn{
  26410. PsnNo: res5.Output.Baseinfo.PsnNo,
  26411. PatientId: id,
  26412. Certno: res5.Output.Baseinfo.Certno,
  26413. Gend: res5.Output.Baseinfo.Gend,
  26414. Naty: res5.Output.Baseinfo.Naty,
  26415. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26416. PsnName: res5.Output.Baseinfo.PsnName,
  26417. Idetinfo: idetinfoStr,
  26418. Insuinfo: infoStr,
  26419. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26420. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26421. VerifyNumber: res2.Output.EcToken,
  26422. }
  26423. if res2.Output.MdtrtCertType == "01" {
  26424. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26425. psn.VerifyNumber = res2.Output.EcToken
  26426. } else if res2.Output.MdtrtCertType == "02" {
  26427. psn.VerifyNumber = res2.Output.CardNo
  26428. } else {
  26429. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26430. }
  26431. service.CreateHisPsn(psn)
  26432. if res2.Output.MdtrtCertType == "01" {
  26433. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26434. token := res2.Output.EcToken
  26435. 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)
  26436. } else if res2.Output.MdtrtCertType == "02" {
  26437. 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)
  26438. } else {
  26439. 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)
  26440. }
  26441. var dat2 map[string]interface{}
  26442. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26443. fmt.Println(dat2)
  26444. } else {
  26445. fmt.Println(err)
  26446. }
  26447. userJSONBytes3, _ := json.Marshal(dat2)
  26448. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26449. utils.ErrorLog("解析失败:%v", err)
  26450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26451. return
  26452. }
  26453. saveLog(result2, src_resquest, "2207", "结算")
  26454. } else {
  26455. c.ServeSuccessJSON(map[string]interface{}{
  26456. "failed_code": -10,
  26457. "msg": res2.ErrMsg,
  26458. })
  26459. return
  26460. }
  26461. } else {
  26462. if miConfig.Code == "H15049901371" {
  26463. //赤峰地区国家医保医疗类别
  26464. //职工透析:医疗类别选特殊情况门诊990502
  26465. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26466. var med_type string
  26467. if his.Insutype == "390" {
  26468. if reg_type == 14 {
  26469. med_type = "9933"
  26470. } else if reg_type == 11 {
  26471. med_type = "11"
  26472. }
  26473. } else if his.Insutype == "310" {
  26474. if reg_type == 14 {
  26475. med_type = "990502"
  26476. } else if reg_type == 11 {
  26477. med_type = "11"
  26478. }
  26479. }
  26480. 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)
  26481. } else {
  26482. if his.IdCardType == 4 {
  26483. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26484. var token string
  26485. token = psn_info.VerifyNumber
  26486. 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)
  26487. } else {
  26488. if his.IdCardType == 1 {
  26489. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26490. bas := strings.Split(psn_info.CardInfo, "|")
  26491. basNumber := bas[2]
  26492. cert_no = basNumber
  26493. }
  26494. 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)
  26495. }
  26496. }
  26497. //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)
  26498. var dat map[string]interface{}
  26499. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26500. fmt.Println(dat)
  26501. } else {
  26502. fmt.Println(err)
  26503. }
  26504. saveLog(result2, src_resquest, "2207", "结算")
  26505. userJSONBytes, _ := json.Marshal(dat)
  26506. if miConfig.Code == "H15049901371" {
  26507. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26508. utils.ErrorLog("解析失败:%v", err)
  26509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26510. return
  26511. }
  26512. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26513. res.Output = resSeven10265.Output
  26514. res.ErrMsg = resSeven10265.ErrMsg
  26515. res.Cainfo = resSeven10265.Cainfo
  26516. res.WarnMsg = resSeven10265.WarnMsg
  26517. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26518. res.Infcode = infocode
  26519. } else {
  26520. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26521. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26522. utils.ErrorLog("解析失败:%v", err)
  26523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26524. return
  26525. }
  26526. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26527. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26528. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26529. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26530. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26531. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26532. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26533. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26534. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26535. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26536. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26537. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26538. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26539. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26540. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26541. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26542. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26543. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26544. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26545. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26546. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26547. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26548. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26549. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26550. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26551. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26552. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26553. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26554. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26555. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26556. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26557. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26558. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26559. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26560. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26561. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26562. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26563. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26564. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26565. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26566. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26567. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26568. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26569. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26570. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26571. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26572. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26573. res.Cainfo = gzresSeven10265Two.Cainfo
  26574. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26575. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26576. //res.Infcode = infocode
  26577. } else {
  26578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26579. utils.ErrorLog("解析失败:%v", err)
  26580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26581. return
  26582. }
  26583. }
  26584. }
  26585. }
  26586. if res.Infcode == -1 {
  26587. errlog := &models.HisOrderError{
  26588. UserOrgId: adminUser.CurrentOrgId,
  26589. Ctime: time.Now().Unix(),
  26590. Mtime: time.Now().Unix(),
  26591. Number: chrg_bchno,
  26592. ErrMsg: res.ErrMsg,
  26593. Status: 1,
  26594. PatientId: id,
  26595. RecordTime: recordDateTime,
  26596. Stage: 6,
  26597. }
  26598. service.CreateErrMsgLog(errlog)
  26599. c.ServeSuccessJSON(map[string]interface{}{
  26600. "failed_code": -10,
  26601. "msg": res.ErrMsg,
  26602. })
  26603. return
  26604. } else {
  26605. sickConfig, _ := service.FindSickById(his.SickType)
  26606. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26607. order.OrderStatus = 2
  26608. order.Status = 1
  26609. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26610. order.SetlId = res.Output.Setlinfo.SetlID
  26611. order.PsnNo = res.Output.Setlinfo.PsnNo
  26612. order.PsnName = res.Output.Setlinfo.PsnName
  26613. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26614. order.Certno = res.Output.Setlinfo.Certno
  26615. order.Gend = res.Output.Setlinfo.Gend
  26616. order.Naty = res.Output.Setlinfo.Naty
  26617. order.Age = res.Output.Setlinfo.Age
  26618. order.Insutype = res.Output.Setlinfo.Insutype
  26619. order.PsnType = res.Output.Setlinfo.PsnType
  26620. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26621. order.SetlTime = res.Output.Setlinfo.SetlTime
  26622. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26623. if res.Output.Setlinfo.MedType == "140101" {
  26624. order.MedType = "14"
  26625. } else {
  26626. if res.Output.Setlinfo.MedType == "110104" {
  26627. order.MedType = "11"
  26628. } else {
  26629. order.MedType = res.Output.Setlinfo.MedType
  26630. }
  26631. }
  26632. if reg_type == 1112 {
  26633. order.MedType = "1112"
  26634. }
  26635. if reg_type == 1111 {
  26636. order.MedType = "1111"
  26637. }
  26638. order.ClrType = res.Output.Setlinfo.ClrType
  26639. if adminUser.CurrentOrgId == 10480 {
  26640. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26641. order.ClrType = "11"
  26642. } else {
  26643. order.ClrType = "9903"
  26644. }
  26645. }
  26646. if adminUser.CurrentOrgId == 10721 {
  26647. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26648. order.ClrType = "11"
  26649. } else {
  26650. order.ClrType = "9903"
  26651. }
  26652. }
  26653. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26654. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26655. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26656. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26657. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26658. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26659. order.HifpPay = res.Output.Setlinfo.HifpPay
  26660. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26661. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26662. order.HifesPay = res.Output.Setlinfo.HifesPay
  26663. order.HifobPay = res.Output.Setlinfo.HifobPay
  26664. order.MafPay = res.Output.Setlinfo.MafPay
  26665. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26666. order.OthPay = res.Output.Setlinfo.OthPay
  26667. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26668. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26669. order.AcctPay = res.Output.Setlinfo.AcctPay
  26670. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26671. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26672. order.Balc = res.Output.Setlinfo.Balc
  26673. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26674. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26675. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26676. //order.ClrType = res.Output.Setlinfo.ClrType
  26677. order.ClrWay = res.Output.Setlinfo.ClrWay
  26678. order.Creator = order.Creator
  26679. order.Modify = roles.AdminUserId
  26680. order.RequestLog = src_resquest
  26681. order.FaPiaoNumber = fapiao_number
  26682. order.FaPiaoCode = fapiao_code
  26683. order.SickName = sickConfig.ClassName
  26684. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26685. //detailStr := string(setlDetail)
  26686. //order.SetlDetail = detailStr
  26687. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26688. err = service.UpDateOrder(order)
  26689. if err == nil {
  26690. //判断是否使用了押金
  26691. if dec_way == "true" {
  26692. tmpstring := strconv.FormatInt(order.ID, 10)
  26693. order.Decimal = decimal
  26694. service.UpDateOrder(order)
  26695. //扣押金
  26696. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26697. if errmsg != nil {
  26698. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26699. return
  26700. }
  26701. }
  26702. c.ServeSuccessJSON(map[string]interface{}{
  26703. "msg": "结算成功",
  26704. })
  26705. } else {
  26706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26707. return
  26708. }
  26709. }
  26710. } else {
  26711. adminUser := c.GetAdminUserInfo()
  26712. errlog := &models.HisOrderError{
  26713. UserOrgId: adminUser.CurrentOrgId,
  26714. Ctime: time.Now().Unix(),
  26715. Mtime: time.Now().Unix(),
  26716. ErrMsg: res.ErrMsg,
  26717. Status: 1,
  26718. PatientId: id,
  26719. RecordTime: recordDateTime,
  26720. Stage: 4,
  26721. }
  26722. service.CreateErrMsgLog(errlog)
  26723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26724. return
  26725. }
  26726. } else {
  26727. adminUser := c.GetAdminUserInfo()
  26728. errlog := &models.HisOrderError{
  26729. UserOrgId: adminUser.CurrentOrgId,
  26730. Ctime: time.Now().Unix(),
  26731. Mtime: time.Now().Unix(),
  26732. ErrMsg: res.ErrMsg,
  26733. Status: 1,
  26734. PatientId: id,
  26735. RecordTime: recordDateTime,
  26736. Stage: 4,
  26737. }
  26738. service.CreateErrMsgLog(errlog)
  26739. c.ServeSuccessJSON(map[string]interface{}{
  26740. "failed_code": -10,
  26741. "msg": res.ErrMsg,
  26742. })
  26743. return
  26744. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26745. //return
  26746. }
  26747. }
  26748. }
  26749. } else if tempOrder.ID > 0 {
  26750. if tempOrder.IsPre == 1 {
  26751. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26752. var rf []*ResultFive
  26753. json.Unmarshal([]byte(his.Iinfo), &rf)
  26754. chrg_bchno := tempOrder.Number
  26755. cert_no := his.Certno
  26756. var insutypes []string
  26757. var insutype string
  26758. var is390 int = 0
  26759. var is310 int = 0
  26760. for _, item := range rf {
  26761. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26762. insutypes = append(insutypes, item.Insutype)
  26763. }
  26764. }
  26765. if len(insutypes) == 1 {
  26766. insutype = insutypes[0]
  26767. } else {
  26768. for _, i := range insutypes {
  26769. if i == "390" {
  26770. is390 = 1
  26771. }
  26772. if i == "310" {
  26773. is310 = 1
  26774. }
  26775. }
  26776. }
  26777. if is390 == 1 {
  26778. insutype = "390"
  26779. }
  26780. if is310 == 1 {
  26781. insutype = "310"
  26782. }
  26783. if len(insutypes) == 0 {
  26784. insutype = "310"
  26785. }
  26786. if len(insutypes) == 2 {
  26787. insutype = strconv.FormatInt(his.SocialType, 10)
  26788. }
  26789. //insutype = "390"
  26790. if his.IdCardType == 1 {
  26791. // cert_no = his.MedicalInsuranceNumber
  26792. cert_no = his.Certno
  26793. } else {
  26794. cert_no = his.Certno
  26795. }
  26796. var res ResultSeven
  26797. var ahres ResultSevenAH
  26798. var resSeven10265 ResultSeven10265
  26799. var gzresSeven10265Two GZResultSeven10265Two
  26800. var src_resquest string
  26801. var result2 string
  26802. if miConfig.MdtrtareaAdmvs == "450721" {
  26803. res2 := c.GetoleInfo()
  26804. if res2.Infcode == 0 {
  26805. var result string
  26806. var request_log string
  26807. var result_log string
  26808. if res2.Output.MdtrtCertType == "02" {
  26809. 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)
  26810. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26811. } else if res2.Output.MdtrtCertType == "01" {
  26812. 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)
  26813. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26814. } else {
  26815. 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)
  26816. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26817. }
  26818. var dat map[string]interface{}
  26819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26820. fmt.Println(dat)
  26821. } else {
  26822. fmt.Println(err)
  26823. }
  26824. userJSONBytes, _ := json.Marshal(dat)
  26825. var res5 ResultTwo
  26826. //var resTwo10265 ResultTwo10265
  26827. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26828. utils.ErrorLog("解析失败:%v", err)
  26829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26830. return
  26831. }
  26832. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26833. if res5.Infcode == -1 {
  26834. c.ServeSuccessJSON(map[string]interface{}{
  26835. "failed_code": -10,
  26836. "msg": res5.ErrMsg,
  26837. })
  26838. return
  26839. }
  26840. var insutypes []string
  26841. var insutype string
  26842. var is390 int = 0
  26843. var is310 int = 0
  26844. for _, item := range res5.Output.Iinfo {
  26845. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26846. insutypes = append(insutypes, item.Insutype)
  26847. }
  26848. }
  26849. if len(insutypes) == 1 {
  26850. insutype = insutypes[0]
  26851. } else {
  26852. for _, i := range insutypes {
  26853. if i == "390" {
  26854. is390 = 1
  26855. }
  26856. if i == "310" {
  26857. is310 = 1
  26858. }
  26859. }
  26860. }
  26861. if is390 == 1 {
  26862. insutype = "390"
  26863. }
  26864. if is310 == 1 {
  26865. insutype = "310"
  26866. }
  26867. if len(insutypes) == 0 {
  26868. insutype = "310"
  26869. }
  26870. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26871. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26872. infoStr := string(Iinfos)
  26873. idetinfoStr := string(Idetinfos)
  26874. psn := &models.HisPsn{
  26875. PsnNo: res5.Output.Baseinfo.PsnNo,
  26876. PatientId: id,
  26877. Certno: res5.Output.Baseinfo.Certno,
  26878. Gend: res5.Output.Baseinfo.Gend,
  26879. Naty: res5.Output.Baseinfo.Naty,
  26880. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26881. PsnName: res5.Output.Baseinfo.PsnName,
  26882. Idetinfo: idetinfoStr,
  26883. Insuinfo: infoStr,
  26884. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26885. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26886. VerifyNumber: res2.Output.EcToken,
  26887. }
  26888. service.CreateHisPsn(psn)
  26889. if res2.Output.MdtrtCertType == "01" {
  26890. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26891. token := res2.Output.EcToken
  26892. 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)
  26893. } else if res2.Output.MdtrtCertType == "02" {
  26894. 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)
  26895. } else {
  26896. 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)
  26897. }
  26898. var dat2 map[string]interface{}
  26899. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26900. fmt.Println(dat2)
  26901. } else {
  26902. fmt.Println(err)
  26903. }
  26904. userJSONBytes3, _ := json.Marshal(dat2)
  26905. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26906. utils.ErrorLog("解析失败:%v", err)
  26907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26908. return
  26909. }
  26910. saveLog(result2, src_resquest, "2207", "结算")
  26911. } else {
  26912. c.ServeSuccessJSON(map[string]interface{}{
  26913. "failed_code": -10,
  26914. "msg": res2.ErrMsg,
  26915. })
  26916. return
  26917. }
  26918. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26919. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26920. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26921. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26922. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26923. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26924. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26925. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26926. resp, requestErr := http.Get(api)
  26927. if requestErr != nil {
  26928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26929. return
  26930. }
  26931. body, ioErr := ioutil.ReadAll(resp.Body)
  26932. if ioErr != nil {
  26933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26935. return
  26936. }
  26937. var respJSON map[string]interface{}
  26938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26941. return
  26942. }
  26943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26944. result, _ := json.Marshal(respJSON)
  26945. fmt.Println("log")
  26946. fmt.Println(string(result))
  26947. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26948. utils.ErrorLog("解析失败:%v", err)
  26949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26950. return
  26951. }
  26952. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26953. if reg_type == 11 && his.Insutype == "390" {
  26954. reg_type = 110104
  26955. }
  26956. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26957. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26958. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26960. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26961. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26962. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26963. resp, requestErr := http.Get(api)
  26964. if requestErr != nil {
  26965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26966. return
  26967. }
  26968. body, ioErr := ioutil.ReadAll(resp.Body)
  26969. if ioErr != nil {
  26970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26972. return
  26973. }
  26974. var respJSON map[string]interface{}
  26975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26978. return
  26979. }
  26980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26981. result, _ := json.Marshal(respJSON)
  26982. fmt.Println("log")
  26983. fmt.Println(string(result))
  26984. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26985. utils.ErrorLog("解析失败:%v", err)
  26986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26987. return
  26988. }
  26989. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26990. if reg_type == 11 && his.Insutype == "390" {
  26991. reg_type = 110104
  26992. }
  26993. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26994. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26995. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26996. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26997. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26998. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26999. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27000. resp, requestErr := http.Get(api)
  27001. if requestErr != nil {
  27002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27003. return
  27004. }
  27005. body, ioErr := ioutil.ReadAll(resp.Body)
  27006. if ioErr != nil {
  27007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27009. return
  27010. }
  27011. var respJSON map[string]interface{}
  27012. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27015. return
  27016. }
  27017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27018. result, _ := json.Marshal(respJSON)
  27019. fmt.Println("log")
  27020. fmt.Println(string(result))
  27021. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27022. utils.ErrorLog("解析失败:%v", err)
  27023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27024. return
  27025. }
  27026. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27027. if reg_type == 11 && his.Insutype == "390" {
  27028. reg_type = 110104
  27029. }
  27030. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27031. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27032. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27034. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27035. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27036. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27037. resp, requestErr := http.Get(api)
  27038. if requestErr != nil {
  27039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27040. return
  27041. }
  27042. body, ioErr := ioutil.ReadAll(resp.Body)
  27043. if ioErr != nil {
  27044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27046. return
  27047. }
  27048. var respJSON map[string]interface{}
  27049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27052. return
  27053. }
  27054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27055. result, _ := json.Marshal(respJSON)
  27056. fmt.Println("log")
  27057. fmt.Println(string(result))
  27058. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27059. utils.ErrorLog("解析失败:%v", err)
  27060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27061. return
  27062. }
  27063. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27064. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27065. if result3101.Infcode == "0" {
  27066. if len(result3101.Output.Result) > 0 {
  27067. var errMsgs []string
  27068. for _, item := range result3101.Output.Result {
  27069. errMsgs = append(errMsgs, item.VolaCont)
  27070. }
  27071. c.ServeSuccessJSON(map[string]interface{}{
  27072. "failed_code": -10,
  27073. "msg": errMsgs,
  27074. })
  27075. return
  27076. } else {
  27077. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27078. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27079. bas := strings.Split(psn_info.CardInfo, "|")
  27080. if his.IdCardType == 1 {
  27081. cert_no = bas[2]
  27082. } else if his.IdCardType == 3 {
  27083. cert_no = his.Certno
  27084. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27085. } else if his.IdCardType == 4 {
  27086. cert_no = his.Certno
  27087. psn_info.VerifyNumber = psn_info.VerifyNumber
  27088. }
  27089. //江苏地区国家医保医疗类别
  27090. //职工透析:医疗类别选特殊情况门诊9933
  27091. //居民血透门慢: 医疗类别选门诊慢病1402
  27092. //var med_type string
  27093. //if his.Insutype == "310" {
  27094. // if reg_type == 14 {
  27095. // med_type = "9933"
  27096. // } else if reg_type == 11 {
  27097. // med_type = "11"
  27098. //
  27099. // }
  27100. //} else if his.Insutype == "390" {
  27101. // if reg_type == 14 {
  27102. // med_type = "1402"
  27103. // } else if reg_type == 11 {
  27104. // med_type = "11"
  27105. // }
  27106. //}
  27107. var api string
  27108. if miConfig.MdtrtareaAdmvs == "320921" {
  27109. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27110. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27111. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27112. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27113. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27114. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27115. "&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
  27116. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27117. } else {
  27118. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27119. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27120. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27121. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27122. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27123. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27124. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27125. "&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
  27126. }
  27127. resp, requestErr := http.Get(api)
  27128. if requestErr != nil {
  27129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27130. return
  27131. }
  27132. body, ioErr := ioutil.ReadAll(resp.Body)
  27133. if ioErr != nil {
  27134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27136. return
  27137. }
  27138. var respJSON map[string]interface{}
  27139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27142. return
  27143. }
  27144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27145. result, _ := json.Marshal(respJSON)
  27146. fmt.Println("log")
  27147. fmt.Println(string(result))
  27148. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27149. utils.ErrorLog("解析失败:%v", err)
  27150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27151. return
  27152. }
  27153. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27154. res.Output = resSeven10265.Output
  27155. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27156. res.ErrMsg = resSeven10265.ErrMsg
  27157. res.Cainfo = resSeven10265.Cainfo
  27158. res.WarnMsg = resSeven10265.WarnMsg
  27159. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27160. res.Infcode = infocode
  27161. }
  27162. }
  27163. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27164. psn_info, _ := service.GetPsnByPatientId(id)
  27165. var verify_number string
  27166. if psn_info.IdCardType == 4 {
  27167. verify_number = psn_info.VerifyNumber
  27168. } else if psn_info.IdCardType == 1 {
  27169. bas := strings.Split(psn_info.CardInfo, "|")
  27170. cardNumber := bas[2]
  27171. verify_number = cardNumber
  27172. } else {
  27173. verify_number = psn_info.Certno
  27174. psn_info.IdCardType = 2
  27175. }
  27176. var api string
  27177. new_chrg_bchno := chrg_bchno
  27178. if adminUser.CurrentOrgId == 10265 {
  27179. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27180. new_chrg_bchno = "0000"
  27181. }
  27182. }
  27183. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27184. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27185. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27186. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27187. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27188. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27189. "&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
  27190. resp, requestErr := http.Get(api)
  27191. if requestErr != nil {
  27192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27193. return
  27194. }
  27195. body, ioErr := ioutil.ReadAll(resp.Body)
  27196. if ioErr != nil {
  27197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27199. return
  27200. }
  27201. var respJSON map[string]interface{}
  27202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27205. return
  27206. }
  27207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27208. result, _ := json.Marshal(respJSON)
  27209. fmt.Println("log")
  27210. fmt.Println(string(result))
  27211. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27212. utils.ErrorLog("解析失败:%v", err)
  27213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27214. return
  27215. }
  27216. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27217. res.Output = resSeven10265.Output
  27218. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27219. res.ErrMsg = resSeven10265.ErrMsg
  27220. res.Cainfo = resSeven10265.Cainfo
  27221. res.WarnMsg = resSeven10265.WarnMsg
  27222. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27223. res.Infcode = infocode
  27224. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27225. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27226. var cert_no string
  27227. if his.IdCardType == 1 {
  27228. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27229. } else {
  27230. cert_no = psn_info.VerifyNumber
  27231. }
  27232. 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)
  27233. var dat map[string]interface{}
  27234. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27235. fmt.Println(dat)
  27236. } else {
  27237. fmt.Println(err)
  27238. }
  27239. saveLog(result2, src_resquest, "2207", "结算")
  27240. userJSONBytes, _ := json.Marshal(dat)
  27241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27242. utils.ErrorLog("解析失败:%v", err)
  27243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27244. return
  27245. }
  27246. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27247. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27248. var cert_no string
  27249. var card_sn string
  27250. if his.IdCardType == 1 {
  27251. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27252. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27253. bas := strings.Split(psn_info.CardInfo, "|")
  27254. card_sn = bas[3]
  27255. } else if his.IdCardType == 2 {
  27256. cert_no = his.IdCardNo
  27257. } else {
  27258. cert_no = psn_info.VerifyNumber
  27259. }
  27260. var rf []*ResultFive
  27261. json.Unmarshal([]byte(his.Iinfo), &rf)
  27262. var psn_type string
  27263. for _, item := range rf {
  27264. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27265. psn_type = item.PsnType
  27266. }
  27267. }
  27268. 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)
  27269. var dat map[string]interface{}
  27270. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27271. fmt.Println(dat)
  27272. } else {
  27273. fmt.Println(err)
  27274. }
  27275. saveLog(result2, src_resquest, "2207", "结算")
  27276. userJSONBytes, _ := json.Marshal(dat)
  27277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27278. utils.ErrorLog("解析失败:%v", err)
  27279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27280. return
  27281. }
  27282. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27283. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27284. var cert_no string
  27285. var card_sn string
  27286. if his.IdCardType == 1 {
  27287. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27288. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27289. //bas := strings.Split(psn_info.CardInfo, "|")
  27290. card_sn = ""
  27291. } else if his.IdCardType == 2 {
  27292. cert_no = his.IdCardNo
  27293. } else {
  27294. cert_no = psn_info.VerifyNumber
  27295. }
  27296. var rf []*ResultFive
  27297. json.Unmarshal([]byte(his.Iinfo), &rf)
  27298. var psn_type string
  27299. for _, item := range rf {
  27300. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27301. psn_type = item.PsnType
  27302. }
  27303. }
  27304. 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)
  27305. var dat map[string]interface{}
  27306. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27307. fmt.Println(dat)
  27308. } else {
  27309. fmt.Println(err)
  27310. }
  27311. saveLog(result2, src_resquest, "2207", "结算")
  27312. userJSONBytes, _ := json.Marshal(dat)
  27313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27314. utils.ErrorLog("解析失败:%v", err)
  27315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27316. return
  27317. }
  27318. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27319. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27320. if his.IdCardType == 1 {
  27321. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27322. bas := strings.Split(psn_info.CardInfo, "|")
  27323. cert_no = bas[2]
  27324. } else if his.IdCardType == 3 {
  27325. cert_no = his.Certno
  27326. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27327. } else if his.IdCardType == 4 {
  27328. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27329. cert_no = psn_info.VerifyNumber
  27330. psn_info.VerifyNumber = psn_info.VerifyNumber
  27331. } else {
  27332. cert_no = his.Certno
  27333. psn_info.VerifyNumber = his.Certno
  27334. }
  27335. var api string
  27336. var med_type string
  27337. if his.Insutype == "390" {
  27338. if reg_type == 992102 {
  27339. med_type = "992102"
  27340. }
  27341. if reg_type == 140104 {
  27342. med_type = "140104"
  27343. }
  27344. if reg_type == 140201 {
  27345. med_type = "140201"
  27346. }
  27347. if reg_type == 14 {
  27348. med_type = "14"
  27349. }
  27350. } else if his.Insutype == "310" {
  27351. if reg_type == 992102 {
  27352. med_type = "992102"
  27353. }
  27354. if reg_type == 140104 {
  27355. med_type = "140104"
  27356. }
  27357. if reg_type == 140201 {
  27358. med_type = "140201"
  27359. }
  27360. if reg_type == 14 {
  27361. med_type = "14"
  27362. }
  27363. }
  27364. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27365. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27366. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27367. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27368. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27369. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27370. "&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
  27371. resp, requestErr := http.Get(api)
  27372. if requestErr != nil {
  27373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27374. return
  27375. }
  27376. body, ioErr := ioutil.ReadAll(resp.Body)
  27377. if ioErr != nil {
  27378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27380. return
  27381. }
  27382. var respJSON map[string]interface{}
  27383. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27386. return
  27387. }
  27388. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27389. if status == "0" {
  27390. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27391. c.ServeSuccessJSON(map[string]interface{}{
  27392. "failed_code": -10,
  27393. "msg": err_msg,
  27394. })
  27395. return
  27396. }
  27397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27398. result, _ := json.Marshal(respJSON)
  27399. fmt.Println("log")
  27400. fmt.Println(string(result))
  27401. if err := json.Unmarshal(result, &ahres); err != nil {
  27402. utils.ErrorLog("解析失败:%v", err)
  27403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27404. return
  27405. }
  27406. res.InfRefmsgid = ahres.InfRefmsgid
  27407. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27408. // 创建对应的Time类型
  27409. t := time.UnixMilli(timestamp)
  27410. // 格式化成指定的日期字符串
  27411. str := t.Format("2006-01-02 15:04:05")
  27412. res.Output.Setlinfo.SetlTime = str
  27413. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27414. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27415. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27416. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27417. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27418. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27419. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27420. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27421. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27422. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27423. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27424. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27425. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27426. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27427. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27428. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27429. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27430. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27431. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27432. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27433. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27434. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27435. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27436. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27437. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27438. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27439. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27440. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27441. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27442. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27443. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27444. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27445. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27446. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27447. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27448. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27449. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27450. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27451. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27452. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27453. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27454. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27455. res.Output.Setldetail = ahres.Output.Setldetail
  27456. res.ErrMsg = ahres.ErrMsg
  27457. res.Cainfo = ahres.Cainfo
  27458. res.WarnMsg = ahres.WarnMsg
  27459. res.Infcode = ahres.Infcode
  27460. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27461. res.Output.Setlinfo.ClrType = "11"
  27462. } else {
  27463. res.Output.Setlinfo.ClrType = "9903"
  27464. }
  27465. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27466. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27467. if his.IdCardType == 1 {
  27468. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27469. bas := strings.Split(psn_info.CardInfo, "|")
  27470. cert_no = bas[2]
  27471. } else if his.IdCardType == 3 {
  27472. cert_no = his.Certno
  27473. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27474. } else if his.IdCardType == 4 {
  27475. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27476. cert_no = his.Certno
  27477. psn_info.VerifyNumber = psn_info.VerifyNumber
  27478. } else {
  27479. cert_no = his.Certno
  27480. psn_info.VerifyNumber = his.Certno
  27481. }
  27482. var api string
  27483. var med_type string
  27484. if his.Insutype == "390" {
  27485. if reg_type == 992102 {
  27486. med_type = "992102"
  27487. }
  27488. if reg_type == 140104 {
  27489. med_type = "140104"
  27490. }
  27491. if reg_type == 14 {
  27492. med_type = "14"
  27493. }
  27494. if reg_type == 140201 {
  27495. med_type = "140201"
  27496. }
  27497. } else if his.Insutype == "310" {
  27498. if reg_type == 992102 {
  27499. med_type = "992102"
  27500. }
  27501. if reg_type == 14 {
  27502. med_type = "14"
  27503. }
  27504. if reg_type == 140104 {
  27505. med_type = "140104"
  27506. }
  27507. if reg_type == 140201 {
  27508. med_type = "140201"
  27509. }
  27510. }
  27511. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27512. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27517. "&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
  27518. resp, requestErr := http.Get(api)
  27519. if requestErr != nil {
  27520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27521. return
  27522. }
  27523. body, ioErr := ioutil.ReadAll(resp.Body)
  27524. if ioErr != nil {
  27525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27527. return
  27528. }
  27529. var respJSON map[string]interface{}
  27530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27533. return
  27534. }
  27535. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27536. if status == "0" {
  27537. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27538. c.ServeSuccessJSON(map[string]interface{}{
  27539. "failed_code": -10,
  27540. "msg": err_msg,
  27541. })
  27542. return
  27543. }
  27544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27545. result, _ := json.Marshal(respJSON)
  27546. fmt.Println("log")
  27547. fmt.Println(string(result))
  27548. if err := json.Unmarshal(result, &ahres); err != nil {
  27549. utils.ErrorLog("解析失败:%v", err)
  27550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27551. return
  27552. }
  27553. res.InfRefmsgid = ahres.InfRefmsgid
  27554. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27555. // 创建对应的Time类型
  27556. t := time.UnixMilli(timestamp)
  27557. // 格式化成指定的日期字符串
  27558. str := t.Format("2006-01-02 15:04:05")
  27559. res.Output.Setlinfo.SetlTime = str
  27560. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27561. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27562. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27563. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27564. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27565. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27566. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27567. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27568. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27569. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27570. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27571. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27572. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27573. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27574. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27575. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27576. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27577. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27578. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27579. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27580. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27581. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27582. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27583. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27584. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27585. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27586. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27587. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27588. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27589. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27590. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27591. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27592. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27593. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27594. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27595. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27596. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27597. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27598. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27599. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27600. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27601. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27602. res.Output.Setldetail = ahres.Output.Setldetail
  27603. res.ErrMsg = ahres.ErrMsg
  27604. res.Cainfo = ahres.Cainfo
  27605. res.WarnMsg = ahres.WarnMsg
  27606. res.Infcode = ahres.Infcode
  27607. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27608. res.Output.Setlinfo.ClrType = "11"
  27609. } else {
  27610. res.Output.Setlinfo.ClrType = "9903"
  27611. }
  27612. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27613. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27614. var cert_no string
  27615. if his.IdCardType == 1 {
  27616. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27617. } else if his.IdCardType == 2 {
  27618. cert_no = his.IdCardNo
  27619. } else {
  27620. cert_no = psn_info.VerifyNumber
  27621. }
  27622. 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, "")
  27623. var dat map[string]interface{}
  27624. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27625. fmt.Println(dat)
  27626. } else {
  27627. fmt.Println(err)
  27628. }
  27629. saveLog(result2, src_resquest, "2207", "结算")
  27630. userJSONBytes, _ := json.Marshal(dat)
  27631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27632. utils.ErrorLog("解析失败:%v", err)
  27633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27634. return
  27635. }
  27636. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27637. psn_info, _ := service.GetPsnByPatientId(id)
  27638. var verify_number string
  27639. if psn_info.IdCardType == 4 {
  27640. verify_number = psn_info.VerifyNumber
  27641. } else if psn_info.IdCardType == 1 {
  27642. bas := strings.Split(psn_info.CardInfo, "|")
  27643. cardNumber := bas[2]
  27644. verify_number = cardNumber
  27645. } else {
  27646. verify_number = psn_info.Certno
  27647. psn_info.IdCardType = 2
  27648. }
  27649. var api string
  27650. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27651. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27652. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27653. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27654. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27655. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27656. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27657. resp, requestErr := http.Get(api)
  27658. if requestErr != nil {
  27659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27660. return
  27661. }
  27662. body, ioErr := ioutil.ReadAll(resp.Body)
  27663. if ioErr != nil {
  27664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27666. return
  27667. }
  27668. var respJSON map[string]interface{}
  27669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27672. return
  27673. }
  27674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27675. result, _ := json.Marshal(respJSON)
  27676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27677. utils.ErrorLog("解析失败:%v", err)
  27678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27679. return
  27680. }
  27681. } else {
  27682. var src_resquest string
  27683. if miConfig.Code == "H15049901371" {
  27684. //赤峰地区国家医保医疗类别
  27685. //职工透析:医疗类别选特殊情况门诊990502
  27686. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27687. var med_type string
  27688. if his.Insutype == "390" {
  27689. if reg_type == 14 {
  27690. med_type = "9933"
  27691. } else if reg_type == 11 {
  27692. med_type = "11"
  27693. }
  27694. } else if his.Insutype == "310" {
  27695. if reg_type == 14 {
  27696. med_type = "990502"
  27697. } else if reg_type == 11 {
  27698. med_type = "11"
  27699. }
  27700. }
  27701. 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)
  27702. } else {
  27703. if his.IdCardType == 4 {
  27704. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27705. token := psn_info.VerifyNumber
  27706. 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)
  27707. } else {
  27708. 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)
  27709. }
  27710. }
  27711. var dat map[string]interface{}
  27712. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27713. fmt.Println(dat)
  27714. } else {
  27715. fmt.Println(err)
  27716. }
  27717. saveLog(result2, src_resquest, "2207", "结算")
  27718. userJSONBytes, _ := json.Marshal(dat)
  27719. if miConfig.Code == "H15049901371" {
  27720. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27721. utils.ErrorLog("解析失败:%v", err)
  27722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27723. return
  27724. }
  27725. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27726. res.Output = resSeven10265.Output
  27727. res.ErrMsg = resSeven10265.ErrMsg
  27728. res.Cainfo = resSeven10265.Cainfo
  27729. res.WarnMsg = resSeven10265.WarnMsg
  27730. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27731. res.Infcode = infocode
  27732. } else {
  27733. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27734. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27735. utils.ErrorLog("解析失败:%v", err)
  27736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27737. return
  27738. }
  27739. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27740. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27741. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27742. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27743. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27744. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27745. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27746. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27747. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27748. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27749. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27750. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27751. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27752. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27753. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27754. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27755. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27756. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27757. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27758. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27759. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27760. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27761. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27762. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27763. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27764. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27765. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27766. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27767. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27768. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27769. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27770. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27771. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27772. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27773. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27774. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27775. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27776. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27777. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27778. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27779. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27780. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27781. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27782. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27783. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27784. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27785. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27786. res.Cainfo = gzresSeven10265Two.Cainfo
  27787. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27788. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27789. //res.Infcode = infocode
  27790. } else {
  27791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27792. utils.ErrorLog("解析失败:%v", err)
  27793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27794. return
  27795. }
  27796. }
  27797. }
  27798. }
  27799. if res.Infcode == -1 {
  27800. errlog := &models.HisOrderError{
  27801. UserOrgId: adminUser.CurrentOrgId,
  27802. Ctime: time.Now().Unix(),
  27803. Mtime: time.Now().Unix(),
  27804. Number: chrg_bchno,
  27805. ErrMsg: res.ErrMsg,
  27806. Status: 1,
  27807. PatientId: id,
  27808. RecordTime: recordDateTime,
  27809. Stage: 6,
  27810. }
  27811. service.CreateErrMsgLog(errlog)
  27812. c.ServeSuccessJSON(map[string]interface{}{
  27813. "failed_code": -10,
  27814. "msg": res.ErrMsg,
  27815. })
  27816. return
  27817. } else {
  27818. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27819. order.OrderStatus = 2
  27820. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27821. order.SetlId = res.Output.Setlinfo.SetlID
  27822. order.PsnNo = res.Output.Setlinfo.PsnNo
  27823. order.PsnName = res.Output.Setlinfo.PsnName
  27824. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27825. order.Certno = res.Output.Setlinfo.Certno
  27826. order.Gend = res.Output.Setlinfo.Gend
  27827. order.Naty = res.Output.Setlinfo.Naty
  27828. order.Age = res.Output.Setlinfo.Age
  27829. order.Insutype = res.Output.Setlinfo.Insutype
  27830. order.PsnType = res.Output.Setlinfo.PsnType
  27831. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27832. order.SetlTime = res.Output.Setlinfo.SetlTime
  27833. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27834. order.PayWays = pay_ways
  27835. order.AcctUsedFlag = acct_used_flag
  27836. order.WechatPay = wechat_pay
  27837. order.AliPay = ali_pay
  27838. order.JifenPay = jifen_pay
  27839. order.BandCardPay = band_card_pay
  27840. order.CashPay = cash_pay
  27841. order.OthDesc = oth_desc
  27842. //order.MedType = res.Output.Setlinfo.MedType
  27843. if reg_type == 1112 {
  27844. order.MedType = "1112"
  27845. }
  27846. if reg_type == 1111 {
  27847. order.MedType = "1111"
  27848. }
  27849. order.ClrType = res.Output.Setlinfo.ClrType
  27850. if adminUser.CurrentOrgId == 10480 {
  27851. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27852. order.ClrType = "11"
  27853. } else {
  27854. order.ClrType = "9903"
  27855. }
  27856. }
  27857. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27858. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27859. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27860. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27861. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27862. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27863. order.HifpPay = res.Output.Setlinfo.HifpPay
  27864. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27865. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27866. order.HifesPay = res.Output.Setlinfo.HifesPay
  27867. order.HifobPay = res.Output.Setlinfo.HifobPay
  27868. order.MafPay = res.Output.Setlinfo.MafPay
  27869. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27870. order.OthPay = res.Output.Setlinfo.OthPay
  27871. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27872. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27873. order.AcctPay = res.Output.Setlinfo.AcctPay
  27874. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27875. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27876. order.Balc = res.Output.Setlinfo.Balc
  27877. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27878. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27879. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27880. order.ClrWay = res.Output.Setlinfo.ClrWay
  27881. order.Creator = order.Creator
  27882. order.Modify = roles.AdminUserId
  27883. order.RequestLog = src_resquest
  27884. order.Diagnosis = diagnosis_id
  27885. order.FaPiaoNumber = fapiao_number
  27886. order.FaPiaoCode = fapiao_code
  27887. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27888. detailStr := string(setlDetail)
  27889. order.SetlDetail = detailStr
  27890. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27891. err = service.UpDateOrder(order)
  27892. if err == nil {
  27893. //判断是否使用了押金
  27894. if dec_way == "true" {
  27895. tmpstring := strconv.FormatInt(order.ID, 10)
  27896. //扣押金
  27897. order.Decimal = decimal
  27898. service.UpDateOrder(order)
  27899. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27900. if errmsg != nil {
  27901. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27902. return
  27903. }
  27904. }
  27905. c.ServeSuccessJSON(map[string]interface{}{
  27906. "msg": "结算成功",
  27907. })
  27908. } else {
  27909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27910. return
  27911. }
  27912. }
  27913. }
  27914. }
  27915. }
  27916. // 上传明细-预结算-
  27917. func (c *HisApiController) GetPreUploadInfo() {
  27918. id, _ := c.GetInt64("id")
  27919. record_time := c.GetString("record_time")
  27920. his_patient_id, _ := c.GetInt64("his_patient_id")
  27921. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27922. admin_user_id, _ := c.GetInt64("admin_user_id")
  27923. diagnosis_id := c.GetString("diagnosis")
  27924. sick_type, _ := c.GetInt64("sick_type")
  27925. reg_type, _ := c.GetInt64("p_type")
  27926. begin_time := c.GetString("begin_time")
  27927. acct_used_flag := c.GetString("acct_used_flag")
  27928. id_str := c.GetString("ids")
  27929. ids_arr := strings.Split(id_str, ",")
  27930. timeLayout := "2006-01-02"
  27931. loc, _ := time.LoadLocation("Local")
  27932. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27933. if err != nil {
  27934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27935. return
  27936. }
  27937. recordDateTime := theTime.Unix()
  27938. adminUser := c.GetAdminUserInfo()
  27939. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27940. var config []*models.HisXtDiagnoseConfig
  27941. for _, item := range diagnosis_ids {
  27942. id, _ := strconv.ParseInt(item, 10, 64)
  27943. if id > 0 {
  27944. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27945. config = append(config, &diagnosisConfig)
  27946. }
  27947. }
  27948. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27949. sickConfig, _ := service.FindSickById(sick_type)
  27950. var prescriptions []*models.HisPrescription
  27951. var start_time int64
  27952. var end_time int64
  27953. var isSuccess bool = true
  27954. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27955. fmt.Println(his_patient_id)
  27956. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27957. timestamp := time.Now().Unix()
  27958. tempTime := time.Unix(timestamp, 0)
  27959. timeFormat := tempTime.Format("20060102150405")
  27960. chrgBchno := rand.Intn(100000) + 10000
  27961. new_chrg_bchno := ""
  27962. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27963. new_chrg_bchno = chrg_bchno
  27964. if adminUser.CurrentOrgId == 10265 {
  27965. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27966. new_chrg_bchno = "0000"
  27967. }
  27968. }
  27969. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27970. var patientPrescription models.HisPrescriptionInfo
  27971. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27972. if patientPrescription.ID == 0 {
  27973. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27974. }
  27975. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27976. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27977. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27978. strconv.FormatInt(his.PatientId, 10)
  27979. var res2406 Result2406
  27980. //安徽单病种处理
  27981. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27982. data := make(map[string]interface{})
  27983. client := &http.Client{}
  27984. data["psn_no"] = his.PsnNo
  27985. data["mdtrt_id"] = his.Number
  27986. data["operator"] = roles.UserName
  27987. data["cert_no"] = his.IdCardNo
  27988. data["org_name"] = miConfig.OrgName
  27989. data["psn_name"] = his.Name
  27990. data["ipt_otp_no"] = his.IptOtpNo
  27991. data["ipt_psn_sp_flag_type"] = "0901"
  27992. data["ipt_psn_sp_flag"] = "1"
  27993. data["fixmedins_code"] = miConfig.Code
  27994. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27995. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27996. data["url"] = miConfig.Url
  27997. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27998. bytesData, _ := json.Marshal(data)
  27999. var req *http.Request
  28000. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28001. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28002. resp, _ := client.Do(req)
  28003. defer resp.Body.Close()
  28004. body, ioErr := ioutil.ReadAll(resp.Body)
  28005. if ioErr != nil {
  28006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28008. return
  28009. }
  28010. var respJSON map[string]interface{}
  28011. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28014. return
  28015. }
  28016. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28017. if status == "0" {
  28018. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28019. c.ServeSuccessJSON(map[string]interface{}{
  28020. "failed_code": -10,
  28021. "msg": err_msg,
  28022. })
  28023. return
  28024. }
  28025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28026. userJSONBytes, _ := json.Marshal(respJSON)
  28027. fmt.Println("log")
  28028. fmt.Println(string(userJSONBytes))
  28029. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28030. utils.ErrorLog("解析失败:%v", err)
  28031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28032. return
  28033. }
  28034. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28035. data := make(map[string]interface{})
  28036. client := &http.Client{}
  28037. data["psn_no"] = his.PsnNo
  28038. data["mdtrt_id"] = his.Number
  28039. data["operator"] = roles.UserName
  28040. data["cert_no"] = his.IdCardNo
  28041. data["org_name"] = miConfig.OrgName
  28042. data["psn_name"] = his.Name
  28043. data["ipt_otp_no"] = his.IptOtpNo
  28044. data["ipt_psn_sp_flag_type"] = "0901"
  28045. data["ipt_psn_sp_flag"] = "1"
  28046. data["fixmedins_code"] = miConfig.Code
  28047. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28048. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28049. data["url"] = miConfig.Url
  28050. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28051. bytesData, _ := json.Marshal(data)
  28052. var req *http.Request
  28053. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28054. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28055. resp, _ := client.Do(req)
  28056. defer resp.Body.Close()
  28057. body, ioErr := ioutil.ReadAll(resp.Body)
  28058. if ioErr != nil {
  28059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28061. return
  28062. }
  28063. var respJSON map[string]interface{}
  28064. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28067. return
  28068. }
  28069. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28070. if status == "0" {
  28071. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28072. c.ServeSuccessJSON(map[string]interface{}{
  28073. "failed_code": -10,
  28074. "msg": err_msg,
  28075. })
  28076. return
  28077. }
  28078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28079. userJSONBytes, _ := json.Marshal(respJSON)
  28080. fmt.Println("log")
  28081. fmt.Println(string(userJSONBytes))
  28082. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28083. utils.ErrorLog("解析失败:%v", err)
  28084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28085. return
  28086. }
  28087. }
  28088. if res2406.Infcode != 0 {
  28089. adminUser := c.GetAdminUserInfo()
  28090. errlog := &models.HisOrderError{
  28091. UserOrgId: adminUser.CurrentOrgId,
  28092. Ctime: time.Now().Unix(),
  28093. Mtime: time.Now().Unix(),
  28094. ErrMsg: res2406.ErrMsg,
  28095. Status: 1,
  28096. PatientId: id,
  28097. RecordTime: recordDateTime,
  28098. Stage: 3,
  28099. }
  28100. service.CreateErrMsgLog(errlog)
  28101. c.ServeSuccessJSON(map[string]interface{}{
  28102. "failed_code": -10,
  28103. "msg": res2406.ErrMsg,
  28104. })
  28105. return
  28106. }
  28107. var res2 ResultSix
  28108. var res3 GZResultSix
  28109. var resSix10265 ResultSix10265
  28110. //var time_stamp string
  28111. if miConfig.MdtrtareaAdmvs == "421300" {
  28112. data := make(map[string]interface{})
  28113. client := &http.Client{}
  28114. data["psn_no"] = his.PsnNo
  28115. data["mdtrt_id"] = his.Number
  28116. data["department"] = department.Name
  28117. data["org_name"] = miConfig.OrgName
  28118. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28119. data["doctor_id"] = doctor_info.DoctorNumber
  28120. data["doctor_name"] = roles.UserName
  28121. data["fixmedins_code"] = miConfig.Code
  28122. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28123. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28124. data["secret_key"] = miConfig.SecretKey
  28125. data["sick_code"] = sickConfig.CountryCode
  28126. data["sick_name"] = sickConfig.ClassName
  28127. data["begin_time"] = begin_time
  28128. data["dept"] = strconv.FormatInt(department.ID, 10)
  28129. data["config"] = config
  28130. data["opter"] = roles.UserName
  28131. fmt.Println(data)
  28132. bytesData, _ := json.Marshal(data)
  28133. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28134. resp, _ := client.Do(req)
  28135. defer resp.Body.Close()
  28136. body, ioErr := ioutil.ReadAll(resp.Body)
  28137. if ioErr != nil {
  28138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28140. return
  28141. }
  28142. var respJSON map[string]interface{}
  28143. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28146. return
  28147. }
  28148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28149. userJSONBytes, _ := json.Marshal(respJSON)
  28150. fmt.Println("log")
  28151. fmt.Println(string(userJSONBytes))
  28152. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28153. utils.ErrorLog("解析失败:%v", err)
  28154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28155. return
  28156. }
  28157. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28158. data := make(map[string]interface{})
  28159. client := &http.Client{}
  28160. data["psn_no"] = his.PsnNo
  28161. data["mdtrt_id"] = his.Number
  28162. data["department"] = department.Name
  28163. data["org_name"] = miConfig.OrgName
  28164. if reg_type == 11 && his.Insutype == "390" {
  28165. data["med_type"] = "110104"
  28166. } else {
  28167. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28168. }
  28169. data["doctor_id"] = doctor_info.DoctorNumber
  28170. data["doctor_name"] = roles.UserName
  28171. data["fixmedins_code"] = miConfig.Code
  28172. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28173. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28174. data["secret_key"] = miConfig.SecretKey
  28175. data["sick_code"] = sickConfig.CountryCode
  28176. data["sick_name"] = sickConfig.ClassName
  28177. data["begin_time"] = begin_time
  28178. data["dept"] = strconv.FormatInt(department.ID, 10)
  28179. data["config"] = config
  28180. data["opter"] = roles.UserName
  28181. fmt.Println(data)
  28182. bytesData, _ := json.Marshal(data)
  28183. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28184. resp, _ := client.Do(req)
  28185. defer resp.Body.Close()
  28186. body, ioErr := ioutil.ReadAll(resp.Body)
  28187. if ioErr != nil {
  28188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28190. return
  28191. }
  28192. var respJSON map[string]interface{}
  28193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28196. return
  28197. }
  28198. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28199. userJSONBytes, _ := json.Marshal(respJSON)
  28200. fmt.Println("log")
  28201. fmt.Println(string(userJSONBytes))
  28202. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28203. utils.ErrorLog("解析失败:%v", err)
  28204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28205. return
  28206. }
  28207. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28208. data := make(map[string]interface{})
  28209. client := &http.Client{}
  28210. data["psn_no"] = his.PsnNo
  28211. data["mdtrt_id"] = his.Number
  28212. data["department"] = department.Name
  28213. data["org_name"] = miConfig.OrgName
  28214. if reg_type == 11 && his.Insutype == "390" {
  28215. data["med_type"] = "110104"
  28216. } else {
  28217. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28218. }
  28219. data["doctor_id"] = doctor_info.DoctorNumber
  28220. data["doctor_name"] = roles.UserName
  28221. data["fixmedins_code"] = miConfig.Code
  28222. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28223. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28224. data["secret_key"] = miConfig.SecretKey
  28225. data["sick_code"] = sickConfig.CountryCode
  28226. data["sick_name"] = sickConfig.ClassName
  28227. data["begin_time"] = begin_time
  28228. data["dept"] = strconv.FormatInt(department.ID, 10)
  28229. data["config"] = config
  28230. data["opter"] = roles.UserName
  28231. fmt.Println(data)
  28232. bytesData, _ := json.Marshal(data)
  28233. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28234. resp, _ := client.Do(req)
  28235. defer resp.Body.Close()
  28236. body, ioErr := ioutil.ReadAll(resp.Body)
  28237. if ioErr != nil {
  28238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28240. return
  28241. }
  28242. var respJSON map[string]interface{}
  28243. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28246. return
  28247. }
  28248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28249. userJSONBytes, _ := json.Marshal(respJSON)
  28250. fmt.Println("log")
  28251. fmt.Println(string(userJSONBytes))
  28252. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28253. utils.ErrorLog("解析失败:%v", err)
  28254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28255. return
  28256. }
  28257. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28258. data := make(map[string]interface{})
  28259. client := &http.Client{}
  28260. data["psn_no"] = his.PsnNo
  28261. data["mdtrt_id"] = his.Number
  28262. data["department"] = department.Name
  28263. data["org_name"] = miConfig.OrgName
  28264. if reg_type == 11 && his.Insutype == "390" {
  28265. data["med_type"] = "110104"
  28266. } else {
  28267. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28268. }
  28269. data["doctor_id"] = doctor_info.DoctorNumber
  28270. data["doctor_name"] = roles.UserName
  28271. data["fixmedins_code"] = miConfig.Code
  28272. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28273. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28274. data["secret_key"] = miConfig.SecretKey
  28275. data["sick_code"] = sickConfig.CountryCode
  28276. data["sick_name"] = sickConfig.ClassName
  28277. data["begin_time"] = begin_time
  28278. data["dept"] = strconv.FormatInt(department.ID, 10)
  28279. data["config"] = config
  28280. data["opter"] = roles.UserName
  28281. fmt.Println(data)
  28282. bytesData, _ := json.Marshal(data)
  28283. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28284. resp, _ := client.Do(req)
  28285. defer resp.Body.Close()
  28286. body, ioErr := ioutil.ReadAll(resp.Body)
  28287. if ioErr != nil {
  28288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28290. return
  28291. }
  28292. var respJSON map[string]interface{}
  28293. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28296. return
  28297. }
  28298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28299. userJSONBytes, _ := json.Marshal(respJSON)
  28300. fmt.Println("log")
  28301. fmt.Println(string(userJSONBytes))
  28302. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28303. utils.ErrorLog("解析失败:%v", err)
  28304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28305. return
  28306. }
  28307. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28308. data := make(map[string]interface{})
  28309. client := &http.Client{}
  28310. data["psn_no"] = his.PsnNo
  28311. data["mdtrt_id"] = his.Number
  28312. data["doctor"] = roles.UserName
  28313. data["department"] = department.Name
  28314. data["org_name"] = miConfig.OrgName
  28315. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28316. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28317. data["fixmedins_code"] = miConfig.Code
  28318. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28319. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28320. data["secret_key"] = miConfig.SecretKey
  28321. data["sick_code"] = sickConfig.CountryCode
  28322. data["sick_name"] = sickConfig.ClassName
  28323. data["begin_time"] = begin_time
  28324. data["dept"] = strconv.FormatInt(department.ID, 10)
  28325. data["config"] = config
  28326. data["url"] = miConfig.Url
  28327. data["ak"] = miConfig.AccessKey
  28328. data["cainfo"] = miConfig.Cainfo
  28329. bytesData, _ := json.Marshal(data)
  28330. var req *http.Request
  28331. if miConfig.MdtrtareaAdmvs == "320921" {
  28332. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28333. } else {
  28334. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28335. }
  28336. resp, _ := client.Do(req)
  28337. defer resp.Body.Close()
  28338. body, ioErr := ioutil.ReadAll(resp.Body)
  28339. if ioErr != nil {
  28340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28342. return
  28343. }
  28344. var respJSON map[string]interface{}
  28345. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28348. return
  28349. }
  28350. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28351. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28352. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28354. userJSONBytes, _ := json.Marshal(respJSON)
  28355. fmt.Println("log")
  28356. fmt.Println(string(userJSONBytes))
  28357. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28358. utils.ErrorLog("解析失败:%v", err)
  28359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28360. return
  28361. }
  28362. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28363. res2.Output = resSix10265.Output
  28364. res2.ErrMsg = resSix10265.ErrMsg
  28365. res2.Cainfo = resSix10265.Cainfo
  28366. res2.WarnMsg = resSix10265.WarnMsg
  28367. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28368. res2.Infcode = infocode
  28369. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28370. data := make(map[string]interface{})
  28371. client := &http.Client{}
  28372. data["psn_no"] = his.PsnNo
  28373. data["mdtrt_id"] = his.Number
  28374. data["doctor"] = roles.UserName
  28375. data["department"] = department.Name
  28376. data["org_name"] = miConfig.OrgName
  28377. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28378. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28379. data["fixmedins_code"] = miConfig.Code
  28380. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28381. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28382. data["secret_key"] = miConfig.SecretKey
  28383. data["sick_code"] = sickConfig.CountryCode
  28384. data["sick_name"] = sickConfig.ClassName
  28385. data["begin_time"] = begin_time
  28386. data["dept"] = strconv.FormatInt(department.ID, 10)
  28387. data["config"] = config
  28388. //data["url"] = miConfig.Url
  28389. //data["ak"] = miConfig.AccessKey
  28390. data["cainfo"] = miConfig.Cainfo
  28391. fmt.Println(data)
  28392. bytesData, _ := json.Marshal(data)
  28393. var req *http.Request
  28394. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28395. resp, _ := client.Do(req)
  28396. defer resp.Body.Close()
  28397. body, ioErr := ioutil.ReadAll(resp.Body)
  28398. if ioErr != nil {
  28399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28401. return
  28402. }
  28403. var respJSON map[string]interface{}
  28404. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28407. return
  28408. }
  28409. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28410. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28411. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28412. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28413. userJSONBytes, _ := json.Marshal(respJSON)
  28414. fmt.Println("log")
  28415. fmt.Println(string(userJSONBytes))
  28416. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28417. utils.ErrorLog("解析失败:%v", err)
  28418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28419. return
  28420. }
  28421. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28422. res2.Output = resSix10265.Output
  28423. res2.ErrMsg = resSix10265.ErrMsg
  28424. res2.Cainfo = resSix10265.Cainfo
  28425. res2.WarnMsg = resSix10265.WarnMsg
  28426. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28427. res2.Infcode = infocode
  28428. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28429. 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)
  28430. saveLog(result, requestLog, "2203", "上传就诊信息")
  28431. var respJSON2 map[string]interface{}
  28432. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28435. return
  28436. }
  28437. userJSONBytes2, _ := json.Marshal(respJSON2)
  28438. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28439. utils.ErrorLog("解析失败:%v", err)
  28440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28441. return
  28442. }
  28443. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28444. var result string
  28445. var requestLog string
  28446. 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, "")
  28447. saveLog(result, requestLog, "2203", "上传就诊信息")
  28448. var respJSON2 map[string]interface{}
  28449. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28452. return
  28453. }
  28454. userJSONBytes2, _ := json.Marshal(respJSON2)
  28455. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28456. utils.ErrorLog("解析失败:%v", err)
  28457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28458. return
  28459. }
  28460. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28461. var result string
  28462. var requestLog string
  28463. 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, "")
  28464. saveLog(result, requestLog, "2203", "上传就诊信息")
  28465. var respJSON2 map[string]interface{}
  28466. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28469. return
  28470. }
  28471. userJSONBytes2, _ := json.Marshal(respJSON2)
  28472. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28473. utils.ErrorLog("解析失败:%v", err)
  28474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28475. return
  28476. }
  28477. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28478. data := make(map[string]interface{})
  28479. client := &http.Client{}
  28480. data["psn_no"] = his.PsnNo
  28481. data["mdtrt_id"] = his.Number
  28482. data["operator"] = roles.UserName
  28483. data["department"] = department.Name
  28484. data["org_name"] = miConfig.OrgName
  28485. var med_type string
  28486. if his.Insutype == "390" {
  28487. if reg_type == 992102 {
  28488. med_type = "992102"
  28489. data["sick_code"] = "ZDZ940"
  28490. data["sick_name"] = "慢性肾衰竭"
  28491. }
  28492. if reg_type == 140104 {
  28493. med_type = "140104"
  28494. data["sick_code"] = sickConfig.CountryCode
  28495. data["sick_name"] = sickConfig.ClassName
  28496. }
  28497. if reg_type == 14 {
  28498. med_type = "140104"
  28499. data["sick_code"] = sickConfig.CountryCode
  28500. data["sick_name"] = sickConfig.ClassName
  28501. }
  28502. } else if his.Insutype == "310" {
  28503. if reg_type == 992102 {
  28504. med_type = "992102"
  28505. data["sick_code"] = "ZDZ940"
  28506. data["sick_name"] = "慢性肾衰竭"
  28507. }
  28508. if reg_type == 140104 {
  28509. med_type = "140104"
  28510. data["sick_code"] = sickConfig.CountryCode
  28511. data["sick_name"] = sickConfig.ClassName
  28512. }
  28513. if reg_type == 14 {
  28514. med_type = "14"
  28515. data["sick_code"] = sickConfig.CountryCode
  28516. data["sick_name"] = sickConfig.ClassName
  28517. }
  28518. }
  28519. data["med_type"] = med_type
  28520. data["doctor_number"] = doctor_info.DoctorNumber
  28521. data["doctor_name"] = doctor_info.UserName
  28522. data["fixmedins_code"] = miConfig.Code
  28523. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28524. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28525. data["secret_key"] = miConfig.SecretKey
  28526. data["begin_time"] = begin_time
  28527. data["dept"] = strconv.FormatInt(department.ID, 10)
  28528. data["config"] = config
  28529. data["url"] = miConfig.Url
  28530. data["ak"] = miConfig.AccessKey
  28531. data["cainfo"] = miConfig.Cainfo
  28532. bytesData, _ := json.Marshal(data)
  28533. var req *http.Request
  28534. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28535. resp, _ := client.Do(req)
  28536. defer resp.Body.Close()
  28537. body, ioErr := ioutil.ReadAll(resp.Body)
  28538. if ioErr != nil {
  28539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28541. return
  28542. }
  28543. var respJSON map[string]interface{}
  28544. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28547. return
  28548. }
  28549. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28550. if status == "0" {
  28551. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28552. c.ServeSuccessJSON(map[string]interface{}{
  28553. "failed_code": -10,
  28554. "msg": err_msg,
  28555. })
  28556. return
  28557. }
  28558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28559. userJSONBytes, _ := json.Marshal(respJSON)
  28560. fmt.Println("log")
  28561. fmt.Println(string(userJSONBytes))
  28562. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28563. utils.ErrorLog("解析失败:%v", err)
  28564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28565. return
  28566. }
  28567. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28568. data := make(map[string]interface{})
  28569. client := &http.Client{}
  28570. data["psn_no"] = his.PsnNo
  28571. data["mdtrt_id"] = his.Number
  28572. data["operator"] = roles.UserName
  28573. data["department"] = department.Name
  28574. data["org_name"] = miConfig.OrgName
  28575. var med_type string
  28576. if his.Insutype == "390" {
  28577. if reg_type == 992102 {
  28578. med_type = "992102"
  28579. data["sick_code"] = sickConfig.CountryCode
  28580. data["sick_name"] = sickConfig.ClassName
  28581. }
  28582. if reg_type == 140104 {
  28583. med_type = "140104"
  28584. data["sick_code"] = sickConfig.CountryCode
  28585. data["sick_name"] = sickConfig.ClassName
  28586. }
  28587. if reg_type == 140201 {
  28588. med_type = "140201"
  28589. data["sick_code"] = sickConfig.CountryCode
  28590. data["sick_name"] = sickConfig.ClassName
  28591. }
  28592. if reg_type == 14 {
  28593. med_type = "14"
  28594. data["sick_code"] = sickConfig.CountryCode
  28595. data["sick_name"] = sickConfig.ClassName
  28596. }
  28597. } else if his.Insutype == "310" {
  28598. if reg_type == 992102 {
  28599. med_type = "992102"
  28600. data["sick_code"] = sickConfig.CountryCode
  28601. data["sick_name"] = sickConfig.ClassName
  28602. }
  28603. if reg_type == 140104 {
  28604. med_type = "140104"
  28605. data["sick_code"] = sickConfig.CountryCode
  28606. data["sick_name"] = sickConfig.ClassName
  28607. }
  28608. if reg_type == 140201 {
  28609. med_type = "140201"
  28610. data["sick_code"] = sickConfig.CountryCode
  28611. data["sick_name"] = sickConfig.ClassName
  28612. }
  28613. if reg_type == 14 {
  28614. med_type = "14"
  28615. data["sick_code"] = sickConfig.CountryCode
  28616. data["sick_name"] = sickConfig.ClassName
  28617. }
  28618. }
  28619. data["med_type"] = med_type
  28620. data["doctor_number"] = doctor_info.DoctorNumber
  28621. data["doctor_name"] = doctor_info.UserName
  28622. data["fixmedins_code"] = miConfig.Code
  28623. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28625. data["secret_key"] = miConfig.SecretKey
  28626. data["begin_time"] = begin_time
  28627. data["dept"] = strconv.FormatInt(department.ID, 10)
  28628. data["config"] = config
  28629. data["url"] = miConfig.Url
  28630. data["ak"] = miConfig.AccessKey
  28631. data["cainfo"] = miConfig.Cainfo
  28632. bytesData, _ := json.Marshal(data)
  28633. var req *http.Request
  28634. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28635. resp, _ := client.Do(req)
  28636. defer resp.Body.Close()
  28637. body, ioErr := ioutil.ReadAll(resp.Body)
  28638. if ioErr != nil {
  28639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28641. return
  28642. }
  28643. var respJSON map[string]interface{}
  28644. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28647. return
  28648. }
  28649. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28650. if status == "0" {
  28651. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28652. c.ServeSuccessJSON(map[string]interface{}{
  28653. "failed_code": -10,
  28654. "msg": err_msg,
  28655. })
  28656. return
  28657. }
  28658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28659. userJSONBytes, _ := json.Marshal(respJSON)
  28660. fmt.Println("log")
  28661. fmt.Println(string(userJSONBytes))
  28662. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28663. utils.ErrorLog("解析失败:%v", err)
  28664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28665. return
  28666. }
  28667. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28668. var result string
  28669. var requestLog string
  28670. 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, "")
  28671. saveLog(result, requestLog, "2203", "上传就诊信息")
  28672. var respJSON2 map[string]interface{}
  28673. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28676. return
  28677. }
  28678. userJSONBytes2, _ := json.Marshal(respJSON2)
  28679. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28680. utils.ErrorLog("解析失败:%v", err)
  28681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28682. return
  28683. }
  28684. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28685. data := make(map[string]interface{})
  28686. client := &http.Client{}
  28687. data["psn_no"] = his.PsnNo
  28688. data["mdtrt_id"] = his.Number
  28689. data["doctor"] = roles.UserName
  28690. data["department"] = department.Name
  28691. data["org_name"] = miConfig.OrgName
  28692. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28693. data["doctor_id"] = doctor_info.DoctorNumber
  28694. data["fixmedins_code"] = miConfig.Code
  28695. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28696. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28697. data["secret_key"] = miConfig.SecretKey
  28698. data["sick_code"] = sickConfig.CountryCode
  28699. data["sick_name"] = sickConfig.ClassName
  28700. data["begin_time"] = begin_time
  28701. data["new_doctor_name"] = doctor_info.UserName
  28702. data["dept"] = strconv.FormatInt(department.ID, 10)
  28703. data["config"] = config
  28704. bytesData, _ := json.Marshal(data)
  28705. var req *http.Request
  28706. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28707. resp, _ := client.Do(req)
  28708. defer resp.Body.Close()
  28709. body, ioErr := ioutil.ReadAll(resp.Body)
  28710. if ioErr != nil {
  28711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28713. return
  28714. }
  28715. var respJSON map[string]interface{}
  28716. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28719. return
  28720. }
  28721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28722. userJSONBytes, _ := json.Marshal(respJSON)
  28723. fmt.Println("log")
  28724. fmt.Println(string(userJSONBytes))
  28725. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28726. utils.ErrorLog("解析失败:%v", err)
  28727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28728. return
  28729. }
  28730. } else {
  28731. var result string
  28732. var requestLog string
  28733. if miConfig.MdtrtareaAdmvs == "440781" { //
  28734. 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)
  28735. } else {
  28736. if miConfig.Code == "H15049901371" {
  28737. //赤峰地区国家医保医疗类别
  28738. //职工透析:医疗类别选特殊情况门诊990502
  28739. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28740. var med_type string
  28741. if his.Insutype == "390" {
  28742. if reg_type == 14 {
  28743. med_type = "9933"
  28744. } else if reg_type == 11 {
  28745. med_type = "11"
  28746. }
  28747. } else if his.Insutype == "310" {
  28748. if reg_type == 14 {
  28749. med_type = "990502"
  28750. } else if reg_type == 11 {
  28751. med_type = "11"
  28752. }
  28753. }
  28754. 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)
  28755. } else {
  28756. 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)
  28757. }
  28758. saveLog(result, requestLog, "2203", "上传就诊信息")
  28759. var respJSON2 map[string]interface{}
  28760. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28763. return
  28764. }
  28765. userJSONBytes2, _ := json.Marshal(respJSON2)
  28766. if miConfig.Code == "H15049901371" {
  28767. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28768. utils.ErrorLog("解析失败:%v", err)
  28769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28770. return
  28771. }
  28772. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28773. res2.Output = resSix10265.Output
  28774. res2.ErrMsg = resSix10265.ErrMsg
  28775. res2.Cainfo = resSix10265.Cainfo
  28776. res2.WarnMsg = resSix10265.WarnMsg
  28777. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28778. res2.Infcode = infocode
  28779. } else {
  28780. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28781. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28782. utils.ErrorLog("解析失败:%v", err)
  28783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28784. return
  28785. }
  28786. res2.Infcode = res3.Infcode
  28787. } else {
  28788. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28789. utils.ErrorLog("解析失败:%v", err)
  28790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28791. return
  28792. }
  28793. }
  28794. }
  28795. }
  28796. }
  28797. if res2.Infcode == -1 {
  28798. adminUser := c.GetAdminUserInfo()
  28799. errlog := &models.HisOrderError{
  28800. UserOrgId: adminUser.CurrentOrgId,
  28801. Ctime: time.Now().Unix(),
  28802. Mtime: time.Now().Unix(),
  28803. ErrMsg: res2.ErrMsg,
  28804. Status: 1,
  28805. PatientId: id,
  28806. RecordTime: recordDateTime,
  28807. Stage: 3,
  28808. }
  28809. service.CreateErrMsgLog(errlog)
  28810. c.ServeSuccessJSON(map[string]interface{}{
  28811. "failed_code": -10,
  28812. "msg": res2.ErrMsg,
  28813. })
  28814. return
  28815. }
  28816. if res2.Infcode != 0 {
  28817. adminUser := c.GetAdminUserInfo()
  28818. errlog := &models.HisOrderError{
  28819. UserOrgId: adminUser.CurrentOrgId,
  28820. Ctime: time.Now().Unix(),
  28821. Mtime: time.Now().Unix(),
  28822. ErrMsg: res2.ErrMsg,
  28823. Status: 1,
  28824. PatientId: id,
  28825. RecordTime: recordDateTime,
  28826. Stage: 3,
  28827. }
  28828. service.CreateErrMsgLog(errlog)
  28829. c.ServeSuccessJSON(map[string]interface{}{
  28830. "failed_code": -10,
  28831. "msg": res2.ErrMsg,
  28832. })
  28833. return
  28834. } else {
  28835. his.Diagnosis = diagnosis_id
  28836. his.SickType = sickConfig.ID
  28837. his.PType = fmt.Sprintf("%d", reg_type)
  28838. service.UpdateHisPatientThree(&his)
  28839. data := make(map[string]interface{})
  28840. if settle_accounts_type == 1 { //日结
  28841. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28842. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28843. } else {
  28844. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28845. }
  28846. data["pre"] = prescriptions
  28847. } else { //月结
  28848. start_time_str := c.GetString("start_time")
  28849. end_time_str := c.GetString("end_time")
  28850. timeLayout := "2006-01-02"
  28851. loc, _ := time.LoadLocation("Local")
  28852. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28853. if err != nil {
  28854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28855. return
  28856. }
  28857. recordStartTime := theStartTime.Unix()
  28858. start_time = recordStartTime
  28859. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28860. if err != nil {
  28861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28862. return
  28863. }
  28864. recordEndTime := theEndTime.Unix()
  28865. end_time = recordEndTime
  28866. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28867. data["pre"] = prescriptions
  28868. }
  28869. client := &http.Client{}
  28870. data["psn_no"] = his.PsnNo
  28871. data["mdtrt_id"] = his.Number
  28872. data["chrg_bchno"] = new_chrg_bchno
  28873. data["org_name"] = miConfig.OrgName
  28874. data["doctor"] = doctor_info.UserName
  28875. data["doctor_id"] = doctor_info.DoctorNumber
  28876. data["dept"] = department.Name
  28877. data["fixmedins_code"] = miConfig.Code
  28878. data["opter"] = roles.UserName
  28879. data["dept_code"] = department.Number
  28880. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28881. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28882. data["secret_key"] = miConfig.SecretKey
  28883. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28884. data["url"] = miConfig.Url
  28885. data["ak"] = miConfig.AccessKey
  28886. data["new_doctor_name"] = patientPrescription.Doctor
  28887. if his.Insutype == "390" {
  28888. if reg_type == 992102 {
  28889. data["diag_code"] = "ZDZ940"
  28890. }
  28891. if reg_type == 140104 {
  28892. data["diag_code"] = sickConfig.CountryCode
  28893. }
  28894. if reg_type == 140201 {
  28895. data["diag_code"] = sickConfig.CountryCode
  28896. }
  28897. if reg_type == 14 {
  28898. data["diag_code"] = sickConfig.CountryCode
  28899. }
  28900. } else if his.Insutype == "310" {
  28901. if miConfig.MdtrtareaAdmvs == "341203" {
  28902. if reg_type == 992102 {
  28903. data["diag_code"] = "ZDZ940"
  28904. }
  28905. if reg_type != 992102 {
  28906. data["diag_code"] = sickConfig.CountryCode
  28907. }
  28908. } else {
  28909. data["diag_code"] = sickConfig.CountryCode
  28910. }
  28911. }
  28912. data["cainfo"] = miConfig.Cainfo
  28913. data["opter"] = roles.UserName
  28914. var ids []int64
  28915. for _, item := range prescriptions {
  28916. ids = append(ids, item.ID)
  28917. }
  28918. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28919. if config.IsOpen == 1 { //对接了医保,走医保流程
  28920. var res ResultFour
  28921. var resFour10265 ResultFour10265
  28922. if miConfig.MdtrtareaAdmvs == "421300" {
  28923. bytesData, _ := json.Marshal(data)
  28924. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28925. resp, _ := client.Do(req)
  28926. defer resp.Body.Close()
  28927. body, ioErr := ioutil.ReadAll(resp.Body)
  28928. if ioErr != nil {
  28929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28931. return
  28932. }
  28933. var respJSON map[string]interface{}
  28934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28937. return
  28938. }
  28939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28940. userJSONBytes, _ := json.Marshal(respJSON)
  28941. fmt.Println("log")
  28942. fmt.Println(string(userJSONBytes))
  28943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28944. utils.ErrorLog("解析失败:%v", err)
  28945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28946. return
  28947. }
  28948. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28949. bytesData, _ := json.Marshal(data)
  28950. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28951. resp, _ := client.Do(req)
  28952. defer resp.Body.Close()
  28953. body, ioErr := ioutil.ReadAll(resp.Body)
  28954. if ioErr != nil {
  28955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28957. return
  28958. }
  28959. var respJSON map[string]interface{}
  28960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28963. return
  28964. }
  28965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28966. userJSONBytes, _ := json.Marshal(respJSON)
  28967. fmt.Println("log")
  28968. fmt.Println(string(userJSONBytes))
  28969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28970. utils.ErrorLog("解析失败:%v", err)
  28971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28972. return
  28973. }
  28974. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28975. bytesData, _ := json.Marshal(data)
  28976. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28977. resp, _ := client.Do(req)
  28978. defer resp.Body.Close()
  28979. body, ioErr := ioutil.ReadAll(resp.Body)
  28980. if ioErr != nil {
  28981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28983. return
  28984. }
  28985. var respJSON map[string]interface{}
  28986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28989. return
  28990. }
  28991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28992. userJSONBytes, _ := json.Marshal(respJSON)
  28993. fmt.Println("log")
  28994. fmt.Println(string(userJSONBytes))
  28995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28996. utils.ErrorLog("解析失败:%v", err)
  28997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28998. return
  28999. }
  29000. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29001. bytesData, _ := json.Marshal(data)
  29002. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29003. resp, _ := client.Do(req)
  29004. defer resp.Body.Close()
  29005. body, ioErr := ioutil.ReadAll(resp.Body)
  29006. if ioErr != nil {
  29007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29009. return
  29010. }
  29011. var respJSON map[string]interface{}
  29012. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29015. return
  29016. }
  29017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29018. userJSONBytes, _ := json.Marshal(respJSON)
  29019. fmt.Println("log")
  29020. fmt.Println(string(userJSONBytes))
  29021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29022. utils.ErrorLog("解析失败:%v", err)
  29023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29024. return
  29025. }
  29026. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29027. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29028. if result3101.Infcode == "0" {
  29029. if len(result3101.Output.Result) > 0 {
  29030. var errMsgs []string
  29031. for _, item := range result3101.Output.Result {
  29032. errMsgs = append(errMsgs, item.VolaCont)
  29033. }
  29034. c.ServeSuccessJSON(map[string]interface{}{
  29035. "failed_code": -10,
  29036. "msg": errMsgs,
  29037. })
  29038. return
  29039. } else {
  29040. if miConfig.MdtrtareaAdmvs == "320921" {
  29041. data["doctor_id"] = "D320923012139"
  29042. } else {
  29043. data["doctor_id"] = "D371621008686"
  29044. }
  29045. bytesData, _ := json.Marshal(data)
  29046. var req *http.Request
  29047. if miConfig.MdtrtareaAdmvs == "320921" {
  29048. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29049. } else {
  29050. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29051. }
  29052. resp, _ := client.Do(req)
  29053. defer resp.Body.Close()
  29054. body, ioErr := ioutil.ReadAll(resp.Body)
  29055. if ioErr != nil {
  29056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29058. return
  29059. }
  29060. var respJSON map[string]interface{}
  29061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29064. return
  29065. }
  29066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29067. userJSONBytes, _ := json.Marshal(respJSON)
  29068. fmt.Println("log")
  29069. fmt.Println(string(userJSONBytes))
  29070. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29071. utils.ErrorLog("解析失败:%v", err)
  29072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29073. return
  29074. }
  29075. res.InfRefmsgid = resFour10265.InfRefmsgid
  29076. res.Output = resFour10265.Output
  29077. res.ErrMsg = resFour10265.ErrMsg
  29078. res.Cainfo = resFour10265.Cainfo
  29079. res.WarnMsg = resFour10265.WarnMsg
  29080. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29081. res.Infcode = infocode
  29082. }
  29083. }
  29084. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29085. var pagesize int = 5
  29086. var start int = 1
  29087. var stop int
  29088. var pagecount int
  29089. var curpage int
  29090. data["doctor_id"] = doctor_info.DoctorNumber
  29091. var res2 ResultFour
  29092. //var result res.
  29093. //总页数,向上取整,注意除之前要先转换类型为float64
  29094. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29095. for curpage = 1; curpage <= pagecount; curpage++ {
  29096. if curpage == 1 {
  29097. start = 1
  29098. } else {
  29099. start = (curpage-1)*pagesize + 1
  29100. }
  29101. stop = curpage * pagesize
  29102. if stop > len(prescriptions) {
  29103. stop = len(prescriptions)
  29104. }
  29105. //var requestLog string
  29106. data["pre"] = prescriptions[start-1 : stop]
  29107. fmt.Println(data["pre"])
  29108. bytesData, _ := json.Marshal(data)
  29109. var req *http.Request
  29110. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29111. resp, _ := client.Do(req)
  29112. defer resp.Body.Close()
  29113. body, ioErr := ioutil.ReadAll(resp.Body)
  29114. if ioErr != nil {
  29115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29117. return
  29118. }
  29119. var respJSON map[string]interface{}
  29120. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29123. return
  29124. }
  29125. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29126. userJSONBytes, _ := json.Marshal(respJSON)
  29127. fmt.Println("log")
  29128. fmt.Println(string(userJSONBytes))
  29129. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29130. utils.ErrorLog("解析失败:%v", err)
  29131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29132. return
  29133. }
  29134. res.InfRefmsgid = resFour10265.InfRefmsgid
  29135. res.Output = resFour10265.Output
  29136. res.ErrMsg = resFour10265.ErrMsg
  29137. res.Cainfo = resFour10265.Cainfo
  29138. res.WarnMsg = resFour10265.WarnMsg
  29139. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29140. res.Infcode = infocode
  29141. if infocode == 0 {
  29142. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29143. } else {
  29144. isSuccess = false
  29145. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29146. res.Infcode = -1
  29147. res.ErrMsg = resFour10265.ErrMsg
  29148. errlog := &models.HisOrderError{
  29149. UserOrgId: adminUser.CurrentOrgId,
  29150. Ctime: time.Now().Unix(),
  29151. Mtime: time.Now().Unix(),
  29152. Number: chrg_bchno,
  29153. ErrMsg: "",
  29154. Status: 1,
  29155. PatientId: id,
  29156. RecordTime: recordDateTime,
  29157. Stage: 4,
  29158. }
  29159. service.CreateErrMsgLog(errlog)
  29160. }
  29161. }
  29162. if isSuccess {
  29163. res.Infcode = 0
  29164. res.Output.Result = res2.Output.Result
  29165. } else {
  29166. order := &models.HisOrder{
  29167. UserOrgId: adminUser.CurrentOrgId,
  29168. HisPatientId: his.ID,
  29169. PatientId: his.PatientId,
  29170. SettleAccountsDate: recordDateTime,
  29171. Ctime: time.Now().Unix(),
  29172. Mtime: time.Now().Unix(),
  29173. MdtrtId: his.Number,
  29174. PsnNo: his.PsnNo,
  29175. MedType: strconv.FormatInt(reg_type, 10),
  29176. Status: 1,
  29177. Number: chrg_bchno,
  29178. Infcode: res.Infcode,
  29179. WarnMsg: res.WarnMsg,
  29180. Cainfo: res.Cainfo,
  29181. ErrMsg: res.ErrMsg,
  29182. RespondTime: res.RefmsgTime,
  29183. InfRefmsgid: res.InfRefmsgid,
  29184. OrderStatus: 1,
  29185. IsMedicineInsurance: 1,
  29186. SettleType: settle_accounts_type,
  29187. SettleStartTime: start_time,
  29188. SettleEndTime: end_time,
  29189. Creator: roles.AdminUserId,
  29190. Modify: roles.AdminUserId,
  29191. PType: 2,
  29192. Diagnosis: diagnosis_id,
  29193. }
  29194. err = service.CreateOrder(order)
  29195. if err != nil {
  29196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29197. return
  29198. }
  29199. c.ServeSuccessJSON(map[string]interface{}{
  29200. "failed_code": -10,
  29201. "msg": res2.ErrMsg,
  29202. })
  29203. return
  29204. }
  29205. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29206. 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)
  29207. var dat map[string]interface{}
  29208. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29209. fmt.Println(dat)
  29210. } else {
  29211. fmt.Println(err)
  29212. }
  29213. saveLog(result, request_log, "2204", "上传费用明细")
  29214. userJSONBytes, _ := json.Marshal(dat)
  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 == "360302" {
  29221. 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, "", "")
  29222. var dat map[string]interface{}
  29223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29224. fmt.Println(dat)
  29225. } else {
  29226. fmt.Println(err)
  29227. }
  29228. saveLog(result, request_log, "2204", "上传费用明细")
  29229. userJSONBytes, _ := json.Marshal(dat)
  29230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29231. utils.ErrorLog("解析失败:%v", err)
  29232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29233. return
  29234. }
  29235. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29236. 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, "", "")
  29237. var dat map[string]interface{}
  29238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29239. fmt.Println(dat)
  29240. } else {
  29241. fmt.Println(err)
  29242. }
  29243. saveLog(result, request_log, "2204", "上传费用明细")
  29244. userJSONBytes, _ := json.Marshal(dat)
  29245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29246. utils.ErrorLog("解析失败:%v", err)
  29247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29248. return
  29249. }
  29250. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29251. bytesData, _ := json.Marshal(data)
  29252. var req *http.Request
  29253. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29254. resp, _ := client.Do(req)
  29255. defer resp.Body.Close()
  29256. body, ioErr := ioutil.ReadAll(resp.Body)
  29257. if ioErr != nil {
  29258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29260. return
  29261. }
  29262. var respJSON map[string]interface{}
  29263. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29266. return
  29267. }
  29268. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29269. if status == "0" {
  29270. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29271. c.ServeSuccessJSON(map[string]interface{}{
  29272. "failed_code": -10,
  29273. "msg": err_msg,
  29274. })
  29275. return
  29276. }
  29277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29278. userJSONBytes, _ := json.Marshal(respJSON)
  29279. fmt.Println("log")
  29280. fmt.Println(string(userJSONBytes))
  29281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29282. utils.ErrorLog("解析失败:%v", err)
  29283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29284. return
  29285. }
  29286. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29287. bytesData, _ := json.Marshal(data)
  29288. var req *http.Request
  29289. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29290. resp, _ := client.Do(req)
  29291. defer resp.Body.Close()
  29292. body, ioErr := ioutil.ReadAll(resp.Body)
  29293. if ioErr != nil {
  29294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29296. return
  29297. }
  29298. var respJSON map[string]interface{}
  29299. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29302. return
  29303. }
  29304. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29305. if status == "0" {
  29306. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29307. c.ServeSuccessJSON(map[string]interface{}{
  29308. "failed_code": -10,
  29309. "msg": err_msg,
  29310. })
  29311. return
  29312. }
  29313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29314. userJSONBytes, _ := json.Marshal(respJSON)
  29315. fmt.Println("log")
  29316. fmt.Println(string(userJSONBytes))
  29317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29318. utils.ErrorLog("解析失败:%v", err)
  29319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29320. return
  29321. }
  29322. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29323. 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, "", "")
  29324. var dat map[string]interface{}
  29325. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29326. fmt.Println(dat)
  29327. } else {
  29328. fmt.Println(err)
  29329. }
  29330. saveLog(result, request_log, "2204", "上传费用明细")
  29331. userJSONBytes, _ := json.Marshal(dat)
  29332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29333. utils.ErrorLog("解析失败:%v", err)
  29334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29335. return
  29336. }
  29337. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29338. bytesData, _ := json.Marshal(data)
  29339. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29340. resp, _ := client.Do(req)
  29341. defer resp.Body.Close()
  29342. body, ioErr := ioutil.ReadAll(resp.Body)
  29343. if ioErr != nil {
  29344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29346. return
  29347. }
  29348. var respJSON map[string]interface{}
  29349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29352. return
  29353. }
  29354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29355. userJSONBytes, _ := json.Marshal(respJSON)
  29356. fmt.Println("log")
  29357. fmt.Println(string(userJSONBytes))
  29358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29359. utils.ErrorLog("解析失败:%v", err)
  29360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29361. return
  29362. }
  29363. } else {
  29364. if miConfig.MdtrtareaAdmvs == "441202" {
  29365. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29366. if result3101.Infcode == 0 {
  29367. if len(result3101.Output.Result) > 0 {
  29368. var errMsgs []string
  29369. for _, item := range result3101.Output.Result {
  29370. errMsgs = append(errMsgs, item.VolaCont)
  29371. }
  29372. c.ServeSuccessJSON(map[string]interface{}{
  29373. "failed_code": -10,
  29374. "msg": errMsgs,
  29375. })
  29376. return
  29377. } else {
  29378. 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)
  29379. var dat map[string]interface{}
  29380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29381. fmt.Println(dat)
  29382. } else {
  29383. fmt.Println(err)
  29384. }
  29385. saveLog(result, request_log, "2204", "上传费用明细")
  29386. userJSONBytes, _ := json.Marshal(dat)
  29387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29388. utils.ErrorLog("解析失败:%v", err)
  29389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29390. return
  29391. }
  29392. }
  29393. } else {
  29394. c.ServeSuccessJSON(map[string]interface{}{
  29395. "failed_code": -10,
  29396. "msg": result3101.ErrMsg,
  29397. })
  29398. return
  29399. }
  29400. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29401. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29402. if result3101.Infcode == 0 {
  29403. if len(result3101.Output.Result) > 0 {
  29404. var errMsgs []string
  29405. for _, item := range result3101.Output.Result {
  29406. errMsgs = append(errMsgs, item.VolaCont)
  29407. }
  29408. c.ServeSuccessJSON(map[string]interface{}{
  29409. "failed_code": -10,
  29410. "msg": errMsgs,
  29411. })
  29412. return
  29413. } else {
  29414. 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)
  29415. var dat map[string]interface{}
  29416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29417. fmt.Println(dat)
  29418. } else {
  29419. fmt.Println(err)
  29420. }
  29421. saveLog(result, request_log, "2204", "上传费用明细")
  29422. userJSONBytes, _ := json.Marshal(dat)
  29423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29424. utils.ErrorLog("解析失败:%v", err)
  29425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29426. return
  29427. }
  29428. }
  29429. } else {
  29430. c.ServeSuccessJSON(map[string]interface{}{
  29431. "failed_code": -10,
  29432. "msg": result3101.ErrMsg,
  29433. })
  29434. return
  29435. }
  29436. } else {
  29437. if miConfig.Code == "H15049901371" {
  29438. 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)
  29439. var dat map[string]interface{}
  29440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29441. fmt.Println(dat)
  29442. } else {
  29443. fmt.Println(err)
  29444. }
  29445. saveLog(result, request_log, "2204", "上传费用明细")
  29446. userJSONBytes, _ := json.Marshal(dat)
  29447. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29448. utils.ErrorLog("解析失败:%v", err)
  29449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29450. return
  29451. }
  29452. res.InfRefmsgid = resFour10265.InfRefmsgid
  29453. res.Output = resFour10265.Output
  29454. res.ErrMsg = resFour10265.ErrMsg
  29455. res.Cainfo = resFour10265.Cainfo
  29456. res.WarnMsg = resFour10265.WarnMsg
  29457. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29458. res.Infcode = infocode
  29459. } else {
  29460. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29461. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29462. if result3101.Infcode == 0 {
  29463. if len(result3101.Output.Result) > 0 {
  29464. c.ServeSuccessJSON(map[string]interface{}{
  29465. "failed_code": -10,
  29466. "failed_type": 100,
  29467. "msg": result3101.Output.Result,
  29468. })
  29469. return
  29470. } else {
  29471. 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)
  29472. var dat map[string]interface{}
  29473. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29474. fmt.Println(dat)
  29475. } else {
  29476. fmt.Println(err)
  29477. }
  29478. saveLog(result, request_log, "2204", "上传费用明细")
  29479. userJSONBytes, _ := json.Marshal(dat)
  29480. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29481. utils.ErrorLog("解析失败:%v", err)
  29482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29483. return
  29484. }
  29485. }
  29486. } else {
  29487. c.ServeSuccessJSON(map[string]interface{}{
  29488. "failed_code": -10,
  29489. "msg": result3101.ErrMsg,
  29490. })
  29491. return
  29492. }
  29493. } else {
  29494. 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)
  29495. var dat map[string]interface{}
  29496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29497. fmt.Println(dat)
  29498. } else {
  29499. fmt.Println(err)
  29500. }
  29501. saveLog(result, request_log, "2204", "上传费用明细")
  29502. userJSONBytes, _ := json.Marshal(dat)
  29503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29504. utils.ErrorLog("解析失败:%v", err)
  29505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29506. return
  29507. }
  29508. }
  29509. }
  29510. }
  29511. }
  29512. var total_two float64
  29513. if res.Infcode == -1 {
  29514. errlog := &models.HisOrderError{
  29515. UserOrgId: adminUser.CurrentOrgId,
  29516. Ctime: time.Now().Unix(),
  29517. Mtime: time.Now().Unix(),
  29518. Number: chrg_bchno,
  29519. ErrMsg: res.ErrMsg,
  29520. Status: 1,
  29521. PatientId: id,
  29522. RecordTime: recordDateTime,
  29523. Stage: 4,
  29524. }
  29525. service.CreateErrMsgLog(errlog)
  29526. c.ServeSuccessJSON(map[string]interface{}{
  29527. "failed_code": -10,
  29528. "msg": res.ErrMsg,
  29529. })
  29530. return
  29531. }
  29532. if res.Infcode == 0 {
  29533. order := &models.HisOrder{
  29534. UserOrgId: adminUser.CurrentOrgId,
  29535. HisPatientId: his.ID,
  29536. PatientId: his.PatientId,
  29537. SettleAccountsDate: recordDateTime,
  29538. Ctime: time.Now().Unix(),
  29539. Mtime: time.Now().Unix(),
  29540. MdtrtId: his.Number,
  29541. PsnNo: his.PsnNo,
  29542. MedType: strconv.FormatInt(reg_type, 10),
  29543. Status: 1,
  29544. Number: chrg_bchno,
  29545. Infcode: res.Infcode,
  29546. WarnMsg: res.WarnMsg,
  29547. Cainfo: res.Cainfo,
  29548. ErrMsg: res.ErrMsg,
  29549. RespondTime: res.RefmsgTime,
  29550. InfRefmsgid: res.InfRefmsgid,
  29551. OrderStatus: 1,
  29552. IsMedicineInsurance: 1,
  29553. SettleType: settle_accounts_type,
  29554. SettleStartTime: start_time,
  29555. SettleEndTime: end_time,
  29556. Creator: roles.AdminUserId,
  29557. Modify: roles.AdminUserId,
  29558. PType: 2,
  29559. Diagnosis: diagnosis_id,
  29560. }
  29561. err = service.CreateOrder(order)
  29562. if err != nil {
  29563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29564. return
  29565. }
  29566. for _, item := range res.Output.Result {
  29567. temp := strings.Split(item.FeedetlSn, "-")
  29568. var advice_id int64 = 0
  29569. var project_id int64 = 0
  29570. var types int64 = 0
  29571. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29572. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29573. if temp[1] == "1" {
  29574. advice_id = id
  29575. project_id = 0
  29576. } else if temp[1] == "2" {
  29577. advice_id = 0
  29578. project_id = id
  29579. }
  29580. total_two = total_two + item.DetItemFeeSumamt
  29581. info := &models.HisOrderInfo{
  29582. OrderNumber: order.Number,
  29583. FeedetlSn: item.FeedetlSn,
  29584. UploadDate: time.Now().Unix(),
  29585. AdviceId: advice_id,
  29586. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29587. Cnt: item.Cnt,
  29588. Pric: float64(item.Pric),
  29589. PatientId: his.PatientId,
  29590. PricUplmtAmt: item.PricUplmtAmt,
  29591. SelfpayProp: item.SelfpayProp,
  29592. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29593. OverlmtAmt: item.OverlmtAmt,
  29594. PreselfpayAmt: item.PreselfpayAmt,
  29595. BasMednFlag: item.BasMednFlag,
  29596. MedChrgitmType: item.MedChrgitmType,
  29597. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29598. Status: 1,
  29599. Memo: item.Memo,
  29600. Mtime: time.Now().Unix(),
  29601. InscpScpAmt: item.InscpScpAmt,
  29602. DrtReimFlag: item.DrtReimFlag,
  29603. Ctime: time.Now().Unix(),
  29604. ListSpItemFlag: item.ListSpItemFlag,
  29605. ChldMedcFlag: item.ChldMedcFlag,
  29606. LmtUsedFlag: item.LmtUsedFlag,
  29607. ChrgitmLv: item.ChrgitmLv,
  29608. UserOrgId: adminUser.CurrentOrgId,
  29609. HisPatientId: his.ID,
  29610. OrderId: order.ID,
  29611. ProjectId: project_id,
  29612. Type: types,
  29613. }
  29614. service.CreateOrderInfo(info)
  29615. }
  29616. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29617. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29618. var total float64
  29619. for _, item := range prescriptions {
  29620. if item.Type == 1 { //药品
  29621. for _, subItem := range item.HisDoctorAdviceInfo {
  29622. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29623. total_one := price * subItem.PrescribingNumber
  29624. fmt.Println("subItem")
  29625. fmt.Println(subItem.Price)
  29626. fmt.Println("price")
  29627. fmt.Println(price)
  29628. fmt.Println("total_one")
  29629. fmt.Println(total_one)
  29630. total = total + total_one
  29631. fmt.Println(total)
  29632. }
  29633. }
  29634. if item.Type == 2 { //项目
  29635. for _, subItem := range item.HisPrescriptionProject {
  29636. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29637. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29638. total_one := price * cnt
  29639. total = total + total_one
  29640. }
  29641. }
  29642. }
  29643. allTotal := fmt.Sprintf("%.2f", total)
  29644. if res.Infcode == 0 {
  29645. var rf []*ResultFive
  29646. json.Unmarshal([]byte(his.Iinfo), &rf)
  29647. chrg_bchno := chrg_bchno
  29648. cert_no := his.Certno
  29649. var insutypes []string
  29650. var insutype string
  29651. var is390 int = 0
  29652. var is310 int = 0
  29653. for _, item := range rf {
  29654. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29655. insutypes = append(insutypes, item.Insutype)
  29656. }
  29657. }
  29658. if len(insutypes) == 1 {
  29659. insutype = insutypes[0]
  29660. } else {
  29661. for _, i := range insutypes {
  29662. if i == "390" {
  29663. is390 = 1
  29664. }
  29665. if i == "310" {
  29666. is310 = 1
  29667. }
  29668. }
  29669. }
  29670. if is390 == 1 {
  29671. insutype = "390"
  29672. }
  29673. if is310 == 1 {
  29674. insutype = "310"
  29675. }
  29676. if len(insutypes) == 0 {
  29677. insutype = "390"
  29678. }
  29679. if len(insutypes) == 2 {
  29680. insutype = strconv.FormatInt(his.SocialType, 10)
  29681. }
  29682. //insutype = "390"
  29683. if his.IdCardType == 1 {
  29684. cert_no = his.MedicalInsuranceNumber
  29685. } else {
  29686. cert_no = his.Certno
  29687. }
  29688. var res ResultSeven
  29689. var ahres ResultSevenAH
  29690. var resSeven10265 ResultSeven10265
  29691. var resSeven10265Two ResultSeven10265Two
  29692. var gzresSeven10265Two GZResultSeven10265Two
  29693. if miConfig.MdtrtareaAdmvs == "421300" {
  29694. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29695. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29696. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29697. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29698. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29699. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29700. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29701. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29702. resp, requestErr := http.Get(api)
  29703. if requestErr != nil {
  29704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29705. return
  29706. }
  29707. body, ioErr := ioutil.ReadAll(resp.Body)
  29708. if ioErr != nil {
  29709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29711. return
  29712. }
  29713. var respJSON map[string]interface{}
  29714. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29717. return
  29718. }
  29719. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29720. result, _ := json.Marshal(respJSON)
  29721. fmt.Println("log")
  29722. fmt.Println(string(result))
  29723. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29724. utils.ErrorLog("解析失败:%v", err)
  29725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29726. return
  29727. }
  29728. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29729. if reg_type == 11 && his.Insutype == "390" {
  29730. reg_type = 110104
  29731. }
  29732. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29733. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29734. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29735. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29736. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29737. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29738. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29739. resp, requestErr := http.Get(api)
  29740. if requestErr != nil {
  29741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29742. return
  29743. }
  29744. body, ioErr := ioutil.ReadAll(resp.Body)
  29745. if ioErr != nil {
  29746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29748. return
  29749. }
  29750. var respJSON map[string]interface{}
  29751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29754. return
  29755. }
  29756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29757. result, _ := json.Marshal(respJSON)
  29758. fmt.Println("log")
  29759. fmt.Println(string(result))
  29760. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29761. utils.ErrorLog("解析失败:%v", err)
  29762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29763. return
  29764. }
  29765. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29766. if reg_type == 11 && his.Insutype == "390" {
  29767. reg_type = 110104
  29768. }
  29769. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29770. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29771. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29772. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29773. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29774. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29775. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29776. resp, requestErr := http.Get(api)
  29777. if requestErr != nil {
  29778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29779. return
  29780. }
  29781. body, ioErr := ioutil.ReadAll(resp.Body)
  29782. if ioErr != nil {
  29783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29785. return
  29786. }
  29787. var respJSON map[string]interface{}
  29788. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29791. return
  29792. }
  29793. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29794. result, _ := json.Marshal(respJSON)
  29795. fmt.Println("log")
  29796. fmt.Println(string(result))
  29797. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29798. utils.ErrorLog("解析失败:%v", err)
  29799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29800. return
  29801. }
  29802. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29803. if reg_type == 11 && his.Insutype == "390" {
  29804. reg_type = 110104
  29805. }
  29806. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29807. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29808. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29809. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29810. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29811. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29812. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29813. resp, requestErr := http.Get(api)
  29814. if requestErr != nil {
  29815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29816. return
  29817. }
  29818. body, ioErr := ioutil.ReadAll(resp.Body)
  29819. if ioErr != nil {
  29820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29822. return
  29823. }
  29824. var respJSON map[string]interface{}
  29825. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29828. return
  29829. }
  29830. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29831. result, _ := json.Marshal(respJSON)
  29832. fmt.Println("log")
  29833. fmt.Println(string(result))
  29834. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29835. utils.ErrorLog("解析失败:%v", err)
  29836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29837. return
  29838. }
  29839. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29840. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29841. if result3101.Infcode == "0" {
  29842. if len(result3101.Output.Result) > 0 {
  29843. var errMsgs []string
  29844. for _, item := range result3101.Output.Result {
  29845. errMsgs = append(errMsgs, item.VolaCont)
  29846. }
  29847. c.ServeSuccessJSON(map[string]interface{}{
  29848. "failed_code": -10,
  29849. "msg": errMsgs,
  29850. })
  29851. return
  29852. } else {
  29853. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29854. if his.IdCardType != 4 {
  29855. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29856. bas := strings.Split(psn_info.CardInfo, "|")
  29857. if his.IdCardType == 1 {
  29858. cert_no = bas[2]
  29859. } else {
  29860. cert_no = bas[1]
  29861. }
  29862. } else {
  29863. cert_no = his.Certno
  29864. }
  29865. //江苏地区国家医保医疗类别
  29866. //职工透析:医疗类别选特殊情况门诊9933
  29867. //居民血透门慢: 医疗类别选门诊慢病1402
  29868. //var med_type string
  29869. //if his.Insutype == "310" {
  29870. // if reg_type == 14 {
  29871. // med_type = "9933"
  29872. // } else if reg_type == 11 {
  29873. // med_type = "11"
  29874. //
  29875. // }
  29876. //} else if his.Insutype == "390" {
  29877. // if reg_type == 14 {
  29878. // med_type = "1402"
  29879. // } else if reg_type == 11 {
  29880. // med_type = "11"
  29881. // }
  29882. //}
  29883. var api string
  29884. if miConfig.MdtrtareaAdmvs == "320921" {
  29885. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29886. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29887. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29889. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29890. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29891. "&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
  29892. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29893. } else {
  29894. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29895. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29896. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29897. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29898. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29899. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29900. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29901. "&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
  29902. }
  29903. resp, requestErr := http.Get(api)
  29904. if requestErr != nil {
  29905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29906. return
  29907. }
  29908. body, ioErr := ioutil.ReadAll(resp.Body)
  29909. if ioErr != nil {
  29910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29912. return
  29913. }
  29914. var respJSON map[string]interface{}
  29915. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29918. return
  29919. }
  29920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29921. result, _ := json.Marshal(respJSON)
  29922. fmt.Println("log")
  29923. fmt.Println(string(result))
  29924. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29925. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29926. utils.ErrorLog("解析失败:%v", err)
  29927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29928. return
  29929. }
  29930. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29931. res.Output = resSeven10265.Output
  29932. res.ErrMsg = resSeven10265.ErrMsg
  29933. res.Cainfo = resSeven10265.Cainfo
  29934. res.WarnMsg = resSeven10265.WarnMsg
  29935. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29936. res.Infcode = infocode
  29937. } else {
  29938. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29939. utils.ErrorLog("解析失败:%v", err)
  29940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29941. return
  29942. }
  29943. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29944. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29945. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29946. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29947. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29948. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29949. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29950. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29951. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29952. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29953. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29954. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29955. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29956. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29957. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29958. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29959. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29960. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29961. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29962. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29963. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29964. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29965. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29966. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29967. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29968. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29969. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29970. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29971. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29972. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29973. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29974. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29975. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29976. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29977. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29978. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29979. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29980. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29981. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29982. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29983. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29984. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29985. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29986. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29987. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29988. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29989. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29990. res.ErrMsg = resSeven10265Two.ErrMsg
  29991. res.Cainfo = resSeven10265Two.Cainfo
  29992. res.WarnMsg = resSeven10265Two.WarnMsg
  29993. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29994. res.Infcode = infocode
  29995. }
  29996. }
  29997. }
  29998. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29999. psn_info, _ := service.GetPsnByPatientId(id)
  30000. var verify_number string
  30001. if psn_info.IdCardType == 4 {
  30002. verify_number = psn_info.VerifyNumber
  30003. } else if psn_info.IdCardType == 1 {
  30004. bas := strings.Split(psn_info.CardInfo, "|")
  30005. cardNumber := bas[2]
  30006. verify_number = cardNumber
  30007. } else {
  30008. psn_info.IdCardType = 2
  30009. verify_number = psn_info.Certno
  30010. }
  30011. var api string
  30012. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30013. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30014. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30015. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30016. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30017. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30018. "&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
  30019. resp, requestErr := http.Get(api)
  30020. if requestErr != nil {
  30021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30022. return
  30023. }
  30024. body, ioErr := ioutil.ReadAll(resp.Body)
  30025. if ioErr != nil {
  30026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30028. return
  30029. }
  30030. var respJSON map[string]interface{}
  30031. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30034. return
  30035. }
  30036. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30037. result, _ := json.Marshal(respJSON)
  30038. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30039. utils.ErrorLog("解析失败:%v", err)
  30040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30041. return
  30042. }
  30043. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30044. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30045. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30046. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30047. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30048. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30049. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30050. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30051. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30052. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30053. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30054. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30055. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30056. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30057. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30058. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30059. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30060. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30061. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30062. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30063. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30064. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30065. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30066. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30067. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30068. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30069. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30070. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30071. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30072. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30073. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30074. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30075. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30076. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30077. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30078. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30079. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30080. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30081. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30082. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30083. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30084. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30085. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30086. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30087. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30088. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30089. res.ErrMsg = resSeven10265.ErrMsg
  30090. res.Cainfo = resSeven10265.Cainfo
  30091. res.WarnMsg = resSeven10265.WarnMsg
  30092. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30093. res.Infcode = infocode
  30094. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30095. acct_used_flag := "1"
  30096. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30097. var result string
  30098. var request_log string
  30099. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30100. 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)
  30101. } else {
  30102. 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)
  30103. }
  30104. var dat map[string]interface{}
  30105. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30106. fmt.Println(dat)
  30107. } else {
  30108. fmt.Println(err)
  30109. }
  30110. saveLog(result, request_log, "2206", "预结算")
  30111. userJSONBytes, _ := json.Marshal(dat)
  30112. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30113. utils.ErrorLog("解析失败:%v", err)
  30114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30115. return
  30116. }
  30117. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30118. var result string
  30119. var request_log string
  30120. if his.IdCardType == 2 {
  30121. insutype = strconv.FormatInt(his.SocialType, 10)
  30122. 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, "")
  30123. } else if his.IdCardType == 1 {
  30124. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30125. bas := strings.Split(psn_info.CardInfo, "|")
  30126. basNumber := bas[2]
  30127. card_sn := bas[3]
  30128. var rf []*ResultFive
  30129. json.Unmarshal([]byte(his.Iinfo), &rf)
  30130. var psn_type string
  30131. for _, item := range rf {
  30132. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30133. psn_type = item.PsnType
  30134. }
  30135. }
  30136. insutype = strconv.FormatInt(his.SocialType, 10)
  30137. 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)
  30138. } else {
  30139. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30140. //bas := strings.Split(psn_info.CardInfo, "|")
  30141. //basNumber := bas[2]
  30142. //card_sn := bas[3]
  30143. var rf []*ResultFive
  30144. json.Unmarshal([]byte(his.Iinfo), &rf)
  30145. var psn_type string
  30146. for _, item := range rf {
  30147. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30148. psn_type = item.PsnType
  30149. }
  30150. }
  30151. insutype = strconv.FormatInt(his.SocialType, 10)
  30152. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30153. 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)
  30154. }
  30155. var dat map[string]interface{}
  30156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30157. fmt.Println(dat)
  30158. } else {
  30159. fmt.Println(err)
  30160. }
  30161. saveLog(result, request_log, "2206", "预结算")
  30162. userJSONBytes, _ := json.Marshal(dat)
  30163. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30164. utils.ErrorLog("解析失败:%v", err)
  30165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30166. return
  30167. }
  30168. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30169. var result string
  30170. var request_log string
  30171. if his.IdCardType == 2 {
  30172. insutype = strconv.FormatInt(his.SocialType, 10)
  30173. 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, "")
  30174. } else if his.IdCardType == 1 {
  30175. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30176. bas := strings.Split(psn_info.CardInfo, "|")
  30177. basNumber := bas[0]
  30178. card_sn := ""
  30179. var rf []*ResultFive
  30180. json.Unmarshal([]byte(his.Iinfo), &rf)
  30181. var psn_type string
  30182. for _, item := range rf {
  30183. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30184. psn_type = item.PsnType
  30185. }
  30186. }
  30187. insutype = strconv.FormatInt(his.SocialType, 10)
  30188. 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)
  30189. } else {
  30190. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30191. //bas := strings.Split(psn_info.CardInfo, "|")
  30192. //basNumber := bas[2]
  30193. //card_sn := bas[3]
  30194. var rf []*ResultFive
  30195. json.Unmarshal([]byte(his.Iinfo), &rf)
  30196. var psn_type string
  30197. for _, item := range rf {
  30198. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30199. psn_type = item.PsnType
  30200. }
  30201. }
  30202. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30203. 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)
  30204. }
  30205. var dat map[string]interface{}
  30206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30207. fmt.Println(dat)
  30208. } else {
  30209. fmt.Println(err)
  30210. }
  30211. saveLog(result, request_log, "2206", "预结算")
  30212. userJSONBytes, _ := json.Marshal(dat)
  30213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30214. utils.ErrorLog("解析失败:%v", err)
  30215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30216. return
  30217. }
  30218. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30219. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30220. if his.IdCardType == 4 {
  30221. psn_info.VerifyNumber = psn_info.VerifyNumber
  30222. cert_no = psn_info.VerifyNumber
  30223. } else if his.IdCardType == 2 {
  30224. cert_no = psn_info.Certno
  30225. psn_info.VerifyNumber = psn_info.Certno
  30226. } else {
  30227. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30228. bas := strings.Split(psn_info.CardInfo, "|")
  30229. if his.IdCardType == 1 {
  30230. cert_no = bas[2]
  30231. } else {
  30232. cert_no = bas[1]
  30233. }
  30234. }
  30235. var api string
  30236. var med_type string
  30237. if his.Insutype == "390" {
  30238. if reg_type == 992102 {
  30239. med_type = "992102"
  30240. }
  30241. if reg_type == 140104 {
  30242. med_type = "140104"
  30243. }
  30244. if reg_type == 140201 {
  30245. med_type = "140201"
  30246. }
  30247. if reg_type == 14 {
  30248. med_type = "140104"
  30249. }
  30250. } else if his.Insutype == "310" {
  30251. if reg_type == 992102 {
  30252. med_type = "992102"
  30253. }
  30254. if reg_type == 140104 {
  30255. med_type = "140104"
  30256. }
  30257. if reg_type == 140201 {
  30258. med_type = "140201"
  30259. }
  30260. if reg_type == 14 {
  30261. med_type = "140104"
  30262. }
  30263. }
  30264. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30265. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30266. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30267. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30268. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30269. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30270. "&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
  30271. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30272. resp, requestErr := http.Get(api)
  30273. if requestErr != nil {
  30274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30275. return
  30276. }
  30277. body, ioErr := ioutil.ReadAll(resp.Body)
  30278. if ioErr != nil {
  30279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30281. return
  30282. }
  30283. var respJSON map[string]interface{}
  30284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30287. return
  30288. }
  30289. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30290. if status == "0" {
  30291. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30292. c.ServeSuccessJSON(map[string]interface{}{
  30293. "failed_code": -10,
  30294. "msg": err_msg,
  30295. })
  30296. return
  30297. }
  30298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30299. result, _ := json.Marshal(respJSON)
  30300. fmt.Println("log")
  30301. fmt.Println(string(result))
  30302. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30303. utils.ErrorLog("解析失败:%v", err)
  30304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30305. return
  30306. }
  30307. res.InfRefmsgid = ahres.InfRefmsgid
  30308. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30309. // 创建对应的Time类型
  30310. t := time.UnixMilli(timestamp)
  30311. // 格式化成指定的日期字符串
  30312. str := t.Format("2006-01-02 15:04:05")
  30313. res.Output.Setlinfo.SetlTime = str
  30314. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30315. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30316. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30317. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30318. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30319. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30320. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30321. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30322. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30323. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30324. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30325. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30326. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30327. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30328. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30329. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30330. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30331. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30332. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30333. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30334. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30335. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30336. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30337. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30338. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30339. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30340. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30341. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30342. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30343. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30344. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30345. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30346. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30347. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30348. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30349. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30350. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30351. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30352. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30353. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30354. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30355. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30356. //res.Output.Setldetail = ahres.Output.Setldetail
  30357. res.ErrMsg = ahres.ErrMsg
  30358. res.Cainfo = ahres.Cainfo
  30359. res.WarnMsg = ahres.WarnMsg
  30360. res.Infcode = ahres.Infcode
  30361. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30362. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30363. if his.IdCardType == 4 {
  30364. psn_info.VerifyNumber = psn_info.VerifyNumber
  30365. cert_no = psn_info.Certno
  30366. } else if his.IdCardType == 2 {
  30367. cert_no = psn_info.Certno
  30368. psn_info.VerifyNumber = psn_info.Certno
  30369. } else {
  30370. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30371. bas := strings.Split(psn_info.CardInfo, "|")
  30372. if his.IdCardType == 1 {
  30373. cert_no = bas[2]
  30374. } else {
  30375. cert_no = bas[1]
  30376. }
  30377. }
  30378. var api string
  30379. var med_type string
  30380. if his.Insutype == "390" {
  30381. if reg_type == 992102 {
  30382. med_type = "992102"
  30383. }
  30384. if reg_type == 140104 {
  30385. med_type = "140104"
  30386. }
  30387. if reg_type == 140201 {
  30388. med_type = "140201"
  30389. }
  30390. if reg_type == 14 {
  30391. med_type = "14"
  30392. }
  30393. } else if his.Insutype == "310" {
  30394. if reg_type == 992102 {
  30395. med_type = "992102"
  30396. }
  30397. if reg_type == 140104 {
  30398. med_type = "140104"
  30399. }
  30400. if reg_type == 140201 {
  30401. med_type = "140201"
  30402. }
  30403. if reg_type == 14 {
  30404. med_type = "14"
  30405. }
  30406. }
  30407. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30408. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30409. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30410. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30411. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30412. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30413. "&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
  30414. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30415. resp, requestErr := http.Get(api)
  30416. if requestErr != nil {
  30417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30418. return
  30419. }
  30420. body, ioErr := ioutil.ReadAll(resp.Body)
  30421. if ioErr != nil {
  30422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30424. return
  30425. }
  30426. var respJSON map[string]interface{}
  30427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30430. return
  30431. }
  30432. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30433. if status == "0" {
  30434. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30435. c.ServeSuccessJSON(map[string]interface{}{
  30436. "failed_code": -10,
  30437. "msg": err_msg,
  30438. })
  30439. return
  30440. }
  30441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30442. result, _ := json.Marshal(respJSON)
  30443. fmt.Println("log")
  30444. fmt.Println(string(result))
  30445. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30446. utils.ErrorLog("解析失败:%v", err)
  30447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30448. return
  30449. }
  30450. res.InfRefmsgid = ahres.InfRefmsgid
  30451. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30452. // 创建对应的Time类型
  30453. t := time.UnixMilli(timestamp)
  30454. // 格式化成指定的日期字符串
  30455. str := t.Format("2006-01-02 15:04:05")
  30456. res.Output.Setlinfo.SetlTime = str
  30457. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30458. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30459. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30460. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30461. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30462. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30463. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30464. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30465. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30466. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30467. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30468. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30469. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30470. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30471. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30472. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30473. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30474. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30475. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30476. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30477. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30478. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30479. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30480. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30481. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30482. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30483. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30484. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30485. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30486. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30487. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30488. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30489. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30490. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30491. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30492. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30493. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30494. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30495. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30496. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30497. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30498. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30499. //res.Output.Setldetail = ahres.Output.Setldetail
  30500. res.ErrMsg = ahres.ErrMsg
  30501. res.Cainfo = ahres.Cainfo
  30502. res.WarnMsg = ahres.WarnMsg
  30503. res.Infcode = ahres.Infcode
  30504. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30505. var result string
  30506. var request_log string
  30507. if his.IdCardType == 2 {
  30508. 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")
  30509. } else if his.IdCardType == 1 {
  30510. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30511. bas := strings.Split(psn_info.CardInfo, "|")
  30512. basNumber := bas[2]
  30513. card_sn := bas[3]
  30514. 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")
  30515. } else {
  30516. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30517. 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")
  30518. }
  30519. var dat map[string]interface{}
  30520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30521. fmt.Println(dat)
  30522. } else {
  30523. fmt.Println(err)
  30524. }
  30525. saveLog(result, request_log, "2206", "预结算")
  30526. userJSONBytes, _ := json.Marshal(dat)
  30527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30528. utils.ErrorLog("解析失败:%v", err)
  30529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30530. return
  30531. }
  30532. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30533. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30534. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30535. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30536. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30537. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30538. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30539. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30540. resp, requestErr := http.Get(api)
  30541. if requestErr != nil {
  30542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30543. return
  30544. }
  30545. body, ioErr := ioutil.ReadAll(resp.Body)
  30546. if ioErr != nil {
  30547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30549. return
  30550. }
  30551. var respJSON map[string]interface{}
  30552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30555. return
  30556. }
  30557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30558. result, _ := json.Marshal(respJSON)
  30559. fmt.Println("log")
  30560. fmt.Println(string(result))
  30561. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30562. utils.ErrorLog("解析失败:%v", err)
  30563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30564. return
  30565. }
  30566. } else {
  30567. if miConfig.MdtrtareaAdmvs == "441202" {
  30568. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30569. if result3101.Infcode == 0 {
  30570. if len(result3101.Output.Result) > 0 {
  30571. c.ServeSuccessJSON(map[string]interface{}{
  30572. "failed_code": -10,
  30573. "failed_type": 100,
  30574. "msg": result3101.Output.Result,
  30575. })
  30576. return
  30577. } else {
  30578. var result string
  30579. var request_log string
  30580. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30581. allTotal = fmt.Sprintf("%.2f", total_two)
  30582. if his.IdCardType == 4 {
  30583. 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)
  30584. } else {
  30585. 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)
  30586. }
  30587. var dat map[string]interface{}
  30588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30589. fmt.Println(dat)
  30590. } else {
  30591. fmt.Println(err)
  30592. }
  30593. saveLog(result, request_log, "2206", "预结算")
  30594. //userJSONBytes, _ := json.Marshal(dat)
  30595. //
  30596. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30597. // utils.ErrorLog("解析失败:%v", err)
  30598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30599. // return
  30600. //}
  30601. userJSONBytes, _ := json.Marshal(dat)
  30602. if miConfig.Code == "H15049901371" {
  30603. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30604. utils.ErrorLog("解析失败:%v", err)
  30605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30606. return
  30607. }
  30608. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30609. res.Output = resSeven10265.Output
  30610. res.ErrMsg = resSeven10265.ErrMsg
  30611. res.Cainfo = resSeven10265.Cainfo
  30612. res.WarnMsg = resSeven10265.WarnMsg
  30613. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30614. res.Infcode = infocode
  30615. } else {
  30616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30617. utils.ErrorLog("解析失败:%v", err)
  30618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30619. return
  30620. }
  30621. }
  30622. }
  30623. } else {
  30624. c.ServeSuccessJSON(map[string]interface{}{
  30625. "failed_code": -10,
  30626. "msg": result3101.ErrMsg,
  30627. })
  30628. return
  30629. }
  30630. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30631. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30632. if result3101.Infcode == 0 {
  30633. if len(result3101.Output.Result) > 0 {
  30634. var errMsgs []string
  30635. for _, item := range result3101.Output.Result {
  30636. errMsgs = append(errMsgs, item.VolaCont)
  30637. }
  30638. c.ServeSuccessJSON(map[string]interface{}{
  30639. "failed_code": -10,
  30640. "msg": errMsgs,
  30641. })
  30642. return
  30643. } else {
  30644. var result string
  30645. var request_log string
  30646. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30647. allTotal = fmt.Sprintf("%.2f", total_two)
  30648. if his.IdCardType == 4 {
  30649. 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)
  30650. } else {
  30651. 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)
  30652. }
  30653. var dat map[string]interface{}
  30654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30655. fmt.Println(dat)
  30656. } else {
  30657. fmt.Println(err)
  30658. }
  30659. saveLog(result, request_log, "2206", "预结算")
  30660. //userJSONBytes, _ := json.Marshal(dat)
  30661. //
  30662. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30663. // utils.ErrorLog("解析失败:%v", err)
  30664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30665. // return
  30666. //}
  30667. userJSONBytes, _ := json.Marshal(dat)
  30668. if miConfig.Code == "H15049901371" {
  30669. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30670. utils.ErrorLog("解析失败:%v", err)
  30671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30672. return
  30673. }
  30674. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30675. res.Output = resSeven10265.Output
  30676. res.ErrMsg = resSeven10265.ErrMsg
  30677. res.Cainfo = resSeven10265.Cainfo
  30678. res.WarnMsg = resSeven10265.WarnMsg
  30679. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30680. res.Infcode = infocode
  30681. } else {
  30682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30683. utils.ErrorLog("解析失败:%v", err)
  30684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30685. return
  30686. }
  30687. }
  30688. }
  30689. } else {
  30690. c.ServeSuccessJSON(map[string]interface{}{
  30691. "failed_code": -10,
  30692. "msg": result3101.ErrMsg,
  30693. })
  30694. return
  30695. }
  30696. } else {
  30697. var result string
  30698. var request_log string
  30699. var dat map[string]interface{}
  30700. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30701. allTotal = fmt.Sprintf("%.2f", total_two)
  30702. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30703. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30704. if result3101.Infcode == 0 {
  30705. if len(result3101.Output.Result) > 0 {
  30706. c.ServeSuccessJSON(map[string]interface{}{
  30707. "failed_code": -10,
  30708. "failed_type": 100,
  30709. "msg": result3101.Output.Result,
  30710. })
  30711. return
  30712. } else {
  30713. var result string
  30714. var request_log string
  30715. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30716. allTotal = fmt.Sprintf("%.2f", total_two)
  30717. if his.IdCardType == 4 {
  30718. 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)
  30719. } else {
  30720. if his.IdCardType == 2 {
  30721. cert_no = psn_info.Certno
  30722. psn_info.VerifyNumber = psn_info.Certno
  30723. } else {
  30724. bas := strings.Split(psn_info.CardInfo, "|")
  30725. cert_no = bas[2]
  30726. }
  30727. 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)
  30728. }
  30729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30730. fmt.Println(dat)
  30731. } else {
  30732. fmt.Println(err)
  30733. }
  30734. saveLog(result, request_log, "2206", "预结算")
  30735. }
  30736. } else {
  30737. c.ServeSuccessJSON(map[string]interface{}{
  30738. "failed_code": -10,
  30739. "msg": result3101.ErrMsg,
  30740. })
  30741. return
  30742. }
  30743. } else {
  30744. if his.IdCardType == 4 {
  30745. 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)
  30746. } else {
  30747. if his.IdCardType == 2 {
  30748. cert_no = psn_info.Certno
  30749. psn_info.VerifyNumber = psn_info.Certno
  30750. } else {
  30751. bas := strings.Split(psn_info.CardInfo, "|")
  30752. cert_no = bas[2]
  30753. }
  30754. 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)
  30755. }
  30756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30757. fmt.Println(dat)
  30758. } else {
  30759. fmt.Println(err)
  30760. }
  30761. saveLog(result, request_log, "2206", "预结算")
  30762. }
  30763. //userJSONBytes, _ := json.Marshal(dat)
  30764. //
  30765. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30766. // utils.ErrorLog("解析失败:%v", err)
  30767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30768. // return
  30769. //}
  30770. userJSONBytes, _ := json.Marshal(dat)
  30771. if miConfig.Code == "H15049901371" {
  30772. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30773. utils.ErrorLog("解析失败:%v", err)
  30774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30775. return
  30776. }
  30777. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30778. res.Output = resSeven10265.Output
  30779. res.ErrMsg = resSeven10265.ErrMsg
  30780. res.Cainfo = resSeven10265.Cainfo
  30781. res.WarnMsg = resSeven10265.WarnMsg
  30782. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30783. res.Infcode = infocode
  30784. } else {
  30785. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30786. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30787. utils.ErrorLog("解析失败:%v", err)
  30788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30789. return
  30790. }
  30791. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30792. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30793. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30794. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30795. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30796. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30797. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30798. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30799. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30800. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30801. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30802. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30803. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30804. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30805. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30806. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30807. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30808. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30809. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30810. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30811. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30812. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30813. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30814. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30815. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30816. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30817. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30818. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30819. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30820. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30821. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30822. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30823. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30824. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30825. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30826. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30827. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30828. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30829. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30830. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30831. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30832. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30833. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30834. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30835. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30836. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30837. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30838. res.Cainfo = gzresSeven10265Two.Cainfo
  30839. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30840. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30841. //res.Infcode = infocode
  30842. } else {
  30843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30844. utils.ErrorLog("解析失败:%v", err)
  30845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30846. return
  30847. }
  30848. }
  30849. }
  30850. }
  30851. }
  30852. utils.ErrorLog("解析失败:%v", res.Infcode)
  30853. if res.Infcode == -1 {
  30854. errlog := &models.HisOrderError{
  30855. UserOrgId: adminUser.CurrentOrgId,
  30856. Ctime: time.Now().Unix(),
  30857. Mtime: time.Now().Unix(),
  30858. Number: chrg_bchno,
  30859. ErrMsg: res.ErrMsg,
  30860. Status: 1,
  30861. PatientId: id,
  30862. RecordTime: recordDateTime,
  30863. Stage: 20,
  30864. }
  30865. service.CreateErrMsgLog(errlog)
  30866. c.ServeSuccessJSON(map[string]interface{}{
  30867. "failed_code": -10,
  30868. "msg": res.ErrMsg,
  30869. })
  30870. return
  30871. }
  30872. if res.Infcode != 0 {
  30873. errlog := &models.HisOrderError{
  30874. UserOrgId: adminUser.CurrentOrgId,
  30875. Ctime: time.Now().Unix(),
  30876. Mtime: time.Now().Unix(),
  30877. Number: chrg_bchno,
  30878. ErrMsg: res.ErrMsg,
  30879. Status: 1,
  30880. PatientId: id,
  30881. RecordTime: recordDateTime,
  30882. Stage: 20,
  30883. }
  30884. service.CreateErrMsgLog(errlog)
  30885. c.ServeSuccessJSON(map[string]interface{}{
  30886. "failed_code": -10,
  30887. "msg": res.ErrMsg,
  30888. })
  30889. return
  30890. } else {
  30891. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30892. order.OrderStatus = 1
  30893. order.IsPre = 1
  30894. order.Status = 1
  30895. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30896. order.SetlId = res.Output.Setlinfo.SetlID
  30897. order.PsnNo = res.Output.Setlinfo.PsnNo
  30898. order.PsnName = res.Output.Setlinfo.PsnName
  30899. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30900. order.Certno = res.Output.Setlinfo.Certno
  30901. order.Gend = res.Output.Setlinfo.Gend
  30902. order.Naty = res.Output.Setlinfo.Naty
  30903. order.Age = res.Output.Setlinfo.Age
  30904. order.Insutype = res.Output.Setlinfo.Insutype
  30905. order.PsnType = res.Output.Setlinfo.PsnType
  30906. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30907. order.SetlTime = res.Output.Setlinfo.SetlTime
  30908. order.AcctUsedFlag = acct_used_flag
  30909. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30910. if res.Output.Setlinfo.MedType == "140101" {
  30911. order.MedType = "14"
  30912. } else {
  30913. if res.Output.Setlinfo.MedType == "110104" {
  30914. order.MedType = "11"
  30915. } else {
  30916. order.MedType = res.Output.Setlinfo.MedType
  30917. }
  30918. }
  30919. if res.Output.Setlinfo.MedType == "992102" {
  30920. order.MedType = "992102"
  30921. }
  30922. if res.Output.Setlinfo.MedType == "140104" {
  30923. order.MedType = "140104"
  30924. }
  30925. if res.Output.Setlinfo.MedType == "140201" {
  30926. order.MedType = "140201"
  30927. }
  30928. if res.Output.Setlinfo.MedType == "14" {
  30929. order.MedType = "14"
  30930. }
  30931. if reg_type == 1112 {
  30932. order.MedType = "1112"
  30933. }
  30934. if reg_type == 1111 {
  30935. order.MedType = "1111"
  30936. }
  30937. order.ClrType = res.Output.Setlinfo.ClrType
  30938. if adminUser.CurrentOrgId == 10480 {
  30939. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30940. order.ClrType = "11"
  30941. } else {
  30942. order.ClrType = "9903"
  30943. }
  30944. }
  30945. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30946. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30947. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30948. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30949. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30950. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30951. order.HifpPay = res.Output.Setlinfo.HifpPay
  30952. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30953. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30954. order.HifesPay = res.Output.Setlinfo.HifesPay
  30955. order.HifobPay = res.Output.Setlinfo.HifobPay
  30956. order.MafPay = res.Output.Setlinfo.MafPay
  30957. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30958. order.OthPay = res.Output.Setlinfo.OthPay
  30959. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30960. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30961. order.AcctPay = res.Output.Setlinfo.AcctPay
  30962. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30963. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30964. order.Balc = res.Output.Setlinfo.Balc
  30965. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30966. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30967. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30968. order.ClrWay = res.Output.Setlinfo.ClrWay
  30969. order.Creator = order.Creator
  30970. order.Modify = roles.AdminUserId
  30971. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30972. //detailStr := string(setlDetail)
  30973. //order.SetlDetail = detailStr
  30974. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30975. err = service.UpDateOrder(order)
  30976. if err == nil {
  30977. c.ServeSuccessJSON(map[string]interface{}{
  30978. "msg": "预结算成功",
  30979. })
  30980. } else {
  30981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30982. return
  30983. }
  30984. }
  30985. } else {
  30986. adminUser := c.GetAdminUserInfo()
  30987. errlog := &models.HisOrderError{
  30988. UserOrgId: adminUser.CurrentOrgId,
  30989. Ctime: time.Now().Unix(),
  30990. Mtime: time.Now().Unix(),
  30991. ErrMsg: res.ErrMsg,
  30992. Status: 1,
  30993. PatientId: id,
  30994. RecordTime: recordDateTime,
  30995. Stage: 4,
  30996. }
  30997. service.CreateErrMsgLog(errlog)
  30998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30999. return
  31000. }
  31001. } else {
  31002. if miConfig.MdtrtareaAdmvs == "150499" {
  31003. order := &models.HisOrder{
  31004. UserOrgId: adminUser.CurrentOrgId,
  31005. HisPatientId: his.ID,
  31006. PatientId: his.PatientId,
  31007. SettleAccountsDate: recordDateTime,
  31008. Ctime: time.Now().Unix(),
  31009. Mtime: time.Now().Unix(),
  31010. MdtrtId: his.Number,
  31011. PsnNo: his.PsnNo,
  31012. MedType: strconv.FormatInt(reg_type, 10),
  31013. Status: 1,
  31014. Number: chrg_bchno,
  31015. Infcode: res.Infcode,
  31016. WarnMsg: res.WarnMsg,
  31017. Cainfo: res.Cainfo,
  31018. ErrMsg: res.ErrMsg,
  31019. RespondTime: res.RefmsgTime,
  31020. InfRefmsgid: res.InfRefmsgid,
  31021. OrderStatus: 1,
  31022. IsMedicineInsurance: 1,
  31023. SettleType: settle_accounts_type,
  31024. SettleStartTime: start_time,
  31025. SettleEndTime: end_time,
  31026. Creator: roles.AdminUserId,
  31027. Modify: roles.AdminUserId,
  31028. PType: 2,
  31029. Diagnosis: diagnosis_id,
  31030. }
  31031. err = service.CreateOrder(order)
  31032. if err != nil {
  31033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31034. return
  31035. }
  31036. }
  31037. adminUser := c.GetAdminUserInfo()
  31038. errlog := &models.HisOrderError{
  31039. UserOrgId: adminUser.CurrentOrgId,
  31040. Ctime: time.Now().Unix(),
  31041. Mtime: time.Now().Unix(),
  31042. ErrMsg: res.ErrMsg,
  31043. Status: 1,
  31044. PatientId: id,
  31045. RecordTime: recordDateTime,
  31046. Stage: 4,
  31047. }
  31048. service.CreateErrMsgLog(errlog)
  31049. c.ServeSuccessJSON(map[string]interface{}{
  31050. "failed_code": -10,
  31051. "msg": res.ErrMsg,
  31052. })
  31053. return
  31054. }
  31055. }
  31056. }
  31057. }
  31058. // 退款
  31059. func (c *HisApiController) Refund() {
  31060. order_id, _ := c.GetInt64("order_id")
  31061. admin_user_id, _ := c.GetInt64("admin_user_id")
  31062. adminUser := c.GetAdminUserInfo()
  31063. var order models.HisOrder
  31064. order, _ = service.GetHisOrderByID(order_id)
  31065. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31066. if fapiao.ID > 0 {
  31067. c.ServeSuccessJSON(map[string]interface{}{
  31068. "failed_code": -10,
  31069. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31070. })
  31071. return
  31072. }
  31073. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31074. if order.ID == 0 {
  31075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31076. return
  31077. }
  31078. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31079. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31080. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31081. if config.IsOpen == 1 { //对接了医保,走医保流程
  31082. var res ResultSixteen
  31083. var ahres ResultSevenAH
  31084. var resSixteen10265 ResultSixteen10265
  31085. var resSixteen10265Two ResultSixteen10265Two
  31086. var gz ResultgzSixteen10265Two
  31087. var src_resquest string
  31088. var result string
  31089. if miConfig.MdtrtareaAdmvs == "421300" {
  31090. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31091. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31092. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31093. resp3, requestErr3 := http.Get(api3)
  31094. if requestErr3 != nil {
  31095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31096. return
  31097. }
  31098. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31099. if ioErr3 != nil {
  31100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31102. return
  31103. }
  31104. var respJSON3 map[string]interface{}
  31105. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31108. return
  31109. }
  31110. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31111. userJSONBytes3, _ := json.Marshal(respJSON3)
  31112. fmt.Println("log")
  31113. fmt.Println(string(userJSONBytes3))
  31114. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31115. utils.ErrorLog("解析失败:%v", err)
  31116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31117. return
  31118. }
  31119. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31120. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31121. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31122. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31123. resp3, requestErr3 := http.Get(api3)
  31124. if requestErr3 != nil {
  31125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31126. return
  31127. }
  31128. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31129. if ioErr3 != nil {
  31130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31132. return
  31133. }
  31134. var respJSON3 map[string]interface{}
  31135. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31138. return
  31139. }
  31140. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31141. userJSONBytes3, _ := json.Marshal(respJSON3)
  31142. fmt.Println("log")
  31143. fmt.Println(string(userJSONBytes3))
  31144. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31145. utils.ErrorLog("解析失败:%v", err)
  31146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31147. return
  31148. }
  31149. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31150. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31151. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31152. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31153. resp3, requestErr3 := http.Get(api3)
  31154. if requestErr3 != nil {
  31155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31156. return
  31157. }
  31158. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31159. if ioErr3 != nil {
  31160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31162. return
  31163. }
  31164. var respJSON3 map[string]interface{}
  31165. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31168. return
  31169. }
  31170. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31171. userJSONBytes3, _ := json.Marshal(respJSON3)
  31172. fmt.Println("log")
  31173. fmt.Println(string(userJSONBytes3))
  31174. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31175. utils.ErrorLog("解析失败:%v", err)
  31176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31177. return
  31178. }
  31179. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31180. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31181. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31182. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31183. resp3, requestErr3 := http.Get(api3)
  31184. if requestErr3 != nil {
  31185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31186. return
  31187. }
  31188. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31189. if ioErr3 != nil {
  31190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31192. return
  31193. }
  31194. var respJSON3 map[string]interface{}
  31195. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31198. return
  31199. }
  31200. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31201. userJSONBytes3, _ := json.Marshal(respJSON3)
  31202. fmt.Println("log")
  31203. fmt.Println(string(userJSONBytes3))
  31204. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31205. utils.ErrorLog("解析失败:%v", err)
  31206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31207. return
  31208. }
  31209. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31210. var api3 string
  31211. if miConfig.MdtrtareaAdmvs == "320921" {
  31212. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31213. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31214. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31215. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31216. } else {
  31217. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31218. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31219. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31220. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31221. }
  31222. resp3, requestErr3 := http.Get(api3)
  31223. if requestErr3 != nil {
  31224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31225. return
  31226. }
  31227. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31228. if ioErr3 != nil {
  31229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31231. return
  31232. }
  31233. var respJSON3 map[string]interface{}
  31234. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31237. return
  31238. }
  31239. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31240. userJSONBytes3, _ := json.Marshal(respJSON3)
  31241. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31242. utils.ErrorLog("解析失败:%v", err)
  31243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31244. return
  31245. }
  31246. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31247. res.Output = resSixteen10265.Output
  31248. res.ErrMsg = resSixteen10265.ErrMsg
  31249. res.Cainfo = resSixteen10265.Cainfo
  31250. res.WarnMsg = resSixteen10265.WarnMsg
  31251. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31252. res.Infcode = infocode
  31253. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31254. var api3 string
  31255. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31256. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31258. resp3, requestErr3 := http.Get(api3)
  31259. if requestErr3 != nil {
  31260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31261. return
  31262. }
  31263. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31264. if ioErr3 != nil {
  31265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31267. return
  31268. }
  31269. var respJSON3 map[string]interface{}
  31270. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31273. return
  31274. }
  31275. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31276. userJSONBytes3, _ := json.Marshal(respJSON3)
  31277. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31278. utils.ErrorLog("解析失败:%v", err)
  31279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31280. return
  31281. }
  31282. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31283. res.Output = resSixteen10265.Output
  31284. res.ErrMsg = resSixteen10265.ErrMsg
  31285. res.Cainfo = resSixteen10265.Cainfo
  31286. res.WarnMsg = resSixteen10265.WarnMsg
  31287. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31288. res.Infcode = infocode
  31289. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31290. 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)
  31291. var dat map[string]interface{}
  31292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31293. fmt.Println(dat)
  31294. } else {
  31295. fmt.Println(err)
  31296. }
  31297. saveLog(result, src_resquest, "2208", "退费")
  31298. userJSONBytes, _ := json.Marshal(dat)
  31299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31300. utils.ErrorLog("解析失败:%v", err)
  31301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31302. return
  31303. }
  31304. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31305. 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, "")
  31306. var dat map[string]interface{}
  31307. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31308. fmt.Println(dat)
  31309. } else {
  31310. fmt.Println(err)
  31311. }
  31312. saveLog(result, src_resquest, "2208", "退费")
  31313. userJSONBytes, _ := json.Marshal(dat)
  31314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31315. utils.ErrorLog("解析失败:%v", err)
  31316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31317. return
  31318. }
  31319. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31320. 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, "")
  31321. var dat map[string]interface{}
  31322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31323. fmt.Println(dat)
  31324. } else {
  31325. fmt.Println(err)
  31326. }
  31327. saveLog(result, src_resquest, "2208", "退费")
  31328. userJSONBytes, _ := json.Marshal(dat)
  31329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31330. utils.ErrorLog("解析失败:%v", err)
  31331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31332. return
  31333. }
  31334. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31335. var api3 string
  31336. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31337. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31338. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31339. resp3, requestErr3 := http.Get(api3)
  31340. if requestErr3 != nil {
  31341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31342. return
  31343. }
  31344. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31345. if ioErr3 != nil {
  31346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31348. return
  31349. }
  31350. var respJSON3 map[string]interface{}
  31351. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31354. return
  31355. }
  31356. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31357. if status == "0" {
  31358. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31359. c.ServeSuccessJSON(map[string]interface{}{
  31360. "failed_code": -10,
  31361. "msg": err_msg,
  31362. })
  31363. return
  31364. }
  31365. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31366. userJSONBytes3, _ := json.Marshal(respJSON3)
  31367. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31368. // utils.ErrorLog("解析失败:%v", err)
  31369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31370. // return
  31371. //}
  31372. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31373. utils.ErrorLog("解析失败:%v", err)
  31374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31375. return
  31376. }
  31377. res.InfRefmsgid = ahres.InfRefmsgid
  31378. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31379. // 创建对应的Time类型
  31380. t := time.UnixMilli(timestamp)
  31381. // 格式化成指定的日期字符串
  31382. str := t.Format("2006-01-02 15:04:05")
  31383. res.Output.Setlinfo.SetlTime = str
  31384. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31385. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31386. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31387. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31388. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31389. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31390. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31391. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31392. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31393. //
  31394. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31395. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31396. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31397. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31398. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31399. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31400. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31401. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31402. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31403. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31404. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31405. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31406. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31407. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31408. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31409. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31410. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31411. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31412. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31413. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31414. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31415. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31416. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31417. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31418. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31419. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31420. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31421. //res.Output.Setldetail = ahres.Output.Setldetail
  31422. res.ErrMsg = ahres.ErrMsg
  31423. res.Cainfo = ahres.Cainfo
  31424. res.WarnMsg = ahres.WarnMsg
  31425. res.Infcode = ahres.Infcode
  31426. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31427. var api3 string
  31428. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31429. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31430. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31431. resp3, requestErr3 := http.Get(api3)
  31432. if requestErr3 != nil {
  31433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31434. return
  31435. }
  31436. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31437. if ioErr3 != nil {
  31438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31440. return
  31441. }
  31442. var respJSON3 map[string]interface{}
  31443. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31446. return
  31447. }
  31448. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31449. if status == "0" {
  31450. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31451. c.ServeSuccessJSON(map[string]interface{}{
  31452. "failed_code": -10,
  31453. "msg": err_msg,
  31454. })
  31455. return
  31456. }
  31457. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31458. userJSONBytes3, _ := json.Marshal(respJSON3)
  31459. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31460. // utils.ErrorLog("解析失败:%v", err)
  31461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31462. // return
  31463. //}
  31464. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31465. utils.ErrorLog("解析失败:%v", err)
  31466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31467. return
  31468. }
  31469. res.InfRefmsgid = ahres.InfRefmsgid
  31470. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31471. // 创建对应的Time类型
  31472. t := time.UnixMilli(timestamp)
  31473. // 格式化成指定的日期字符串
  31474. str := t.Format("2006-01-02 15:04:05")
  31475. res.Output.Setlinfo.SetlTime = str
  31476. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31477. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31478. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31479. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31480. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31481. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31482. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31483. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31484. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31485. //
  31486. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31487. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31488. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31489. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31490. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31491. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31492. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31493. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31494. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31495. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31496. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31497. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31498. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31499. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31500. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31501. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31502. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31503. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31504. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31505. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31506. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31507. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31508. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31509. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31510. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31511. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31512. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31513. //res.Output.Setldetail = ahres.Output.Setldetail
  31514. res.ErrMsg = ahres.ErrMsg
  31515. res.Cainfo = ahres.Cainfo
  31516. res.WarnMsg = ahres.WarnMsg
  31517. res.Infcode = ahres.Infcode
  31518. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31519. 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, "")
  31520. var dat map[string]interface{}
  31521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31522. fmt.Println(dat)
  31523. } else {
  31524. fmt.Println(err)
  31525. }
  31526. saveLog(result, src_resquest, "2208", "退费")
  31527. userJSONBytes, _ := json.Marshal(dat)
  31528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31529. utils.ErrorLog("解析失败:%v", err)
  31530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31531. return
  31532. }
  31533. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31534. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31535. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31536. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31537. resp3, requestErr3 := http.Get(api3)
  31538. if requestErr3 != nil {
  31539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31540. return
  31541. }
  31542. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31543. if ioErr3 != nil {
  31544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31546. return
  31547. }
  31548. var respJSON3 map[string]interface{}
  31549. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31552. return
  31553. }
  31554. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31555. userJSONBytes3, _ := json.Marshal(respJSON3)
  31556. fmt.Println("log")
  31557. fmt.Println(string(userJSONBytes3))
  31558. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31559. utils.ErrorLog("解析失败:%v", err)
  31560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31561. return
  31562. }
  31563. } else {
  31564. if miConfig.Code == "H15049901371" {
  31565. 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)
  31566. var dat map[string]interface{}
  31567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31568. fmt.Println(dat)
  31569. } else {
  31570. fmt.Println(err)
  31571. }
  31572. saveLog(result, src_resquest, "2208", "退费")
  31573. if strings.Contains(result, "Post") {
  31574. res.Infcode = -1
  31575. res.ErrMsg = result
  31576. }
  31577. userJSONBytes, _ := json.Marshal(dat)
  31578. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31579. utils.ErrorLog("解析失败:%v", err)
  31580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31581. return
  31582. }
  31583. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31584. res.Output = resSixteen10265.Output
  31585. res.ErrMsg = resSixteen10265.ErrMsg
  31586. res.Cainfo = resSixteen10265.Cainfo
  31587. res.WarnMsg = resSixteen10265.WarnMsg
  31588. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31589. res.Infcode = infocode
  31590. } else {
  31591. 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)
  31592. var dat map[string]interface{}
  31593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31594. fmt.Println(dat)
  31595. } else {
  31596. fmt.Println(err)
  31597. }
  31598. saveLog(result, src_resquest, "2208", "退费")
  31599. userJSONBytes, _ := json.Marshal(dat)
  31600. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31601. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31602. utils.ErrorLog("解析失败:%v", err)
  31603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31604. return
  31605. }
  31606. res.Infcode = gz.Infcode
  31607. } else {
  31608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31609. utils.ErrorLog("解析失败:%v", err)
  31610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31611. return
  31612. }
  31613. }
  31614. if strings.Contains(result, "Post") {
  31615. res.Infcode = -1
  31616. res.ErrMsg = result
  31617. }
  31618. }
  31619. }
  31620. if res.Infcode == -1 {
  31621. c.ServeSuccessJSON(map[string]interface{}{
  31622. "failed_code": -10,
  31623. "msg": res.ErrMsg,
  31624. })
  31625. return
  31626. }
  31627. if res.Infcode != -1 {
  31628. var res2 ResultSix
  31629. var resSix10265 ResultSix10265
  31630. if miConfig.MdtrtareaAdmvs == "421300" {
  31631. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31632. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31633. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31634. resp3, requestErr3 := http.Get(api3)
  31635. if requestErr3 != nil {
  31636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31637. return
  31638. }
  31639. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31640. if ioErr3 != nil {
  31641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31643. return
  31644. }
  31645. var respJSON3 map[string]interface{}
  31646. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31649. return
  31650. }
  31651. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31652. userJSONBytes3, _ := json.Marshal(respJSON3)
  31653. fmt.Println("log")
  31654. fmt.Println(string(userJSONBytes3))
  31655. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31656. utils.ErrorLog("解析失败:%v", err)
  31657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31658. return
  31659. }
  31660. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31661. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31662. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31663. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31664. resp3, requestErr3 := http.Get(api3)
  31665. if requestErr3 != nil {
  31666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31667. return
  31668. }
  31669. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31670. if ioErr3 != nil {
  31671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31673. return
  31674. }
  31675. var respJSON3 map[string]interface{}
  31676. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31679. return
  31680. }
  31681. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31682. userJSONBytes3, _ := json.Marshal(respJSON3)
  31683. fmt.Println("log")
  31684. fmt.Println(string(userJSONBytes3))
  31685. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31686. utils.ErrorLog("解析失败:%v", err)
  31687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31688. return
  31689. }
  31690. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31691. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31692. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31694. resp3, requestErr3 := http.Get(api3)
  31695. if requestErr3 != nil {
  31696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31697. return
  31698. }
  31699. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31700. if ioErr3 != nil {
  31701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31703. return
  31704. }
  31705. var respJSON3 map[string]interface{}
  31706. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31709. return
  31710. }
  31711. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31712. userJSONBytes3, _ := json.Marshal(respJSON3)
  31713. fmt.Println("log")
  31714. fmt.Println(string(userJSONBytes3))
  31715. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31716. utils.ErrorLog("解析失败:%v", err)
  31717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31718. return
  31719. }
  31720. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31721. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31722. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31723. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31724. resp3, requestErr3 := http.Get(api3)
  31725. if requestErr3 != nil {
  31726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31727. return
  31728. }
  31729. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31730. if ioErr3 != nil {
  31731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31733. return
  31734. }
  31735. var respJSON3 map[string]interface{}
  31736. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31739. return
  31740. }
  31741. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31742. userJSONBytes3, _ := json.Marshal(respJSON3)
  31743. fmt.Println("log")
  31744. fmt.Println(string(userJSONBytes3))
  31745. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31746. utils.ErrorLog("解析失败:%v", err)
  31747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31748. return
  31749. }
  31750. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31751. var api3 string
  31752. if miConfig.MdtrtareaAdmvs == "320921" {
  31753. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31754. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31755. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31756. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31757. } else {
  31758. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31759. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31760. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31761. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31762. }
  31763. resp3, requestErr3 := http.Get(api3)
  31764. if requestErr3 != nil {
  31765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31766. return
  31767. }
  31768. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31769. if ioErr3 != nil {
  31770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31772. return
  31773. }
  31774. var respJSON3 map[string]interface{}
  31775. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31778. return
  31779. }
  31780. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31781. userJSONBytes3, _ := json.Marshal(respJSON3)
  31782. fmt.Println("log")
  31783. fmt.Println(string(userJSONBytes3))
  31784. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31785. utils.ErrorLog("解析失败:%v", err)
  31786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31787. return
  31788. }
  31789. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31790. res2.Output = resSix10265.Output
  31791. res2.ErrMsg = resSix10265.ErrMsg
  31792. res2.Cainfo = resSix10265.Cainfo
  31793. res2.WarnMsg = resSix10265.WarnMsg
  31794. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31795. res2.Infcode = infocode
  31796. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31797. var api3 string
  31798. new_chrg_bchno := order.Number
  31799. if adminUser.CurrentOrgId == 10265 {
  31800. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31801. new_chrg_bchno = "0000"
  31802. }
  31803. }
  31804. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31805. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31806. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31807. resp3, requestErr3 := http.Get(api3)
  31808. if requestErr3 != nil {
  31809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31810. return
  31811. }
  31812. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31813. if ioErr3 != nil {
  31814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31816. return
  31817. }
  31818. var respJSON3 map[string]interface{}
  31819. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31822. return
  31823. }
  31824. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31825. userJSONBytes3, _ := json.Marshal(respJSON3)
  31826. fmt.Println("log")
  31827. fmt.Println(string(userJSONBytes3))
  31828. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31829. utils.ErrorLog("解析失败:%v", err)
  31830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31831. return
  31832. }
  31833. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31834. res2.Output = resSix10265.Output
  31835. res2.ErrMsg = resSix10265.ErrMsg
  31836. res2.Cainfo = resSix10265.Cainfo
  31837. res2.WarnMsg = resSix10265.WarnMsg
  31838. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31839. res2.Infcode = infocode
  31840. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31841. 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)
  31842. var dat map[string]interface{}
  31843. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31844. fmt.Println(dat)
  31845. } else {
  31846. fmt.Println(err)
  31847. }
  31848. saveLog(result2, src_request, "2205", "撤销明细")
  31849. userJSONBytes, _ := json.Marshal(dat)
  31850. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31851. utils.ErrorLog("解析失败:%v", err)
  31852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31853. return
  31854. }
  31855. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31856. 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, "")
  31857. var dat map[string]interface{}
  31858. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31859. fmt.Println(dat)
  31860. } else {
  31861. fmt.Println(err)
  31862. }
  31863. saveLog(result2, src_request, "2205", "撤销明细")
  31864. userJSONBytes, _ := json.Marshal(dat)
  31865. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31866. utils.ErrorLog("解析失败:%v", err)
  31867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31868. return
  31869. }
  31870. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31871. 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, "")
  31872. var dat map[string]interface{}
  31873. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31874. fmt.Println(dat)
  31875. } else {
  31876. fmt.Println(err)
  31877. }
  31878. saveLog(result2, src_request, "2205", "撤销明细")
  31879. userJSONBytes, _ := json.Marshal(dat)
  31880. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31881. utils.ErrorLog("解析失败:%v", err)
  31882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31883. return
  31884. }
  31885. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31886. var api3 string
  31887. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31888. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31889. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31890. resp3, requestErr3 := http.Get(api3)
  31891. if requestErr3 != nil {
  31892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31893. return
  31894. }
  31895. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31896. if ioErr3 != nil {
  31897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31899. return
  31900. }
  31901. var respJSON3 map[string]interface{}
  31902. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31905. return
  31906. }
  31907. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31908. if status == "0" {
  31909. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31910. c.ServeSuccessJSON(map[string]interface{}{
  31911. "failed_code": -10,
  31912. "msg": err_msg,
  31913. })
  31914. return
  31915. }
  31916. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31917. userJSONBytes3, _ := json.Marshal(respJSON3)
  31918. fmt.Println("log")
  31919. fmt.Println(string(userJSONBytes3))
  31920. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31921. utils.ErrorLog("解析失败:%v", err)
  31922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31923. return
  31924. }
  31925. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31926. 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, "")
  31927. var dat map[string]interface{}
  31928. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31929. fmt.Println(dat)
  31930. } else {
  31931. fmt.Println(err)
  31932. }
  31933. saveLog(result2, src_request, "2205", "撤销明细")
  31934. userJSONBytes, _ := json.Marshal(dat)
  31935. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31936. utils.ErrorLog("解析失败:%v", err)
  31937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31938. return
  31939. }
  31940. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31941. 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, "")
  31942. var dat map[string]interface{}
  31943. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31944. fmt.Println(dat)
  31945. } else {
  31946. fmt.Println(err)
  31947. }
  31948. saveLog(result2, src_request, "2205", "撤销明细")
  31949. userJSONBytes, _ := json.Marshal(dat)
  31950. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31951. utils.ErrorLog("解析失败:%v", err)
  31952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31953. return
  31954. }
  31955. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31956. var api3 string
  31957. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31958. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31960. resp3, requestErr3 := http.Get(api3)
  31961. if requestErr3 != nil {
  31962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31963. return
  31964. }
  31965. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31966. if ioErr3 != nil {
  31967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31969. return
  31970. }
  31971. var respJSON3 map[string]interface{}
  31972. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31975. return
  31976. }
  31977. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31978. if status == "0" {
  31979. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31980. c.ServeSuccessJSON(map[string]interface{}{
  31981. "failed_code": -10,
  31982. "msg": err_msg,
  31983. })
  31984. return
  31985. }
  31986. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31987. userJSONBytes3, _ := json.Marshal(respJSON3)
  31988. fmt.Println("log")
  31989. fmt.Println(string(userJSONBytes3))
  31990. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31991. utils.ErrorLog("解析失败:%v", err)
  31992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31993. return
  31994. }
  31995. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31996. 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, "")
  31997. var dat map[string]interface{}
  31998. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31999. fmt.Println(dat)
  32000. } else {
  32001. fmt.Println(err)
  32002. }
  32003. saveLog(result2, src_request, "2205", "撤销明细")
  32004. userJSONBytes, _ := json.Marshal(dat)
  32005. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32006. utils.ErrorLog("解析失败:%v", err)
  32007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32008. return
  32009. }
  32010. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32011. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32012. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32014. resp3, requestErr3 := http.Get(api3)
  32015. if requestErr3 != nil {
  32016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32017. return
  32018. }
  32019. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32020. if ioErr3 != nil {
  32021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32023. return
  32024. }
  32025. var respJSON3 map[string]interface{}
  32026. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32029. return
  32030. }
  32031. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32032. userJSONBytes3, _ := json.Marshal(respJSON3)
  32033. fmt.Println("log")
  32034. fmt.Println(string(userJSONBytes3))
  32035. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32036. utils.ErrorLog("解析失败:%v", err)
  32037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32038. return
  32039. }
  32040. } else {
  32041. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32042. res2.Infcode = 0
  32043. } else {
  32044. 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)
  32045. var dat map[string]interface{}
  32046. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32047. fmt.Println(dat)
  32048. } else {
  32049. fmt.Println(err)
  32050. }
  32051. saveLog(result2, src_request, "2205", "撤销明细")
  32052. userJSONBytes, _ := json.Marshal(dat)
  32053. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32054. utils.ErrorLog("解析失败:%v", err)
  32055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32056. return
  32057. }
  32058. }
  32059. }
  32060. if res2.Infcode == -1 {
  32061. c.ServeSuccessJSON(map[string]interface{}{
  32062. "failed_code": -10,
  32063. "msg": res2.ErrMsg,
  32064. })
  32065. return
  32066. }
  32067. if res2.Infcode == 0 {
  32068. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32069. if err == nil {
  32070. //当押金不为零时产生退费记录
  32071. if order.Decimal != 0 {
  32072. tmp := strconv.FormatInt(order.ID, 10)
  32073. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32074. if err != nil {
  32075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32076. return
  32077. }
  32078. }
  32079. c.ServeSuccessJSON(map[string]interface{}{
  32080. "msg": "退费成功",
  32081. })
  32082. } else {
  32083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32084. return
  32085. }
  32086. } else {
  32087. c.ServeSuccessJSON(map[string]interface{}{
  32088. "failed_code": -10,
  32089. "msg": res2.ErrMsg,
  32090. })
  32091. }
  32092. } else {
  32093. c.ServeSuccessJSON(map[string]interface{}{
  32094. "failed_code": -10,
  32095. "msg": res.ErrMsg,
  32096. })
  32097. }
  32098. }
  32099. }
  32100. func (c *HisApiController) RefundNumber() {
  32101. record_time := c.GetString("record_time")
  32102. //patient_id, _ := c.GetInt64("patient_id")
  32103. admin_user_id, _ := c.GetInt64("admin_user_id")
  32104. his_patient_id, _ := c.GetInt64("id")
  32105. timeLayout := "2006-01-02"
  32106. loc, _ := time.LoadLocation("Local")
  32107. adminUser := c.GetAdminUserInfo()
  32108. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32109. fmt.Println(err)
  32110. if err != nil {
  32111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32112. return
  32113. }
  32114. recordDateTime := theTime.Unix()
  32115. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32116. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32117. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32118. //order, _ := service.GetHisOrderByID(order_id)
  32119. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32120. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32121. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32122. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32123. if count > 0 {
  32124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32125. return
  32126. }
  32127. if config.IsOpen == 1 { //对接了医保,走医保流程
  32128. var res2 ResultSix
  32129. var res3 GZResultSix
  32130. var resSix10265 ResultSix10265
  32131. if miConfig.MdtrtareaAdmvs == "421300" {
  32132. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32133. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32134. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32135. resp3, requestErr3 := http.Get(api3)
  32136. if requestErr3 != nil {
  32137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32138. return
  32139. }
  32140. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32141. if ioErr3 != nil {
  32142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32144. return
  32145. }
  32146. var respJSON3 map[string]interface{}
  32147. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32150. return
  32151. }
  32152. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32153. userJSONBytes3, _ := json.Marshal(respJSON3)
  32154. fmt.Println("log")
  32155. fmt.Println(string(userJSONBytes3))
  32156. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32157. utils.ErrorLog("解析失败:%v", err)
  32158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32159. return
  32160. }
  32161. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32162. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32163. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32164. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32165. resp3, requestErr3 := http.Get(api3)
  32166. if requestErr3 != nil {
  32167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32168. return
  32169. }
  32170. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32171. if ioErr3 != nil {
  32172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32174. return
  32175. }
  32176. var respJSON3 map[string]interface{}
  32177. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32180. return
  32181. }
  32182. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32183. userJSONBytes3, _ := json.Marshal(respJSON3)
  32184. fmt.Println("log")
  32185. fmt.Println(string(userJSONBytes3))
  32186. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32187. utils.ErrorLog("解析失败:%v", err)
  32188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32189. return
  32190. }
  32191. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32192. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32193. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32194. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32195. resp3, requestErr3 := http.Get(api3)
  32196. if requestErr3 != nil {
  32197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32198. return
  32199. }
  32200. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32201. if ioErr3 != nil {
  32202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32204. return
  32205. }
  32206. var respJSON3 map[string]interface{}
  32207. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32210. return
  32211. }
  32212. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32213. userJSONBytes3, _ := json.Marshal(respJSON3)
  32214. fmt.Println("log")
  32215. fmt.Println(string(userJSONBytes3))
  32216. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32217. utils.ErrorLog("解析失败:%v", err)
  32218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32219. return
  32220. }
  32221. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32222. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32223. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32224. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32225. resp3, requestErr3 := http.Get(api3)
  32226. if requestErr3 != nil {
  32227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32228. return
  32229. }
  32230. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32231. if ioErr3 != nil {
  32232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32234. return
  32235. }
  32236. var respJSON3 map[string]interface{}
  32237. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32240. return
  32241. }
  32242. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32243. userJSONBytes3, _ := json.Marshal(respJSON3)
  32244. fmt.Println("log")
  32245. fmt.Println(string(userJSONBytes3))
  32246. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32247. utils.ErrorLog("解析失败:%v", err)
  32248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32249. return
  32250. }
  32251. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32252. var api3 string
  32253. if miConfig.MdtrtareaAdmvs == "320921" {
  32254. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32255. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32256. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32257. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32258. } else {
  32259. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32260. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32261. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32262. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32263. }
  32264. resp3, requestErr3 := http.Get(api3)
  32265. if requestErr3 != nil {
  32266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32267. return
  32268. }
  32269. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32270. if ioErr3 != nil {
  32271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32273. return
  32274. }
  32275. var respJSON3 map[string]interface{}
  32276. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32279. return
  32280. }
  32281. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32282. userJSONBytes3, _ := json.Marshal(respJSON3)
  32283. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32284. utils.ErrorLog("解析失败:%v", err)
  32285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32286. return
  32287. }
  32288. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32289. res2.Output = resSix10265.Output
  32290. res2.ErrMsg = resSix10265.ErrMsg
  32291. res2.Cainfo = resSix10265.Cainfo
  32292. res2.WarnMsg = resSix10265.WarnMsg
  32293. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32294. res2.Infcode = infocode
  32295. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32296. var api3 string
  32297. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32298. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32299. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32300. resp3, requestErr3 := http.Get(api3)
  32301. if requestErr3 != nil {
  32302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32303. return
  32304. }
  32305. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32306. if ioErr3 != nil {
  32307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32309. return
  32310. }
  32311. var respJSON3 map[string]interface{}
  32312. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32315. return
  32316. }
  32317. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32318. userJSONBytes3, _ := json.Marshal(respJSON3)
  32319. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32320. utils.ErrorLog("解析失败:%v", err)
  32321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32322. return
  32323. }
  32324. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32325. res2.Output = resSix10265.Output
  32326. res2.ErrMsg = resSix10265.ErrMsg
  32327. res2.Cainfo = resSix10265.Cainfo
  32328. res2.WarnMsg = resSix10265.WarnMsg
  32329. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32330. res2.Infcode = infocode
  32331. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32332. 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)
  32333. var dat map[string]interface{}
  32334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32335. fmt.Println(dat)
  32336. } else {
  32337. fmt.Println(err)
  32338. }
  32339. saveLog(result, request, "2202", "退号")
  32340. userJSONBytes, _ := json.Marshal(dat)
  32341. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32342. utils.ErrorLog("解析失败:%v", err)
  32343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32344. return
  32345. }
  32346. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32347. 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, "")
  32348. var dat map[string]interface{}
  32349. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32350. fmt.Println(dat)
  32351. } else {
  32352. fmt.Println(err)
  32353. }
  32354. saveLog(result, request, "2202", "退号")
  32355. userJSONBytes, _ := json.Marshal(dat)
  32356. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32357. utils.ErrorLog("解析失败:%v", err)
  32358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32359. return
  32360. }
  32361. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32362. 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, "")
  32363. var dat map[string]interface{}
  32364. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32365. fmt.Println(dat)
  32366. } else {
  32367. fmt.Println(err)
  32368. }
  32369. saveLog(result, request, "2202", "退号")
  32370. userJSONBytes, _ := json.Marshal(dat)
  32371. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32372. utils.ErrorLog("解析失败:%v", err)
  32373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32374. return
  32375. }
  32376. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32377. var api3 string
  32378. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32379. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32380. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32381. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32382. resp3, requestErr3 := http.Get(api3)
  32383. if requestErr3 != nil {
  32384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32385. return
  32386. }
  32387. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32388. if ioErr3 != nil {
  32389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32391. return
  32392. }
  32393. var respJSON3 map[string]interface{}
  32394. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32397. return
  32398. }
  32399. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32400. if status == "0" {
  32401. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32402. c.ServeSuccessJSON(map[string]interface{}{
  32403. "failed_code": -10,
  32404. "msg": err_msg,
  32405. })
  32406. return
  32407. }
  32408. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32409. userJSONBytes3, _ := json.Marshal(respJSON3)
  32410. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32411. utils.ErrorLog("解析失败:%v", err)
  32412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32413. return
  32414. }
  32415. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32416. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32417. var api3 string
  32418. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32419. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32420. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32421. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32422. resp3, requestErr3 := http.Get(api3)
  32423. if requestErr3 != nil {
  32424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32425. return
  32426. }
  32427. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32428. if ioErr3 != nil {
  32429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32431. return
  32432. }
  32433. var respJSON3 map[string]interface{}
  32434. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32437. return
  32438. }
  32439. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32440. if status == "0" {
  32441. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32442. c.ServeSuccessJSON(map[string]interface{}{
  32443. "failed_code": -10,
  32444. "msg": err_msg,
  32445. })
  32446. return
  32447. }
  32448. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32449. userJSONBytes3, _ := json.Marshal(respJSON3)
  32450. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32451. utils.ErrorLog("解析失败:%v", err)
  32452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32453. return
  32454. }
  32455. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32456. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32457. 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, "")
  32458. var dat map[string]interface{}
  32459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32460. fmt.Println(dat)
  32461. } else {
  32462. fmt.Println(err)
  32463. }
  32464. saveLog(result, request, "2202", "退号")
  32465. userJSONBytes, _ := json.Marshal(dat)
  32466. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32467. utils.ErrorLog("解析失败:%v", err)
  32468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32469. return
  32470. }
  32471. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32472. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32473. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32475. resp3, requestErr3 := http.Get(api3)
  32476. if requestErr3 != nil {
  32477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32478. return
  32479. }
  32480. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32481. if ioErr3 != nil {
  32482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32484. return
  32485. }
  32486. var respJSON3 map[string]interface{}
  32487. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32490. return
  32491. }
  32492. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32493. userJSONBytes3, _ := json.Marshal(respJSON3)
  32494. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32495. utils.ErrorLog("解析失败:%v", err)
  32496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32497. return
  32498. }
  32499. } else {
  32500. var api3 string
  32501. if miConfig.Code == "H15049901371" {
  32502. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32503. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32505. } else {
  32506. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32507. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32508. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32509. }
  32510. resp3, requestErr3 := http.Get(api3)
  32511. if requestErr3 != nil {
  32512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32513. return
  32514. }
  32515. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32516. if ioErr3 != nil {
  32517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32519. return
  32520. }
  32521. var respJSON3 map[string]interface{}
  32522. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32525. return
  32526. }
  32527. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32528. userJSONBytes3, _ := json.Marshal(respJSON3)
  32529. if miConfig.Code == "H15049901371" {
  32530. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32531. utils.ErrorLog("解析失败:%v", err)
  32532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32533. return
  32534. }
  32535. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32536. res2.Output = resSix10265.Output
  32537. res2.ErrMsg = resSix10265.ErrMsg
  32538. res2.Cainfo = resSix10265.Cainfo
  32539. res2.WarnMsg = resSix10265.WarnMsg
  32540. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32541. res2.Infcode = infocode
  32542. } else {
  32543. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32544. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32545. utils.ErrorLog("解析失败:%v", err)
  32546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32547. return
  32548. }
  32549. res2.Infcode = res3.Infcode
  32550. } else {
  32551. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32552. utils.ErrorLog("解析失败:%v", err)
  32553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32554. return
  32555. }
  32556. }
  32557. }
  32558. }
  32559. if res2.Infcode == -1 {
  32560. c.ServeSuccessJSON(map[string]interface{}{
  32561. "failed_code": -10,
  32562. "msg": res2.ErrMsg,
  32563. })
  32564. return
  32565. }
  32566. if res2.Infcode == 0 {
  32567. if err == nil {
  32568. c.ServeSuccessJSON(map[string]interface{}{
  32569. "msg": "退号成功",
  32570. })
  32571. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32572. } else {
  32573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32574. return
  32575. }
  32576. }
  32577. } else {
  32578. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32579. //if err == nil {
  32580. // c.ServeSuccessJSON(map[string]interface{}{
  32581. // "msg": "退费成功",
  32582. // })
  32583. //} else {
  32584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32585. // return
  32586. //}
  32587. }
  32588. }
  32589. func (c *HisApiController) RefundDetail() {
  32590. order_id, _ := c.GetInt64("order_id")
  32591. admin_user_id, _ := c.GetInt64("admin_user_id")
  32592. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32593. number := c.GetString("number")
  32594. record_time := c.GetString("record_time")
  32595. patient_id, _ := c.GetInt64("patient_id")
  32596. //med_type, _ := c.GetInt64("med_type")
  32597. timeLayout := "2006-01-02"
  32598. loc, _ := time.LoadLocation("Local")
  32599. adminUser := c.GetAdminUserInfo()
  32600. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32601. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32602. fmt.Println(err)
  32603. if err != nil {
  32604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32605. return
  32606. }
  32607. recordDateTime := theTime.Unix()
  32608. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32609. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32610. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32611. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32612. var order models.HisOrder
  32613. order, _ = service.GetHisOrderByID(order_id)
  32614. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32615. if config.IsOpen == 1 { //对接了医保,走医保流程
  32616. var res2 ResultSix
  32617. if miConfig.MdtrtareaAdmvs == "421300" {
  32618. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32619. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32620. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32621. resp3, requestErr3 := http.Get(api3)
  32622. if requestErr3 != nil {
  32623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32624. return
  32625. }
  32626. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32627. if ioErr3 != nil {
  32628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32630. return
  32631. }
  32632. var respJSON3 map[string]interface{}
  32633. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32636. return
  32637. }
  32638. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32639. userJSONBytes3, _ := json.Marshal(respJSON3)
  32640. fmt.Println("log")
  32641. fmt.Println(string(userJSONBytes3))
  32642. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32643. utils.ErrorLog("解析失败:%v", err)
  32644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32645. return
  32646. }
  32647. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32648. if err == nil {
  32649. c.ServeSuccessJSON(map[string]interface{}{
  32650. "msg": "撤销明细成功",
  32651. })
  32652. return
  32653. } else {
  32654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32655. return
  32656. }
  32657. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32658. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32659. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32660. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32661. resp3, requestErr3 := http.Get(api3)
  32662. if requestErr3 != nil {
  32663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32664. return
  32665. }
  32666. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32667. if ioErr3 != nil {
  32668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32670. return
  32671. }
  32672. var respJSON3 map[string]interface{}
  32673. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32676. return
  32677. }
  32678. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32679. userJSONBytes3, _ := json.Marshal(respJSON3)
  32680. fmt.Println("log")
  32681. fmt.Println(string(userJSONBytes3))
  32682. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32683. utils.ErrorLog("解析失败:%v", err)
  32684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32685. return
  32686. }
  32687. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32688. if err == nil {
  32689. c.ServeSuccessJSON(map[string]interface{}{
  32690. "msg": "撤销明细成功",
  32691. })
  32692. return
  32693. } else {
  32694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32695. return
  32696. }
  32697. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32698. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32699. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32700. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32701. resp3, requestErr3 := http.Get(api3)
  32702. if requestErr3 != nil {
  32703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32704. return
  32705. }
  32706. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32707. if ioErr3 != nil {
  32708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32710. return
  32711. }
  32712. var respJSON3 map[string]interface{}
  32713. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32716. return
  32717. }
  32718. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32719. userJSONBytes3, _ := json.Marshal(respJSON3)
  32720. fmt.Println("log")
  32721. fmt.Println(string(userJSONBytes3))
  32722. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32723. utils.ErrorLog("解析失败:%v", err)
  32724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32725. return
  32726. }
  32727. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32728. if err == nil {
  32729. c.ServeSuccessJSON(map[string]interface{}{
  32730. "msg": "撤销明细成功",
  32731. })
  32732. return
  32733. } else {
  32734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32735. return
  32736. }
  32737. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32738. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32739. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32740. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32741. resp3, requestErr3 := http.Get(api3)
  32742. if requestErr3 != nil {
  32743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32744. return
  32745. }
  32746. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32747. if ioErr3 != nil {
  32748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32750. return
  32751. }
  32752. var respJSON3 map[string]interface{}
  32753. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32756. return
  32757. }
  32758. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32759. userJSONBytes3, _ := json.Marshal(respJSON3)
  32760. fmt.Println("log")
  32761. fmt.Println(string(userJSONBytes3))
  32762. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32763. utils.ErrorLog("解析失败:%v", err)
  32764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32765. return
  32766. }
  32767. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32768. if err == nil {
  32769. c.ServeSuccessJSON(map[string]interface{}{
  32770. "msg": "撤销明细成功",
  32771. })
  32772. return
  32773. } else {
  32774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32775. return
  32776. }
  32777. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32778. var resSix10265 ResultSix10265
  32779. var api3 string
  32780. if miConfig.MdtrtareaAdmvs == "320921" {
  32781. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32782. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32784. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32785. } else {
  32786. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32787. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32788. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32790. }
  32791. resp3, requestErr3 := http.Get(api3)
  32792. utils.ErrorLog("接口: %v", requestErr3)
  32793. if requestErr3 != nil {
  32794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32795. return
  32796. }
  32797. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32798. if ioErr3 != nil {
  32799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32801. return
  32802. }
  32803. var respJSON3 map[string]interface{}
  32804. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32807. return
  32808. }
  32809. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32810. userJSONBytes3, _ := json.Marshal(respJSON3)
  32811. fmt.Println("log")
  32812. fmt.Println(string(userJSONBytes3))
  32813. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32814. utils.ErrorLog("解析失败:%v", err)
  32815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32816. return
  32817. }
  32818. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32819. res2.Output = resSix10265.Output
  32820. res2.ErrMsg = resSix10265.ErrMsg
  32821. res2.Cainfo = resSix10265.Cainfo
  32822. res2.WarnMsg = resSix10265.WarnMsg
  32823. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32824. res2.Infcode = infocode
  32825. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32826. if err == nil {
  32827. c.ServeSuccessJSON(map[string]interface{}{
  32828. "msg": "撤销明细成功",
  32829. })
  32830. return
  32831. } else {
  32832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32833. return
  32834. }
  32835. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32836. var api3 string
  32837. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32838. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32840. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32841. resp3, requestErr3 := http.Get(api3)
  32842. utils.ErrorLog("接口: %v", requestErr3)
  32843. if requestErr3 != nil {
  32844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32845. return
  32846. }
  32847. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32848. if ioErr3 != nil {
  32849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32851. return
  32852. }
  32853. var respJSON3 map[string]interface{}
  32854. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32857. return
  32858. }
  32859. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32860. if status == "0" {
  32861. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32862. c.ServeSuccessJSON(map[string]interface{}{
  32863. "failed_code": -10,
  32864. "msg": err_msg,
  32865. })
  32866. return
  32867. }
  32868. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32869. userJSONBytes3, _ := json.Marshal(respJSON3)
  32870. fmt.Println("log")
  32871. fmt.Println(string(userJSONBytes3))
  32872. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32873. utils.ErrorLog("解析失败:%v", err)
  32874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32875. return
  32876. }
  32877. fmt.Println(res2.Infcode)
  32878. if res2.Infcode == -1 {
  32879. c.ServeSuccessJSON(map[string]interface{}{
  32880. "failed_code": -10,
  32881. "msg": res2.ErrMsg,
  32882. })
  32883. return
  32884. }
  32885. if res2.Infcode == 0 {
  32886. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32887. if err == nil {
  32888. c.ServeSuccessJSON(map[string]interface{}{
  32889. "msg": "撤销明细成功",
  32890. })
  32891. return
  32892. } else {
  32893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32894. return
  32895. }
  32896. } else {
  32897. c.ServeSuccessJSON(map[string]interface{}{
  32898. "failed_code": -10,
  32899. "msg": res2.ErrMsg,
  32900. })
  32901. }
  32902. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32903. if err == nil {
  32904. c.ServeSuccessJSON(map[string]interface{}{
  32905. "msg": "撤销明细成功",
  32906. })
  32907. return
  32908. } else {
  32909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32910. return
  32911. }
  32912. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32913. var api3 string
  32914. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32915. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32916. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32917. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32918. resp3, requestErr3 := http.Get(api3)
  32919. utils.ErrorLog("接口: %v", requestErr3)
  32920. if requestErr3 != nil {
  32921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32922. return
  32923. }
  32924. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32925. if ioErr3 != nil {
  32926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32928. return
  32929. }
  32930. var respJSON3 map[string]interface{}
  32931. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32934. return
  32935. }
  32936. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32937. if status == "0" {
  32938. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32939. c.ServeSuccessJSON(map[string]interface{}{
  32940. "failed_code": -10,
  32941. "msg": err_msg,
  32942. })
  32943. return
  32944. }
  32945. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32946. userJSONBytes3, _ := json.Marshal(respJSON3)
  32947. fmt.Println("log")
  32948. fmt.Println(string(userJSONBytes3))
  32949. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32950. utils.ErrorLog("解析失败:%v", err)
  32951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32952. return
  32953. }
  32954. fmt.Println(res2.Infcode)
  32955. if res2.Infcode == -1 {
  32956. c.ServeSuccessJSON(map[string]interface{}{
  32957. "failed_code": -10,
  32958. "msg": res2.ErrMsg,
  32959. })
  32960. return
  32961. }
  32962. if res2.Infcode == 0 {
  32963. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32964. if err == nil {
  32965. c.ServeSuccessJSON(map[string]interface{}{
  32966. "msg": "撤销明细成功",
  32967. })
  32968. return
  32969. } else {
  32970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32971. return
  32972. }
  32973. } else {
  32974. c.ServeSuccessJSON(map[string]interface{}{
  32975. "failed_code": -10,
  32976. "msg": res2.ErrMsg,
  32977. })
  32978. }
  32979. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32980. if err == nil {
  32981. c.ServeSuccessJSON(map[string]interface{}{
  32982. "msg": "撤销明细成功",
  32983. })
  32984. return
  32985. } else {
  32986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32987. return
  32988. }
  32989. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32990. var resSix10265 ResultSix10265
  32991. new_chrg_bchno := order.Number
  32992. if adminUser.CurrentOrgId == 10265 {
  32993. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32994. new_chrg_bchno = "0000"
  32995. }
  32996. }
  32997. var api3 string
  32998. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32999. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33000. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33001. resp3, requestErr3 := http.Get(api3)
  33002. if requestErr3 != nil {
  33003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33004. return
  33005. }
  33006. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33007. if ioErr3 != nil {
  33008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33010. return
  33011. }
  33012. var respJSON3 map[string]interface{}
  33013. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33016. return
  33017. }
  33018. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33019. userJSONBytes3, _ := json.Marshal(respJSON3)
  33020. fmt.Println("log")
  33021. fmt.Println(string(userJSONBytes3))
  33022. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33023. utils.ErrorLog("解析失败:%v", err)
  33024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33025. return
  33026. }
  33027. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33028. res2.Output = resSix10265.Output
  33029. res2.ErrMsg = resSix10265.ErrMsg
  33030. res2.Cainfo = resSix10265.Cainfo
  33031. res2.WarnMsg = resSix10265.WarnMsg
  33032. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33033. res2.Infcode = infocode
  33034. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33035. if err == nil {
  33036. c.ServeSuccessJSON(map[string]interface{}{
  33037. "msg": "撤销明细成功",
  33038. })
  33039. return
  33040. } else {
  33041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33042. return
  33043. }
  33044. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33045. 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)
  33046. var dat map[string]interface{}
  33047. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33048. fmt.Println(dat)
  33049. } else {
  33050. fmt.Println(err)
  33051. }
  33052. saveLog(result2, src_request, "2205", "撤销明细")
  33053. userJSONBytes, _ := json.Marshal(dat)
  33054. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33055. utils.ErrorLog("解析失败:%v", err)
  33056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33057. return
  33058. }
  33059. if res2.Infcode == 0 {
  33060. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33061. if err == nil {
  33062. c.ServeSuccessJSON(map[string]interface{}{
  33063. "msg": "撤销明细成功",
  33064. })
  33065. return
  33066. } else {
  33067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33068. return
  33069. }
  33070. } else {
  33071. c.ServeSuccessJSON(map[string]interface{}{
  33072. "failed_code": -10,
  33073. "msg": res2.ErrMsg,
  33074. })
  33075. }
  33076. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33077. 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, "")
  33078. var dat map[string]interface{}
  33079. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33080. fmt.Println(dat)
  33081. } else {
  33082. fmt.Println(err)
  33083. }
  33084. saveLog(result2, src_request, "2205", "撤销明细")
  33085. userJSONBytes, _ := json.Marshal(dat)
  33086. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33087. utils.ErrorLog("解析失败:%v", err)
  33088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33089. return
  33090. }
  33091. if res2.Infcode == 0 {
  33092. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33093. if err == nil {
  33094. c.ServeSuccessJSON(map[string]interface{}{
  33095. "msg": "撤销明细成功",
  33096. })
  33097. return
  33098. } else {
  33099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33100. return
  33101. }
  33102. } else {
  33103. c.ServeSuccessJSON(map[string]interface{}{
  33104. "failed_code": -10,
  33105. "msg": res2.ErrMsg,
  33106. })
  33107. }
  33108. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33109. 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, "")
  33110. var dat map[string]interface{}
  33111. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33112. fmt.Println(dat)
  33113. } else {
  33114. fmt.Println(err)
  33115. }
  33116. saveLog(result2, src_request, "2205", "撤销明细")
  33117. userJSONBytes, _ := json.Marshal(dat)
  33118. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33119. utils.ErrorLog("解析失败:%v", err)
  33120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33121. return
  33122. }
  33123. if res2.Infcode == 0 {
  33124. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33125. if err == nil {
  33126. c.ServeSuccessJSON(map[string]interface{}{
  33127. "msg": "撤销明细成功",
  33128. })
  33129. return
  33130. } else {
  33131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33132. return
  33133. }
  33134. } else {
  33135. c.ServeSuccessJSON(map[string]interface{}{
  33136. "failed_code": -10,
  33137. "msg": res2.ErrMsg,
  33138. })
  33139. }
  33140. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33141. 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, "")
  33142. var dat map[string]interface{}
  33143. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33144. fmt.Println(dat)
  33145. } else {
  33146. fmt.Println(err)
  33147. }
  33148. saveLog(result2, src_request, "2205", "撤销明细")
  33149. userJSONBytes, _ := json.Marshal(dat)
  33150. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33151. utils.ErrorLog("解析失败:%v", err)
  33152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33153. return
  33154. }
  33155. if res2.Infcode == 0 {
  33156. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33157. if err == nil {
  33158. c.ServeSuccessJSON(map[string]interface{}{
  33159. "msg": "撤销明细成功",
  33160. })
  33161. return
  33162. } else {
  33163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33164. return
  33165. }
  33166. } else {
  33167. c.ServeSuccessJSON(map[string]interface{}{
  33168. "failed_code": -10,
  33169. "msg": res2.ErrMsg,
  33170. })
  33171. }
  33172. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33173. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33174. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33175. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33176. resp2, requestErr2 := http.Get(api2)
  33177. if requestErr2 != nil {
  33178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33179. return
  33180. }
  33181. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33182. if ioErr2 != nil {
  33183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33185. return
  33186. }
  33187. var respJSON2 map[string]interface{}
  33188. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33191. return
  33192. }
  33193. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33194. userJSONBytes3, _ := json.Marshal(respJSON2)
  33195. fmt.Println("log")
  33196. fmt.Println(string(userJSONBytes3))
  33197. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33198. utils.ErrorLog("解析失败:%v", err)
  33199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33200. return
  33201. }
  33202. if res2.Infcode == 0 {
  33203. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33204. if err == nil {
  33205. c.ServeSuccessJSON(map[string]interface{}{
  33206. "msg": "撤销明细成功",
  33207. })
  33208. return
  33209. } else {
  33210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33211. return
  33212. }
  33213. } else {
  33214. c.ServeSuccessJSON(map[string]interface{}{
  33215. "failed_code": -10,
  33216. "msg": res2.ErrMsg,
  33217. })
  33218. }
  33219. } else {
  33220. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33221. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33223. resp2, requestErr2 := http.Get(api2)
  33224. if requestErr2 != nil {
  33225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33226. return
  33227. }
  33228. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33229. if ioErr2 != nil {
  33230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33232. return
  33233. }
  33234. var respJSON2 map[string]interface{}
  33235. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33238. return
  33239. }
  33240. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33241. userJSONBytes3, _ := json.Marshal(respJSON2)
  33242. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33243. utils.ErrorLog("解析失败:%v", err)
  33244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33245. return
  33246. }
  33247. if res2.Infcode == -1 {
  33248. c.ServeSuccessJSON(map[string]interface{}{
  33249. "failed_code": -10,
  33250. "msg": res2.ErrMsg,
  33251. })
  33252. return
  33253. } else {
  33254. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33255. if err == nil {
  33256. c.ServeSuccessJSON(map[string]interface{}{
  33257. "msg": "撤销明细成功",
  33258. })
  33259. return
  33260. } else {
  33261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33262. return
  33263. }
  33264. }
  33265. }
  33266. } else {
  33267. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33268. if err == nil {
  33269. c.ServeSuccessJSON(map[string]interface{}{
  33270. "msg": "退费成功",
  33271. })
  33272. } else {
  33273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33274. return
  33275. }
  33276. }
  33277. }
  33278. // 对账
  33279. func (c *HisApiController) GetCheckAccount() {
  33280. start_time := c.GetString("start_time")
  33281. end_time := c.GetString("end_time")
  33282. insutype := c.GetString("insutype")
  33283. clr_type := c.GetString("clr_type")
  33284. clr_org := c.GetString("clr_optins")
  33285. admin_user_id, _ := c.GetInt64("admin_user_id")
  33286. adminUser := c.GetAdminUserInfo()
  33287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33288. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33289. if len(clr_org) == 0 {
  33290. clr_org = miConfig.InsuplcAdmdvs
  33291. }
  33292. timeLayout := "2006-01-02"
  33293. loc, _ := time.LoadLocation("Local")
  33294. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33295. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33296. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33297. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33298. fixmedins_setl_cnt := int64(len(orders))
  33299. var medfee_sumamt float64
  33300. var acct_pay float64
  33301. var fund_pay_sumamt float64
  33302. for _, item := range orders {
  33303. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33304. acct_pay = acct_pay + item.AcctPay
  33305. if miConfig.MdtrtareaAdmvs == "361025" {
  33306. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  33307. } else {
  33308. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33309. }
  33310. }
  33311. var user_name string
  33312. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33313. if role.ID == 0 {
  33314. user_name = "xxx"
  33315. } else {
  33316. user_name = role.UserName
  33317. }
  33318. var res ResultEight
  33319. var res10188 ResultEightFor10188
  33320. if config.IsOpen == 1 {
  33321. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33322. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33323. "insutype=" + insutype +
  33324. "&clr_type=" + clr_type +
  33325. "&setl_optins=" + clr_org +
  33326. "&stmt_begndate=" + start_time +
  33327. "&stm_enddate=" + end_time +
  33328. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33329. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33330. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33331. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33332. "&fixmedins_code=" + miConfig.Code +
  33333. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33334. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33335. "&secret_key=" + miConfig.SecretKey +
  33336. "&org_name=" + miConfig.OrgName +
  33337. "&doctor=" + user_name +
  33338. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33339. fmt.Println(api)
  33340. resp, requestErr := http.Get(api)
  33341. if requestErr != nil {
  33342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33343. return
  33344. }
  33345. body, ioErr := ioutil.ReadAll(resp.Body)
  33346. fmt.Println(body)
  33347. if ioErr != nil {
  33348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33350. return
  33351. }
  33352. var respJSON map[string]interface{}
  33353. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33356. return
  33357. }
  33358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33359. userJSONBytes, _ := json.Marshal(respJSON)
  33360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33361. utils.ErrorLog("解析失败:%v", err)
  33362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33363. return
  33364. }
  33365. res.InfRefmsgid = res10188.InfRefmsgid
  33366. res.Output = res10188.Output
  33367. res.ErrMsg = res10188.ErrMsg
  33368. res.Cainfo = res10188.Cainfo
  33369. res.WarnMsg = res10188.WarnMsg
  33370. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33371. res.Infcode = infocode
  33372. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33373. if clr_type != "9903" {
  33374. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33375. }
  33376. if clr_type == "9903" {
  33377. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33378. }
  33379. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33380. "insutype=" + insutype +
  33381. "&clr_type=" + clr_type +
  33382. "&setl_optins=" + clr_org +
  33383. "&stmt_begndate=" + start_time +
  33384. "&stm_enddate=" + end_time +
  33385. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33386. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33387. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33388. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33389. "&fixmedins_code=" + miConfig.Code +
  33390. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33391. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33392. "&secret_key=" + miConfig.SecretKey +
  33393. "&org_name=" + miConfig.OrgName +
  33394. "&doctor=" + user_name
  33395. resp, requestErr := http.Get(api)
  33396. if requestErr != nil {
  33397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33398. return
  33399. }
  33400. body, ioErr := ioutil.ReadAll(resp.Body)
  33401. if ioErr != nil {
  33402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33404. return
  33405. }
  33406. var respJSON map[string]interface{}
  33407. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33410. return
  33411. }
  33412. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33413. result, _ := json.Marshal(respJSON)
  33414. fmt.Println("log")
  33415. fmt.Println(string(result))
  33416. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33417. utils.ErrorLog("解析失败:%v", err)
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. res.InfRefmsgid = res10188.InfRefmsgid
  33422. res.Output = res10188.Output
  33423. res.ErrMsg = res10188.ErrMsg
  33424. res.Cainfo = res10188.Cainfo
  33425. res.WarnMsg = res10188.WarnMsg
  33426. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33427. res.Infcode = infocode
  33428. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33429. var baseParams models.BaseParams
  33430. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33431. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33432. baseParams.SecretKey = miConfig.SecretKey
  33433. baseParams.OrgName = miConfig.OrgName
  33434. baseParams.FixmedinsCode = miConfig.Code
  33435. baseParams.EncKey = miConfig.EncKey
  33436. baseParams.AppSecret = miConfig.AppSecret
  33437. baseParams.SignKey = miConfig.SignKey
  33438. baseParams.AppID = miConfig.Code
  33439. baseParams.Doctor = role.UserName
  33440. baseParams.RequestUrl = miConfig.Url
  33441. businessParams := models.BusinessParams{
  33442. Insutype: insutype,
  33443. ClrType: clr_type,
  33444. SetlOptins: clr_org,
  33445. StmtBegndate: start_time,
  33446. StmtEnddate: end_time,
  33447. MedfeeSumamt: medfee_sumamt,
  33448. FundPaySumamt: fund_pay_sumamt,
  33449. AcctPay: acct_pay,
  33450. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33451. }
  33452. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33453. fmt.Println(requestLog)
  33454. fmt.Println(result)
  33455. fmt.Println(err_msg)
  33456. var dat map[string]interface{}
  33457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33458. fmt.Println(dat)
  33459. } else {
  33460. fmt.Println(err)
  33461. }
  33462. userJSONBytes, _ := json.Marshal(dat)
  33463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33464. utils.ErrorLog("解析失败:%v", err)
  33465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33466. return
  33467. }
  33468. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33469. var baseParams models.BaseParams
  33470. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33471. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33472. baseParams.SecretKey = miConfig.SecretKey
  33473. baseParams.OrgName = miConfig.OrgName
  33474. baseParams.FixmedinsCode = miConfig.Code
  33475. baseParams.EncKey = miConfig.EncKey
  33476. baseParams.AppSecret = miConfig.AppSecret
  33477. baseParams.SignKey = miConfig.SignKey
  33478. baseParams.AppID = miConfig.Code
  33479. baseParams.Doctor = role.UserName
  33480. baseParams.RequestUrl = miConfig.Url
  33481. baseParams.AccessKey = miConfig.AccessKey
  33482. businessParams := models.BusinessParams{
  33483. Insutype: insutype,
  33484. ClrType: clr_type,
  33485. SetlOptins: "430822",
  33486. StmtBegndate: start_time,
  33487. StmtEnddate: end_time,
  33488. MedfeeSumamt: medfee_sumamt,
  33489. FundPaySumamt: fund_pay_sumamt,
  33490. AcctPay: acct_pay,
  33491. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33492. }
  33493. 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)
  33494. fmt.Println(requestLog)
  33495. fmt.Println(result)
  33496. var dat map[string]interface{}
  33497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33498. fmt.Println(dat)
  33499. } else {
  33500. fmt.Println(err)
  33501. }
  33502. userJSONBytes, _ := json.Marshal(dat)
  33503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33504. utils.ErrorLog("解析失败:%v", err)
  33505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33506. return
  33507. }
  33508. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33509. var baseParams models.BaseParams
  33510. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33511. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33512. baseParams.SecretKey = miConfig.SecretKey
  33513. baseParams.OrgName = miConfig.OrgName
  33514. baseParams.FixmedinsCode = miConfig.Code
  33515. baseParams.EncKey = miConfig.EncKey
  33516. baseParams.AppSecret = miConfig.AppSecret
  33517. baseParams.SignKey = miConfig.SignKey
  33518. baseParams.AppID = miConfig.Code
  33519. baseParams.Doctor = role.UserName
  33520. baseParams.RequestUrl = miConfig.Url
  33521. businessParams := models.BusinessParams{
  33522. Insutype: insutype,
  33523. ClrType: clr_type,
  33524. SetlOptins: clr_org,
  33525. StmtBegndate: start_time,
  33526. StmtEnddate: end_time,
  33527. MedfeeSumamt: medfee_sumamt,
  33528. FundPaySumamt: fund_pay_sumamt,
  33529. AcctPay: acct_pay,
  33530. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33531. }
  33532. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33533. fmt.Println(requestLog)
  33534. fmt.Println(result)
  33535. fmt.Println(err_msg)
  33536. var dat map[string]interface{}
  33537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33538. fmt.Println(dat)
  33539. } else {
  33540. fmt.Println(err)
  33541. }
  33542. userJSONBytes, _ := json.Marshal(dat)
  33543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33544. utils.ErrorLog("解析失败:%v", err)
  33545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33546. return
  33547. }
  33548. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33549. if len(clr_type) == 0 {
  33550. clr_type = "11"
  33551. }
  33552. api := miConfig.Url + "gdyb/ten?" +
  33553. "insutype=" + insutype +
  33554. "&clr_type=" + clr_type +
  33555. "&setl_optins=" + clr_org +
  33556. "&stmt_begndate=" + start_time +
  33557. "&stm_enddate=" + end_time +
  33558. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33559. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33560. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33561. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33562. "&fixmedins_code=" + miConfig.Code +
  33563. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33564. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33565. "&secret_key=" + miConfig.SecretKey +
  33566. "&org_name=" + miConfig.OrgName +
  33567. "&doctor=" + user_name
  33568. fmt.Println(api)
  33569. resp, requestErr := http.Get(api)
  33570. if requestErr != nil {
  33571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33572. return
  33573. }
  33574. body, ioErr := ioutil.ReadAll(resp.Body)
  33575. fmt.Println(body)
  33576. if ioErr != nil {
  33577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33579. return
  33580. }
  33581. var respJSON map[string]interface{}
  33582. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33585. return
  33586. }
  33587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33588. userJSONBytes, _ := json.Marshal(respJSON)
  33589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33590. utils.ErrorLog("解析失败:%v", err)
  33591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33592. return
  33593. }
  33594. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33595. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33596. //fixmedins_setl_cnt := int64(len(orders_two))
  33597. //var medfee_sumamt float64
  33598. //var acct_pay float64
  33599. //var fund_pay_sumamt float64
  33600. //for _, item := range orders_two {
  33601. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33602. // acct_pay = acct_pay + item.AcctPay
  33603. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33604. //}
  33605. var baseParams models.BaseParams
  33606. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33607. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33608. baseParams.SecretKey = miConfig.SecretKey
  33609. baseParams.OrgName = miConfig.OrgName
  33610. baseParams.FixmedinsCode = miConfig.Code
  33611. baseParams.EncKey = miConfig.EncKey
  33612. baseParams.AppSecret = miConfig.AppSecret
  33613. baseParams.SignKey = miConfig.SignKey
  33614. baseParams.AppID = miConfig.Code
  33615. baseParams.Doctor = role.UserName
  33616. baseParams.RequestUrl = miConfig.Url
  33617. if clr_type == "9903" {
  33618. clr_type = "9994"
  33619. }
  33620. businessParams := models.BusinessParams{
  33621. Insutype: insutype,
  33622. ClrType: clr_type,
  33623. SetlOptins: "360302",
  33624. StmtBegndate: start_time,
  33625. StmtEnddate: end_time,
  33626. MedfeeSumamt: 0,
  33627. FundPaySumamt: 0,
  33628. AcctPay: 0,
  33629. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33630. }
  33631. 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))
  33632. fmt.Println(requestLog)
  33633. fmt.Println(result)
  33634. var dat map[string]interface{}
  33635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33636. fmt.Println(dat)
  33637. } else {
  33638. fmt.Println(err)
  33639. }
  33640. userJSONBytes, _ := json.Marshal(dat)
  33641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33642. utils.ErrorLog("解析失败:%v", err)
  33643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33644. return
  33645. }
  33646. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33647. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33648. //fixmedins_setl_cnt := int64(len(orders_two))
  33649. //var medfee_sumamt float64
  33650. //var acct_pay float64
  33651. //var fund_pay_sumamt float64
  33652. //for _, item := range orders_two {
  33653. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33654. // acct_pay = acct_pay + item.AcctPay
  33655. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33656. //}
  33657. var baseParams models.BaseParams
  33658. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33659. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33660. baseParams.SecretKey = miConfig.SecretKey
  33661. baseParams.OrgName = miConfig.OrgName
  33662. baseParams.FixmedinsCode = miConfig.Code
  33663. baseParams.EncKey = miConfig.EncKey
  33664. baseParams.AppSecret = miConfig.AppSecret
  33665. baseParams.SignKey = miConfig.SignKey
  33666. baseParams.AppID = miConfig.Code
  33667. baseParams.Doctor = role.UserName
  33668. baseParams.RequestUrl = miConfig.Url
  33669. if clr_type == "9903" {
  33670. clr_type = "9994"
  33671. }
  33672. businessParams := models.BusinessParams{
  33673. Insutype: insutype,
  33674. ClrType: clr_type,
  33675. SetlOptins: "361025",
  33676. StmtBegndate: start_time,
  33677. StmtEnddate: end_time,
  33678. MedfeeSumamt: 0,
  33679. FundPaySumamt: 0,
  33680. AcctPay: 0,
  33681. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33682. }
  33683. result, requestLog := service.Jxyb32012(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))
  33684. fmt.Println(requestLog)
  33685. fmt.Println(result)
  33686. var dat map[string]interface{}
  33687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33688. fmt.Println(dat)
  33689. } else {
  33690. fmt.Println(err)
  33691. }
  33692. userJSONBytes, _ := json.Marshal(dat)
  33693. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33694. utils.ErrorLog("解析失败:%v", err)
  33695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33696. return
  33697. }
  33698. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33699. var api string
  33700. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33701. "&clr_type=" + clr_type +
  33702. "&setl_optins=" + clr_org +
  33703. "&stmt_begndate=" + start_time +
  33704. "&stm_enddate=" + end_time +
  33705. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33706. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33707. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33708. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33709. "&fixmedins_code=" + miConfig.Code +
  33710. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33711. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33712. "&secret_key=" + miConfig.SecretKey +
  33713. "&org_name=" + miConfig.OrgName +
  33714. "&doctor=" + user_name + "&url=" + miConfig.Url
  33715. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33716. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33717. resp, requestErr := http.Get(api)
  33718. if requestErr != nil {
  33719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33720. return
  33721. }
  33722. body, ioErr := ioutil.ReadAll(resp.Body)
  33723. if ioErr != nil {
  33724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33726. return
  33727. }
  33728. var respJSON map[string]interface{}
  33729. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33732. return
  33733. }
  33734. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33735. if status == "0" {
  33736. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33737. c.ServeSuccessJSON(map[string]interface{}{
  33738. "failed_code": -10,
  33739. "msg": err_msg,
  33740. })
  33741. return
  33742. }
  33743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33744. userJSONBytes, _ := json.Marshal(respJSON)
  33745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33746. utils.ErrorLog("解析失败:%v", err)
  33747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33748. return
  33749. }
  33750. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33751. var api string
  33752. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33753. "&clr_type=" + clr_type +
  33754. "&setl_optins=" + clr_org +
  33755. "&stmt_begndate=" + start_time +
  33756. "&stm_enddate=" + end_time +
  33757. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33758. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33759. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33760. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33761. "&fixmedins_code=" + miConfig.Code +
  33762. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33763. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33764. "&secret_key=" + miConfig.SecretKey +
  33765. "&org_name=" + miConfig.OrgName +
  33766. "&doctor=" + user_name + "&url=" + miConfig.Url
  33767. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33768. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33769. resp, requestErr := http.Get(api)
  33770. if requestErr != nil {
  33771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33772. return
  33773. }
  33774. body, ioErr := ioutil.ReadAll(resp.Body)
  33775. if ioErr != nil {
  33776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33778. return
  33779. }
  33780. var respJSON map[string]interface{}
  33781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33784. return
  33785. }
  33786. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33787. if status == "0" {
  33788. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33789. c.ServeSuccessJSON(map[string]interface{}{
  33790. "failed_code": -10,
  33791. "msg": err_msg,
  33792. })
  33793. return
  33794. }
  33795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33796. userJSONBytes, _ := json.Marshal(respJSON)
  33797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33798. utils.ErrorLog("解析失败:%v", err)
  33799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33800. return
  33801. }
  33802. } else {
  33803. if len(clr_type) == 0 {
  33804. clr_type = "11"
  33805. }
  33806. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33807. "insutype=" + insutype +
  33808. "&clr_type=" + clr_type +
  33809. "&setl_optins=" + clr_org +
  33810. "&stmt_begndate=" + start_time +
  33811. "&stm_enddate=" + end_time +
  33812. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33813. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33814. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33815. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33816. "&fixmedins_code=" + miConfig.Code +
  33817. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33818. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33819. "&secret_key=" + miConfig.SecretKey +
  33820. "&org_name=" + miConfig.OrgName +
  33821. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33822. fmt.Println(api)
  33823. resp, requestErr := http.Get(api)
  33824. if requestErr != nil {
  33825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33826. return
  33827. }
  33828. body, ioErr := ioutil.ReadAll(resp.Body)
  33829. fmt.Println(body)
  33830. if ioErr != nil {
  33831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33833. return
  33834. }
  33835. var respJSON map[string]interface{}
  33836. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33839. return
  33840. }
  33841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33842. userJSONBytes, _ := json.Marshal(respJSON)
  33843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33844. utils.ErrorLog("解析失败:%v", err)
  33845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33846. return
  33847. }
  33848. }
  33849. if res.Infcode == 0 {
  33850. if res.Output.Stmtinfo.StmtRslt == "0" {
  33851. micc := &models.MedicalInsuranceCostCompare{
  33852. StartTime: startime.Unix(),
  33853. EndTime: endtime.Unix(),
  33854. Insutype: insutype,
  33855. CheckType: 1,
  33856. Num: fixmedins_setl_cnt,
  33857. Mtime: time.Now().Unix(),
  33858. Status: 1,
  33859. UserOrgId: adminUser.CurrentOrgId,
  33860. CostTotal: medfee_sumamt,
  33861. FuncTotal: fund_pay_sumamt,
  33862. PsnPay: acct_pay,
  33863. Creator: admin_user_id,
  33864. Ctime: time.Now().Unix(),
  33865. ClrType: clr_type,
  33866. }
  33867. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33868. if err == nil {
  33869. c.ServeSuccessJSON(map[string]interface{}{
  33870. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33871. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33872. })
  33873. } else {
  33874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33875. }
  33876. } else {
  33877. c.ServeSuccessJSON(map[string]interface{}{
  33878. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33879. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33880. })
  33881. }
  33882. } else {
  33883. c.ServeSuccessJSON(map[string]interface{}{
  33884. "failed_code": -10,
  33885. "msg": res.ErrMsg,
  33886. })
  33887. }
  33888. }
  33889. }
  33890. func (c *HisApiController) Check310() {
  33891. adminUser := c.GetAdminUserInfo()
  33892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33893. var user_name string
  33894. user_name = "高慧裕"
  33895. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33896. "insutype=" + "310" +
  33897. "&clr_type=" + "" +
  33898. "&setl_optins=" + "441202" +
  33899. "&stmt_begndate=" + "2022-03-01" +
  33900. "&stm_enddate=" + "2022-03-31" +
  33901. "&medfee_sumamt=" + "194930.12" +
  33902. "&fund_pay_sumamt=" + "188741.46" +
  33903. "&acct_pay=" + "0" +
  33904. "&fixmedins_setl_cnt=" + "452" +
  33905. "&fixmedins_code=" + miConfig.Code +
  33906. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33907. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33908. "&secret_key=" + miConfig.SecretKey +
  33909. "&org_name=" + miConfig.OrgName +
  33910. "&doctor=" + user_name
  33911. fmt.Println(api)
  33912. resp, requestErr := http.Get(api)
  33913. if requestErr != nil {
  33914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33915. return
  33916. }
  33917. body, ioErr := ioutil.ReadAll(resp.Body)
  33918. fmt.Println(body)
  33919. if ioErr != nil {
  33920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33922. return
  33923. }
  33924. var respJSON map[string]interface{}
  33925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33928. return
  33929. }
  33930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33931. userJSONBytes, _ := json.Marshal(respJSON)
  33932. var res ResultEight
  33933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33934. utils.ErrorLog("解析失败:%v", err)
  33935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33936. return
  33937. }
  33938. }
  33939. func (c *HisApiController) Check390() {
  33940. adminUser := c.GetAdminUserInfo()
  33941. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33942. var user_name string
  33943. user_name = "高慧裕"
  33944. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33945. "insutype=" + "390" +
  33946. "&clr_type=" + "" +
  33947. "&setl_optins=" + "441202" +
  33948. "&stmt_begndate=" + "2022-03-01" +
  33949. "&stm_enddate=" + "2022-03-31" +
  33950. "&medfee_sumamt=" + "1068448.89" +
  33951. "&fund_pay_sumamt=" + "1014677.62" +
  33952. "&acct_pay=" + "0" +
  33953. "&fixmedins_setl_cnt=" + "1950" +
  33954. "&fixmedins_code=" + miConfig.Code +
  33955. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33956. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33957. "&secret_key=" + miConfig.SecretKey +
  33958. "&org_name=" + miConfig.OrgName +
  33959. "&doctor=" + user_name
  33960. fmt.Println(api)
  33961. resp, requestErr := http.Get(api)
  33962. if requestErr != nil {
  33963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33964. return
  33965. }
  33966. body, ioErr := ioutil.ReadAll(resp.Body)
  33967. fmt.Println(body)
  33968. if ioErr != nil {
  33969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33971. return
  33972. }
  33973. var respJSON map[string]interface{}
  33974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33977. return
  33978. }
  33979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33980. userJSONBytes, _ := json.Marshal(respJSON)
  33981. var res ResultEight
  33982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33983. utils.ErrorLog("解析失败:%v", err)
  33984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33985. return
  33986. }
  33987. }
  33988. // 对账明细
  33989. func (c *HisApiController) GetCheckDetailAccount() {
  33990. start_time := c.GetString("start_time")
  33991. end_time := c.GetString("end_time")
  33992. admin_user_id, _ := c.GetInt64("admin_user_id")
  33993. adminUser := c.GetAdminUserInfo()
  33994. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33995. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33996. timeLayout := "2006-01-02"
  33997. loc, _ := time.LoadLocation("Local")
  33998. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33999. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34000. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34001. rand.Seed(time.Now().UnixNano())
  34002. num := rand.Intn(30000)
  34003. Mkdir(miConfig.OrgName)
  34004. file := strconv.FormatInt(int64(num), 10)
  34005. file_name := file + ".txt"
  34006. zip_name := file + ".zip"
  34007. zip_path := miConfig.OrgName + "/" + zip_name
  34008. file_path := miConfig.OrgName + "/" + file_name
  34009. decimal.DivisionPrecision = 2
  34010. var medfee_sumamt float64
  34011. var psn_cash_pay float64
  34012. var fund_pay_sumamt float64
  34013. fixmedins_setl_cnt := int64(len(orders))
  34014. for _, item := range orders {
  34015. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34016. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34017. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34018. }
  34019. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34020. defer f.Close()
  34021. if err != nil {
  34022. fmt.Println(err.Error())
  34023. } else {
  34024. for _, item := range orders {
  34025. var refd_setl_flag string
  34026. if item.OrderStatus == 2 {
  34027. refd_setl_flag = "0"
  34028. var str string
  34029. str = item.SetlId + " " +
  34030. item.MdtrtId + " " +
  34031. item.PsnNo + " " +
  34032. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34033. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34034. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34035. _, err = f.Write([]byte(str))
  34036. }
  34037. if item.OrderStatus == 3 {
  34038. var str string
  34039. str = item.SetlId + " " +
  34040. item.MdtrtId + " " +
  34041. item.PsnNo + " " +
  34042. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34043. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34044. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34045. _, err = f.Write([]byte(str))
  34046. var str2 string
  34047. str2 = item.SetlId + " " +
  34048. item.MdtrtId + " " +
  34049. item.PsnNo + " " +
  34050. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34051. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34052. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34053. _, err = f.Write([]byte(str2))
  34054. }
  34055. }
  34056. }
  34057. Zip(file_path, zip_path)
  34058. fmt.Println(ReadFile(zip_path))
  34059. fmt.Println(string(ReadFile(zip_path)))
  34060. if config.IsOpen == 1 {
  34061. var user_name string
  34062. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34063. if role.ID == 0 {
  34064. user_name = "管理员"
  34065. } else {
  34066. user_name = role.UserName
  34067. }
  34068. baseParams := models.BaseParams{
  34069. SecretKey: miConfig.SecretKey,
  34070. FixmedinsCode: miConfig.Code,
  34071. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34072. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34073. OrgName: miConfig.OrgName,
  34074. Doctor: user_name,
  34075. }
  34076. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34077. var dat map[string]interface{}
  34078. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34079. fmt.Println(dat)
  34080. } else {
  34081. fmt.Println(err)
  34082. }
  34083. userJSONBytes, _ := json.Marshal(dat)
  34084. var res ResultNine
  34085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34086. utils.ErrorLog("解析失败:%v", err)
  34087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34088. return
  34089. }
  34090. if res.Infcode == 0 {
  34091. fileNo := res.Output.FileQuryNo
  34092. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34093. "file_qury_no=" + fileNo +
  34094. "&setl_optins=" + "定点医保中心" +
  34095. "&stmt_begndate=" + start_time +
  34096. "&stm_enddate=" + end_time +
  34097. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34098. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34099. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34100. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34101. "&fixmedins_code=" + miConfig.Code +
  34102. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34103. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34104. "&secret_key=" + miConfig.SecretKey +
  34105. "&org_name=" + miConfig.OrgName +
  34106. "&doctor=" + user_name
  34107. resp, requestErr := http.Get(api)
  34108. if requestErr != nil {
  34109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34110. return
  34111. }
  34112. body, ioErr := ioutil.ReadAll(resp.Body)
  34113. if ioErr != nil {
  34114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34116. return
  34117. }
  34118. var respJSON map[string]interface{}
  34119. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34122. return
  34123. }
  34124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34125. userJSONBytes, _ := json.Marshal(respJSON)
  34126. var res ResultTen
  34127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34128. utils.ErrorLog("解析失败:%v", err)
  34129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34130. return
  34131. }
  34132. if res.Infcode == 0 {
  34133. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34134. micc := &models.MedicalInsuranceCostCompare{
  34135. StartTime: startime.Unix(),
  34136. EndTime: endtime.Unix(),
  34137. Insutype: "0",
  34138. CheckType: 2,
  34139. Num: fixmedins_setl_cnt,
  34140. Mtime: time.Now().Unix(),
  34141. Status: 1,
  34142. UserOrgId: adminUser.CurrentOrgId,
  34143. CostTotal: medfee_sumamt,
  34144. FuncTotal: fund_pay_sumamt,
  34145. PsnPay: psn_cash_pay,
  34146. Creator: admin_user_id,
  34147. Ctime: time.Now().Unix(),
  34148. }
  34149. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34150. c.ServeSuccessJSON(map[string]interface{}{
  34151. "msg": "明细对账成功",
  34152. })
  34153. }
  34154. } else {
  34155. }
  34156. }
  34157. }
  34158. type CustomOrderInfo struct {
  34159. Name string
  34160. Spec string
  34161. Unit string
  34162. Count float64
  34163. Price float64
  34164. Total float64
  34165. }
  34166. func (c *HisApiController) GetBatchSettleAccounts() {
  34167. admin_user_id, _ := c.GetInt64("admin_user_id")
  34168. order_ids := c.GetString("order_ids")
  34169. order_ids_arr := strings.Split(order_ids, ",")
  34170. data3 := []map[string]interface{}{}
  34171. for _, item := range order_ids_arr {
  34172. id, _ := strconv.ParseInt(item, 10, 64)
  34173. order_id := id
  34174. adminUser := c.GetAdminUserInfo()
  34175. order, _ := service.GetHisOrderByID(order_id)
  34176. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34177. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34178. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34179. orderInfos = append(orderInfos, orderInfos_two...)
  34180. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34181. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34182. var diagnosis_ids []string
  34183. if his.ID > 0 {
  34184. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34185. } else {
  34186. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34187. }
  34188. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34189. var dia_config []*models.HisXtDiagnoseConfig
  34190. var name string
  34191. for _, item := range diagnosis_ids {
  34192. id, _ := strconv.ParseInt(item, 10, 64)
  34193. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34194. dia_config = append(dia_config, &diagnosisConfig)
  34195. if len(name) == 0 {
  34196. name = diagnosisConfig.ClassName
  34197. }
  34198. //} else {
  34199. // name = name + "," + diagnosisConfig.ClassName
  34200. //}
  34201. }
  34202. var bedCostTotal float64 = 0 //床位总费
  34203. var bedCostSelfTotal float64 = 0 //床位自费
  34204. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34205. var bedSelfTotal float64 = 0 //床位部分项目自费
  34206. var bedInscpTotal float64 = 0 //床位部分项目自费
  34207. var operationCostTotal float64 = 0 //手术费
  34208. var operationCostSelfTotal float64 = 0 //手术费
  34209. var operationCostPartSelfTotal float64 = 0 //手术费
  34210. var operationSelfTotal float64 = 0 //床位部分项目自费
  34211. var operationInscpTotal float64 = 0 //床位部分项目自费
  34212. var otherCostTotal float64 = 0 //其他费用
  34213. var otherCostSelfTotal float64 = 0 //其他费用
  34214. var otherCostPartSelfTotal float64 = 0 //其他费用
  34215. var otherSelfTotal float64 = 0 //床位部分项目自费
  34216. var otherInscpTotal float64 = 0 //床位部分项目自费
  34217. var materialCostTotal float64 = 0 //材料费
  34218. var materialCostSelfTotal float64 = 0 //材料费
  34219. var materialCostPartSelfTotal float64 = 0 //材料费
  34220. var materialSelfTotal float64 = 0 //床位部分项目自费
  34221. var materialInscpTotal float64 = 0 //床位部分项目自费
  34222. var westernMedicineCostTotal float64 = 0 //西药费
  34223. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34224. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34225. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34226. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34227. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34228. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34229. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34230. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34231. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34232. var checkCostTotal float64 = 0 //检查费
  34233. var checkCostSelfTotal float64 = 0 //检查费
  34234. var checkCostPartSelfTotal float64 = 0 //检查费
  34235. var checkSelfTotal float64 = 0 //床位部分项目自费
  34236. var checkInscpTotal float64 = 0 //床位部分项目自费
  34237. var laboratoryCostTotal float64 = 0 //化验费
  34238. var laboratoryCostSelfTotal float64 = 0 //化验费
  34239. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34240. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34241. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34242. var treatCostTotal float64 = 0 //治疗费用
  34243. var treatCostSelfTotal float64 = 0 //治疗费用
  34244. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34245. var treatSelfTotal float64 = 0 //床位部分项目自费
  34246. var treatInscpTotal float64 = 0 //床位部分项目自费
  34247. decimal.DivisionPrecision = 2
  34248. for _, item := range orderInfos {
  34249. if item.MedChrgitmType == "01" { //床位费
  34250. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34251. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34252. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34253. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34254. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34255. }
  34256. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34257. if item.MedChrgitmType == "03" { //检查费
  34258. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34259. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34260. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34261. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34262. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34263. }
  34264. } else {
  34265. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34266. fmt.Println("------------")
  34267. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34268. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34269. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34270. }
  34271. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34272. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34273. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34274. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34275. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34276. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34277. }
  34278. }
  34279. if item.MedChrgitmType == "04" { //化验费
  34280. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34281. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34282. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34283. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34284. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34285. }
  34286. if item.MedChrgitmType == "05" { //治疗费
  34287. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34288. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34289. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34290. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34291. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34292. }
  34293. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34294. fmt.Println("------------")
  34295. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34296. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34297. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34298. }
  34299. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34300. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34301. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34302. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34303. }
  34304. //if item.MedChrgitmType == "06" { //手术费
  34305. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34306. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34307. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34308. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34309. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34310. //
  34311. //}
  34312. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34313. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34314. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34315. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34316. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34317. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34318. }
  34319. if item.MedChrgitmType == "09" { //西药费
  34320. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34321. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34322. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34323. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34324. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34325. }
  34326. if item.MedChrgitmType == "11" { //中成费
  34327. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34328. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34329. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34330. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34331. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34332. }
  34333. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34334. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34335. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34336. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34337. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34338. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34339. }
  34340. }
  34341. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34342. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34343. var user_name string
  34344. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34345. if role.ID == 0 {
  34346. user_name = "管理员"
  34347. } else {
  34348. user_name = role.UserName
  34349. }
  34350. baseParams := models.BaseParams{
  34351. SecretKey: miConfig.SecretKey,
  34352. FixmedinsCode: miConfig.Code,
  34353. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34354. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34355. OrgName: miConfig.OrgName,
  34356. Doctor: user_name,
  34357. RequestUrl: miConfig.Url,
  34358. AccessKey: miConfig.AccessKey,
  34359. }
  34360. businessParams := models.BusinessParams{
  34361. PsnNo: order.PsnNo,
  34362. MdtrtId: order.MdtrtId,
  34363. SetlId: order.SetlId,
  34364. }
  34365. var res ResultEleven
  34366. var resEleven10265 ResultEleven10265
  34367. if config.IsOpen == 1 {
  34368. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34369. result := service.Gdyb5203(baseParams, businessParams)
  34370. service.Gdyb5204(baseParams, businessParams)
  34371. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34372. var dat map[string]interface{}
  34373. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34374. fmt.Println(dat)
  34375. } else {
  34376. fmt.Println(err)
  34377. }
  34378. userJSONBytes, _ := json.Marshal(dat)
  34379. if miConfig.Code == "H15049901371" {
  34380. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34381. utils.ErrorLog("解析失败:%v", err)
  34382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34383. return
  34384. }
  34385. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34386. res.Output = resEleven10265.Output
  34387. res.ErrMsg = resEleven10265.ErrMsg
  34388. res.Cainfo = resEleven10265.Cainfo
  34389. res.WarnMsg = resEleven10265.WarnMsg
  34390. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34391. res.Infcode = infocode
  34392. } else {
  34393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34394. utils.ErrorLog("解析失败:%v", err)
  34395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34396. return
  34397. }
  34398. }
  34399. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34400. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34401. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34402. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34403. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34404. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34405. var doctor_name string
  34406. if roles.ID == 0 {
  34407. doctor_name = "管理员"
  34408. } else {
  34409. doctor_name = roles.UserName
  34410. }
  34411. yiliao_leibie := ""
  34412. switch order.MedType {
  34413. case "11":
  34414. yiliao_leibie = "普通门诊"
  34415. break
  34416. case "12":
  34417. yiliao_leibie = "门诊挂号"
  34418. break
  34419. case "13":
  34420. yiliao_leibie = "急诊"
  34421. break
  34422. case "14":
  34423. yiliao_leibie = "门诊特殊病"
  34424. break
  34425. case "15":
  34426. yiliao_leibie = "门诊统筹"
  34427. break
  34428. case "16":
  34429. yiliao_leibie = "门诊慢性病"
  34430. break
  34431. case "21":
  34432. yiliao_leibie = "普通住院"
  34433. break
  34434. }
  34435. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34436. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34437. if res.Infcode == 0 {
  34438. data2 := map[string]interface{}{
  34439. "diagnosis": name,
  34440. "order_infos": orderInfos,
  34441. "number": order.MdtrtId,
  34442. "date": order.SettleAccountsDate,
  34443. "charge_admin": charge_admin,
  34444. "printor_admin": printor_admin,
  34445. "info": res.Output.Setlinfo,
  34446. "order": order,
  34447. "bedCostTotal": bedCostTotal,
  34448. "bedCostSelfTotal": bedCostSelfTotal,
  34449. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34450. "bedSelfTotal": bedSelfTotal,
  34451. "bedInscpTotal": bedInscpTotal,
  34452. "operationCostTotal": operationCostTotal,
  34453. "operationCostSelfTotal": operationCostSelfTotal,
  34454. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34455. "operationSelfTotal": operationSelfTotal,
  34456. "operationInscpTotal": operationInscpTotal,
  34457. "otherCostTotal": otherCostTotal,
  34458. "otherCostSelfTotal": otherCostSelfTotal,
  34459. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34460. "otherSelfTotal": otherSelfTotal,
  34461. "otherInscpTotal": otherInscpTotal,
  34462. "materialCostTotal": materialCostTotal,
  34463. "materialCostSelfTotal": materialCostSelfTotal,
  34464. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34465. "materialSelfTotal": materialSelfTotal,
  34466. "materialInscpTotal": materialInscpTotal,
  34467. "westernMedicineCostTotal": westernMedicineCostTotal,
  34468. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34469. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34470. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34471. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34472. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34473. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34474. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34475. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34476. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34477. "checkCostTotal": checkCostTotal,
  34478. "checkCostSelfTotal": checkCostSelfTotal,
  34479. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34480. "checkSelfTotal": checkSelfTotal,
  34481. "checkInscpTotal": checkInscpTotal,
  34482. "laboratoryCostTotal": laboratoryCostTotal,
  34483. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34484. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34485. "laboratorySelfTotal": laboratorySelfTotal,
  34486. "laboratoryInscpTotal": laboratoryInscpTotal,
  34487. "treatCostTotal": treatCostTotal,
  34488. "treatCostSelfTotal": treatCostSelfTotal,
  34489. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34490. "treatSelfTotal": treatSelfTotal,
  34491. "treatInscpTotal": treatInscpTotal,
  34492. "doctor_info": doctor_info,
  34493. "doctor_code": adminRole_two.DoctorCode,
  34494. "doctor_name": doctor_name,
  34495. "health_card_no": order.PsnNo,
  34496. "department": departments.Name,
  34497. "yiliao_leibie": yiliao_leibie,
  34498. "after_money": order.AccountPrice,
  34499. "patient": patient,
  34500. "org_name": miConfig.OrgName,
  34501. "org_code": miConfig.Code,
  34502. "order_number": order.Number,
  34503. "his_hospital": his_hospital,
  34504. "his": his,
  34505. "dia_config": dia_config,
  34506. "psn_cash_pay": order.PsnCashPay,
  34507. //"check_order_info": cus_slice,
  34508. }
  34509. data3 = append(data3, data2)
  34510. }
  34511. }
  34512. }
  34513. c.ServeSuccessJSON(map[string]interface{}{
  34514. "infos": data3,
  34515. })
  34516. }
  34517. func (c *HisApiController) GetSettleAccounts() {
  34518. //id, _ := c.GetInt64("id")
  34519. //record_time := c.GetString("record_time")
  34520. order_id, _ := c.GetInt64("order_id")
  34521. admin_user_id, _ := c.GetInt64("admin_user_id")
  34522. //timeLayout := "2006-01-02"
  34523. //loc, _ := time.LoadLocation("Local")
  34524. //
  34525. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34526. //if err != nil {
  34527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34528. // return
  34529. //}Hbyb5203
  34530. //recordDateTime := theTime.Unix()
  34531. adminUser := c.GetAdminUserInfo()
  34532. order, _ := service.GetHisOrderByID(order_id)
  34533. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34534. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34535. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34536. orderInfos = append(orderInfos, orderInfos_two...)
  34537. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34538. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34539. var diagnosis_ids []string
  34540. if his.ID > 0 {
  34541. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34542. } else {
  34543. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34544. }
  34545. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34546. var dia_config []*models.HisXtDiagnoseConfig
  34547. var name string
  34548. for _, item := range diagnosis_ids {
  34549. id, _ := strconv.ParseInt(item, 10, 64)
  34550. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34551. dia_config = append(dia_config, &diagnosisConfig)
  34552. if len(name) == 0 {
  34553. name = diagnosisConfig.ClassName
  34554. } else {
  34555. name = name + "," + diagnosisConfig.ClassName
  34556. }
  34557. }
  34558. if patient.UserOrgId == 10215 {
  34559. name = "慢性肾功能不全(血透治疗)"
  34560. }
  34561. var bedCostTotal float64 = 0 //床位总费
  34562. var bedCostSelfTotal float64 = 0 //床位自费
  34563. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34564. var bedSelfTotal float64 = 0 //床位部分项目自费
  34565. var bedInscpTotal float64 = 0 //床位部分项目自费
  34566. var operationCostTotal float64 = 0 //手术费
  34567. var operationCostSelfTotal float64 = 0 //手术费
  34568. var operationCostPartSelfTotal float64 = 0 //手术费
  34569. var operationSelfTotal float64 = 0 //床位部分项目自费
  34570. var operationInscpTotal float64 = 0 //床位部分项目自费
  34571. var otherCostTotal float64 = 0 //其他费用
  34572. var otherCostSelfTotal float64 = 0 //其他费用
  34573. var otherCostPartSelfTotal float64 = 0 //其他费用
  34574. var otherSelfTotal float64 = 0 //床位部分项目自费
  34575. var otherInscpTotal float64 = 0 //床位部分项目自费
  34576. var materialCostTotal float64 = 0 //材料费
  34577. var materialCostSelfTotal float64 = 0 //材料费
  34578. var materialCostPartSelfTotal float64 = 0 //材料费
  34579. var materialSelfTotal float64 = 0 //床位部分项目自费
  34580. var materialInscpTotal float64 = 0 //床位部分项目自费
  34581. var westernMedicineCostTotal float64 = 0 //西药费
  34582. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34583. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34584. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34585. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34586. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34587. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34588. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34589. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34590. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34591. var checkCostTotal float64 = 0 //检查费
  34592. var checkCostSelfTotal float64 = 0 //检查费
  34593. var checkCostPartSelfTotal float64 = 0 //检查费
  34594. var checkSelfTotal float64 = 0 //床位部分项目自费
  34595. var checkInscpTotal float64 = 0 //床位部分项目自费
  34596. var laboratoryCostTotal float64 = 0 //化验费
  34597. var laboratoryCostSelfTotal float64 = 0 //化验费
  34598. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34599. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34600. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34601. var treatCostTotal float64 = 0 //治疗费用
  34602. var treatCostSelfTotal float64 = 0 //治疗费用
  34603. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34604. var treatSelfTotal float64 = 0 //床位部分项目自费
  34605. var treatInscpTotal float64 = 0 //床位部分项目自费
  34606. var zcCostTotal float64 = 0 //治疗费用
  34607. var zcCostSelfTotal float64 = 0 //治疗费用
  34608. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34609. var zcSelfTotal float64 = 0 //床位部分项目自费
  34610. var zcInscpTotal float64 = 0 //床位部分项目自费
  34611. var huliCostTotal float64 = 0 //治疗费用
  34612. var huliCostSelfTotal float64 = 0 //治疗费用
  34613. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34614. var huliSelfTotal float64 = 0 //床位部分项目自费
  34615. var huliInscpTotal float64 = 0 //床位部分项目自费
  34616. decimal.DivisionPrecision = 2
  34617. for _, item := range orderInfos {
  34618. if item.MedChrgitmType == "01" { //床位费
  34619. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34620. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34621. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34622. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34623. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34624. }
  34625. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34626. if item.MedChrgitmType == "03" { //检查费
  34627. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34628. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34629. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34630. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34631. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34632. }
  34633. } else {
  34634. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34635. fmt.Println("------------")
  34636. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34637. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34638. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34639. }
  34640. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34641. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34642. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34643. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34644. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34645. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34646. }
  34647. }
  34648. if item.MedChrgitmType == "04" { //化验费
  34649. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34650. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34651. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34652. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34653. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34654. }
  34655. if item.MedChrgitmType == "05" { //治疗费
  34656. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34657. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34658. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34659. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34660. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34661. }
  34662. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34663. fmt.Println("------------")
  34664. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34665. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34666. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34667. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34668. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34669. }
  34670. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34671. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34672. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34673. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34674. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34675. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34676. }
  34677. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34678. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34679. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34680. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34681. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34682. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34683. }
  34684. if item.MedChrgitmType == "09" { //西药费
  34685. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34686. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34687. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34688. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34689. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34690. }
  34691. if item.MedChrgitmType == "11" { //中成费
  34692. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34693. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34694. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34695. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34696. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34697. }
  34698. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34699. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34700. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34701. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34702. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34703. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34704. }
  34705. if item.MedChrgitmType == "02" { //其他费
  34706. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34707. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34708. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34709. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34710. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34711. }
  34712. if item.MedChrgitmType == "07" { //其他费
  34713. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34714. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34715. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34716. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34717. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34718. }
  34719. }
  34720. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34721. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34722. var user_name string
  34723. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34724. if role.ID == 0 {
  34725. user_name = "管理员"
  34726. } else {
  34727. user_name = role.UserName
  34728. }
  34729. baseParams := models.BaseParams{
  34730. SecretKey: miConfig.SecretKey,
  34731. FixmedinsCode: miConfig.Code,
  34732. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34733. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34734. OrgName: miConfig.OrgName,
  34735. Doctor: user_name,
  34736. RequestUrl: miConfig.Url,
  34737. AccessKey: miConfig.AccessKey,
  34738. }
  34739. businessParams := models.BusinessParams{
  34740. PsnNo: order.PsnNo,
  34741. MdtrtId: order.MdtrtId,
  34742. SetlId: order.SetlId,
  34743. }
  34744. var res ResultEleven
  34745. var resah ResultElevenah
  34746. var resEleven10265 ResultEleven10265
  34747. if config.IsOpen == 1 {
  34748. if miConfig.MdtrtareaAdmvs == "421300" {
  34749. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34750. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34751. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34752. resp, requestErr := http.Get(api)
  34753. if requestErr != nil {
  34754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34755. return
  34756. }
  34757. body, ioErr := ioutil.ReadAll(resp.Body)
  34758. if ioErr != nil {
  34759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34761. return
  34762. }
  34763. var respJSON map[string]interface{}
  34764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34767. return
  34768. }
  34769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34770. result, _ := json.Marshal(respJSON)
  34771. fmt.Println("log")
  34772. fmt.Println(string(result))
  34773. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34774. utils.ErrorLog("解析失败:%v", err)
  34775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34776. return
  34777. }
  34778. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34779. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34780. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34781. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34782. resp, requestErr := http.Get(api)
  34783. if requestErr != nil {
  34784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34785. return
  34786. }
  34787. body, ioErr := ioutil.ReadAll(resp.Body)
  34788. if ioErr != nil {
  34789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34791. return
  34792. }
  34793. var respJSON map[string]interface{}
  34794. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34797. return
  34798. }
  34799. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34800. result, _ := json.Marshal(respJSON)
  34801. fmt.Println("log")
  34802. fmt.Println(string(result))
  34803. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34804. utils.ErrorLog("解析失败:%v", err)
  34805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34806. return
  34807. }
  34808. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34809. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34810. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34811. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34812. resp, requestErr := http.Get(api)
  34813. if requestErr != nil {
  34814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34815. return
  34816. }
  34817. body, ioErr := ioutil.ReadAll(resp.Body)
  34818. if ioErr != nil {
  34819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34821. return
  34822. }
  34823. var respJSON map[string]interface{}
  34824. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34827. return
  34828. }
  34829. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34830. result, _ := json.Marshal(respJSON)
  34831. fmt.Println("log")
  34832. fmt.Println(string(result))
  34833. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34834. utils.ErrorLog("解析失败:%v", err)
  34835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34836. return
  34837. }
  34838. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34839. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34840. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34841. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34842. resp, requestErr := http.Get(api)
  34843. if requestErr != nil {
  34844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34845. return
  34846. }
  34847. body, ioErr := ioutil.ReadAll(resp.Body)
  34848. if ioErr != nil {
  34849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34851. return
  34852. }
  34853. var respJSON map[string]interface{}
  34854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34857. return
  34858. }
  34859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34860. result, _ := json.Marshal(respJSON)
  34861. fmt.Println("log")
  34862. fmt.Println(string(result))
  34863. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34864. utils.ErrorLog("解析失败:%v", err)
  34865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34866. return
  34867. }
  34868. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34869. var api string
  34870. if miConfig.MdtrtareaAdmvs == "320921" {
  34871. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34872. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34873. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34874. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34875. } else {
  34876. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34877. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34878. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34879. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34880. }
  34881. resp, requestErr := http.Get(api)
  34882. if requestErr != nil {
  34883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34884. return
  34885. }
  34886. body, ioErr := ioutil.ReadAll(resp.Body)
  34887. if ioErr != nil {
  34888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34890. return
  34891. }
  34892. var respJSON map[string]interface{}
  34893. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34896. return
  34897. }
  34898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34899. result, _ := json.Marshal(respJSON)
  34900. fmt.Println("log")
  34901. fmt.Println(string(result))
  34902. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34903. utils.ErrorLog("解析失败:%v", err)
  34904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34905. return
  34906. }
  34907. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34908. res.Output = resEleven10265.Output
  34909. res.ErrMsg = resEleven10265.ErrMsg
  34910. res.Cainfo = resEleven10265.Cainfo
  34911. res.WarnMsg = resEleven10265.WarnMsg
  34912. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34913. res.Infcode = infocode
  34914. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34915. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34916. saveLog(result, requestLog, "5203", "结算单")
  34917. var dat map[string]interface{}
  34918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34919. fmt.Println(dat)
  34920. } else {
  34921. fmt.Println(err)
  34922. }
  34923. userJSONBytes, _ := json.Marshal(dat)
  34924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34925. utils.ErrorLog("解析失败:%v", err)
  34926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34927. return
  34928. }
  34929. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34930. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34931. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34932. saveLog(result, requestLog, "5203", "结算单")
  34933. var dat map[string]interface{}
  34934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34935. fmt.Println(dat)
  34936. } else {
  34937. fmt.Println(err)
  34938. }
  34939. userJSONBytes, _ := json.Marshal(dat)
  34940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34941. utils.ErrorLog("解析失败:%v", err)
  34942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34943. return
  34944. }
  34945. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34946. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34947. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34948. saveLog(result, requestLog, "5203", "结算单")
  34949. var dat map[string]interface{}
  34950. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34951. fmt.Println(dat)
  34952. } else {
  34953. fmt.Println(err)
  34954. }
  34955. userJSONBytes, _ := json.Marshal(dat)
  34956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34957. utils.ErrorLog("解析失败:%v", err)
  34958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34959. return
  34960. }
  34961. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34962. var api string
  34963. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34964. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34965. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34966. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34967. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34968. resp, requestErr := http.Get(api)
  34969. if requestErr != nil {
  34970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34971. return
  34972. }
  34973. body, ioErr := ioutil.ReadAll(resp.Body)
  34974. if ioErr != nil {
  34975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34977. return
  34978. }
  34979. var respJSON map[string]interface{}
  34980. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34983. return
  34984. }
  34985. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34986. if status == "0" {
  34987. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34988. c.ServeSuccessJSON(map[string]interface{}{
  34989. "failed_code": -10,
  34990. "msg": err_msg,
  34991. })
  34992. return
  34993. }
  34994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34995. result, _ := json.Marshal(respJSON)
  34996. fmt.Println("log")
  34997. fmt.Println(string(result))
  34998. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34999. utils.ErrorLog("解析失败:%v", err)
  35000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35001. return
  35002. }
  35003. res.InfRefmsgid = resah.InfRefmsgid
  35004. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35005. // 创建对应的Time类型
  35006. t := time.UnixMilli(timestamp)
  35007. // 格式化成指定的日期字符串
  35008. str := t.Format("2006-01-02 15:04:05")
  35009. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35010. // 创建对应的Time类型
  35011. t3 := time.UnixMilli(timestamp2)
  35012. // 格式化成指定的日期字符串
  35013. str2 := t3.Format("2006-01-02 15:04:05")
  35014. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35015. // 创建对应的Time类型
  35016. t4 := time.UnixMilli(timestamp3)
  35017. // 格式化成指定的日期字符串
  35018. str3 := t4.Format("2006-01-02 15:04:05")
  35019. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35020. // 创建对应的Time类型
  35021. t5 := time.UnixMilli(timestamp4)
  35022. // 格式化成指定的日期字符串
  35023. str5 := t5.Format("2006-01-02 15:04:05")
  35024. res.Output.Setlinfo.Brdy = str2
  35025. res.Output.Setlinfo.SetlTime = str
  35026. res.Output.Setlinfo.Begndate = str3
  35027. res.Output.Setlinfo.Enddate = str5
  35028. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35029. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35030. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35031. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35032. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35033. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35034. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35035. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35036. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35037. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35038. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35039. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35040. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35041. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35042. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35043. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35044. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35045. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35046. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35047. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35048. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35049. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35050. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35051. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35052. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35053. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35054. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35055. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35056. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35057. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35058. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35059. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35060. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35061. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35062. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35063. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35064. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35065. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35066. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35067. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35068. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35069. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35070. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35071. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35072. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35073. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35074. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35075. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35076. //res.Output.Setldetail = resah.Output.Setldetail
  35077. res.ErrMsg = resah.ErrMsg
  35078. res.Cainfo = resah.Cainfo
  35079. res.WarnMsg = resah.WarnMsg
  35080. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35081. var api string
  35082. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35083. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35084. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35085. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35086. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35087. resp, requestErr := http.Get(api)
  35088. if requestErr != nil {
  35089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35090. return
  35091. }
  35092. body, ioErr := ioutil.ReadAll(resp.Body)
  35093. if ioErr != nil {
  35094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35096. return
  35097. }
  35098. var respJSON map[string]interface{}
  35099. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35102. return
  35103. }
  35104. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35105. if status == "0" {
  35106. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35107. c.ServeSuccessJSON(map[string]interface{}{
  35108. "failed_code": -10,
  35109. "msg": err_msg,
  35110. })
  35111. return
  35112. }
  35113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35114. result, _ := json.Marshal(respJSON)
  35115. fmt.Println("log")
  35116. fmt.Println(string(result))
  35117. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35118. utils.ErrorLog("解析失败:%v", err)
  35119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35120. return
  35121. }
  35122. res.InfRefmsgid = resah.InfRefmsgid
  35123. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35124. // 创建对应的Time类型
  35125. t := time.UnixMilli(timestamp)
  35126. // 格式化成指定的日期字符串
  35127. str := t.Format("2006-01-02 15:04:05")
  35128. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35129. // 创建对应的Time类型
  35130. t3 := time.UnixMilli(timestamp2)
  35131. // 格式化成指定的日期字符串
  35132. str2 := t3.Format("2006-01-02 15:04:05")
  35133. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35134. // 创建对应的Time类型
  35135. t4 := time.UnixMilli(timestamp3)
  35136. // 格式化成指定的日期字符串
  35137. str3 := t4.Format("2006-01-02 15:04:05")
  35138. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35139. // 创建对应的Time类型
  35140. t5 := time.UnixMilli(timestamp4)
  35141. // 格式化成指定的日期字符串
  35142. str5 := t5.Format("2006-01-02 15:04:05")
  35143. res.Output.Setlinfo.Brdy = str2
  35144. res.Output.Setlinfo.SetlTime = str
  35145. res.Output.Setlinfo.Begndate = str3
  35146. res.Output.Setlinfo.Enddate = str5
  35147. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35148. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35149. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35150. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35151. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35152. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35153. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35154. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35155. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35156. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35157. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35158. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35159. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35160. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35161. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35162. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35163. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35164. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35165. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35166. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35167. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35168. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35169. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35170. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35171. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35172. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35173. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35174. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35175. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35176. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35177. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35178. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35179. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35180. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35181. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35182. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35183. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35184. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35185. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35186. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35187. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35188. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35189. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35190. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35191. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35192. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35193. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35194. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35195. //res.Output.Setldetail = resah.Output.Setldetail
  35196. res.ErrMsg = resah.ErrMsg
  35197. res.Cainfo = resah.Cainfo
  35198. res.WarnMsg = resah.WarnMsg
  35199. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35200. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35201. saveLog(result, requestLog, "5203", "结算单")
  35202. var dat map[string]interface{}
  35203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35204. fmt.Println(dat)
  35205. } else {
  35206. fmt.Println(err)
  35207. }
  35208. userJSONBytes, _ := json.Marshal(dat)
  35209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35210. utils.ErrorLog("解析失败:%v", err)
  35211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35212. return
  35213. }
  35214. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35215. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35216. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35217. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35218. resp, requestErr := http.Get(api)
  35219. if requestErr != nil {
  35220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35221. return
  35222. }
  35223. body, ioErr := ioutil.ReadAll(resp.Body)
  35224. if ioErr != nil {
  35225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35227. return
  35228. }
  35229. var respJSON map[string]interface{}
  35230. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35233. return
  35234. }
  35235. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35236. result, _ := json.Marshal(respJSON)
  35237. fmt.Println("log")
  35238. fmt.Println(string(result))
  35239. if err := json.Unmarshal([]byte(result), &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 if miConfig.MdtrtareaAdmvs == "441799" {
  35252. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35253. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35254. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35255. resp, requestErr := http.Get(api)
  35256. if requestErr != nil {
  35257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35258. return
  35259. }
  35260. body, ioErr := ioutil.ReadAll(resp.Body)
  35261. if ioErr != nil {
  35262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35264. return
  35265. }
  35266. var respJSON map[string]interface{}
  35267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35270. return
  35271. }
  35272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35273. result, _ := json.Marshal(respJSON)
  35274. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35275. utils.ErrorLog("解析失败:%v", err)
  35276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35277. return
  35278. }
  35279. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35280. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35281. //return
  35282. } else {
  35283. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35284. if len(his.InsuplcAdmdvs) == 0 {
  35285. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35286. } else {
  35287. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35288. }
  35289. result := service.Gdyb5203(baseParams, businessParams)
  35290. //service.Gdyb5204(baseParams, businessParams)
  35291. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35292. var dat map[string]interface{}
  35293. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35294. fmt.Println(dat)
  35295. } else {
  35296. fmt.Println(err)
  35297. }
  35298. userJSONBytes, _ := json.Marshal(dat)
  35299. if miConfig.Code == "H15049901371" {
  35300. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35301. utils.ErrorLog("解析失败:%v", err)
  35302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35303. return
  35304. }
  35305. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35306. res.Output = resEleven10265.Output
  35307. res.ErrMsg = resEleven10265.ErrMsg
  35308. res.Cainfo = resEleven10265.Cainfo
  35309. res.WarnMsg = resEleven10265.WarnMsg
  35310. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35311. res.Infcode = infocode
  35312. } else {
  35313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35314. utils.ErrorLog("解析失败:%v", err)
  35315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35316. return
  35317. }
  35318. }
  35319. }
  35320. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35321. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35322. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35323. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35324. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35325. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35326. var doctor_name string
  35327. if roles.ID == 0 {
  35328. doctor_name = "管理员"
  35329. } else {
  35330. doctor_name = roles.UserName
  35331. }
  35332. yiliao_leibie := ""
  35333. switch order.MedType {
  35334. case "11":
  35335. yiliao_leibie = "普通门诊"
  35336. break
  35337. case "12":
  35338. yiliao_leibie = "门诊挂号"
  35339. break
  35340. case "13":
  35341. yiliao_leibie = "急诊"
  35342. break
  35343. case "14":
  35344. yiliao_leibie = "门诊特殊病"
  35345. break
  35346. case "15":
  35347. yiliao_leibie = "门诊统筹"
  35348. break
  35349. case "16":
  35350. yiliao_leibie = "门诊慢性病"
  35351. break
  35352. case "21":
  35353. yiliao_leibie = "普通住院"
  35354. break
  35355. }
  35356. //var rf []CustomFundPay
  35357. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35358. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35359. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35360. if res.Infcode == 0 {
  35361. 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 {
  35362. c.ServeSuccessJSON(map[string]interface{}{
  35363. "diagnosis": name,
  35364. "order_infos": orderInfos,
  35365. "number": order.MdtrtId,
  35366. "date": order.SettleAccountsDate,
  35367. "charge_admin": charge_admin,
  35368. "printor_admin": printor_admin,
  35369. "info": res.Output.Setlinfo,
  35370. "order": order,
  35371. "bedCostTotal": bedCostTotal,
  35372. "bedCostSelfTotal": bedCostSelfTotal,
  35373. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35374. "bedSelfTotal": bedSelfTotal,
  35375. "bedInscpTotal": bedInscpTotal,
  35376. "operationCostTotal": operationCostTotal,
  35377. "operationCostSelfTotal": operationCostSelfTotal,
  35378. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35379. "operationSelfTotal": operationSelfTotal,
  35380. "operationInscpTotal": operationInscpTotal,
  35381. "otherCostTotal": otherCostTotal,
  35382. "otherCostSelfTotal": otherCostSelfTotal,
  35383. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35384. "otherSelfTotal": otherSelfTotal,
  35385. "otherInscpTotal": otherInscpTotal,
  35386. "materialCostTotal": materialCostTotal,
  35387. "materialCostSelfTotal": materialCostSelfTotal,
  35388. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35389. "materialSelfTotal": materialSelfTotal,
  35390. "materialInscpTotal": materialInscpTotal,
  35391. "westernMedicineCostTotal": westernMedicineCostTotal,
  35392. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35393. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35394. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35395. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35396. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35397. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35398. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35399. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35400. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35401. "checkCostTotal": checkCostTotal,
  35402. "checkCostSelfTotal": checkCostSelfTotal,
  35403. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35404. "checkSelfTotal": checkSelfTotal,
  35405. "checkInscpTotal": checkInscpTotal,
  35406. "laboratoryCostTotal": laboratoryCostTotal,
  35407. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35408. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35409. "laboratorySelfTotal": laboratorySelfTotal,
  35410. "laboratoryInscpTotal": laboratoryInscpTotal,
  35411. "treatCostTotal": treatCostTotal,
  35412. "treatCostSelfTotal": treatCostSelfTotal,
  35413. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35414. "treatSelfTotal": treatSelfTotal,
  35415. "treatInscpTotal": treatInscpTotal,
  35416. "doctor_info": doctor_info,
  35417. "doctor_code": adminRole_two.DoctorCode,
  35418. "doctor_name": doctor_name,
  35419. "health_card_no": order.PsnNo,
  35420. "department": departments.Name,
  35421. "yiliao_leibie": yiliao_leibie,
  35422. "after_money": order.AccountPrice,
  35423. "patient": patient,
  35424. "org_name": miConfig.OrgName,
  35425. "org_code": miConfig.Code,
  35426. "order_number": order.Number,
  35427. "his_hospital": his_hospital,
  35428. "his": his,
  35429. "dia_config": dia_config,
  35430. "psn_cash_pay": order.PsnCashPay,
  35431. "zcCostTotal": zcCostTotal,
  35432. "zcCostSelfTotal": zcCostSelfTotal,
  35433. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35434. "zcSelfTotal": zcSelfTotal,
  35435. "zcInscpTotal": zcInscpTotal,
  35436. "huliCostTotal": huliCostTotal,
  35437. "huliCostSelfTotal": huliCostSelfTotal,
  35438. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35439. "huliSelfTotal": huliSelfTotal,
  35440. "huliInscpTotal": huliInscpTotal,
  35441. //"funds": rf,
  35442. //"check_order_info": cus_slice,
  35443. })
  35444. } else {
  35445. c.ServeSuccessJSON(map[string]interface{}{
  35446. "diagnosis": name,
  35447. "order_infos": orderInfos,
  35448. "number": order.MdtrtId,
  35449. "date": order.SettleAccountsDate,
  35450. "charge_admin": charge_admin,
  35451. "printor_admin": printor_admin,
  35452. "info": order,
  35453. "order": order,
  35454. "bedCostTotal": bedCostTotal,
  35455. "bedCostSelfTotal": bedCostSelfTotal,
  35456. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35457. "bedSelfTotal": bedSelfTotal,
  35458. "bedInscpTotal": bedInscpTotal,
  35459. "operationCostTotal": operationCostTotal,
  35460. "operationCostSelfTotal": operationCostSelfTotal,
  35461. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35462. "operationSelfTotal": operationSelfTotal,
  35463. "operationInscpTotal": operationInscpTotal,
  35464. "otherCostTotal": otherCostTotal,
  35465. "otherCostSelfTotal": otherCostSelfTotal,
  35466. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35467. "otherSelfTotal": otherSelfTotal,
  35468. "otherInscpTotal": otherInscpTotal,
  35469. "materialCostTotal": materialCostTotal,
  35470. "materialCostSelfTotal": materialCostSelfTotal,
  35471. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35472. "materialSelfTotal": materialSelfTotal,
  35473. "materialInscpTotal": materialInscpTotal,
  35474. "westernMedicineCostTotal": westernMedicineCostTotal,
  35475. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35476. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35477. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35478. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35479. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35480. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35481. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35482. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35483. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35484. "checkCostTotal": checkCostTotal,
  35485. "checkCostSelfTotal": checkCostSelfTotal,
  35486. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35487. "checkSelfTotal": checkSelfTotal,
  35488. "checkInscpTotal": checkInscpTotal,
  35489. "laboratoryCostTotal": laboratoryCostTotal,
  35490. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35491. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35492. "laboratorySelfTotal": laboratorySelfTotal,
  35493. "laboratoryInscpTotal": laboratoryInscpTotal,
  35494. "treatCostTotal": treatCostTotal,
  35495. "treatCostSelfTotal": treatCostSelfTotal,
  35496. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35497. "treatSelfTotal": treatSelfTotal,
  35498. "treatInscpTotal": treatInscpTotal,
  35499. "doctor_info": doctor_info,
  35500. "doctor_code": adminRole_two.DoctorCode,
  35501. "doctor_name": doctor_name,
  35502. "health_card_no": order.PsnNo,
  35503. "department": departments.Name,
  35504. "yiliao_leibie": yiliao_leibie,
  35505. "after_money": order.AccountPrice,
  35506. "patient": patient,
  35507. "org_name": miConfig.OrgName,
  35508. "org_code": miConfig.Code,
  35509. "order_number": order.Number,
  35510. "his_hospital": his_hospital,
  35511. "his": his,
  35512. "dia_config": dia_config,
  35513. "psn_cash_pay": order.PsnCashPay,
  35514. "zcCostTotal": zcCostTotal,
  35515. "zcCostSelfTotal": zcCostSelfTotal,
  35516. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35517. "zcSelfTotal": zcSelfTotal,
  35518. "zcInscpTotal": zcInscpTotal,
  35519. "huliCostTotal": huliCostTotal,
  35520. "huliCostSelfTotal": huliCostSelfTotal,
  35521. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35522. "huliSelfTotal": huliSelfTotal,
  35523. "huliInscpTotal": huliInscpTotal,
  35524. //"funds": rf,
  35525. //"check_order_info": cus_slice,
  35526. })
  35527. }
  35528. }
  35529. }
  35530. }
  35531. //func (c *HisApiController) CheckTreatment() {
  35532. // patient_id, _ := c.GetInt64("patient_id")
  35533. // id_card_no := c.GetString("id_card_no")
  35534. // insutype := c.GetString("insutype")
  35535. // med_type := c.GetString("med_type")
  35536. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35537. //
  35538. // adminUser := c.GetAdminUserInfo()
  35539. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35540. //
  35541. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35542. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35543. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35544. //
  35545. // if miConfig.MdtrtareaAdmvs == "421300" {
  35546. // var res ResultTwo
  35547. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35548. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35549. // "&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)
  35550. // resp, requestErr := http.Get(api)
  35551. // if requestErr != nil {
  35552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35553. // return
  35554. // }
  35555. //
  35556. // body, ioErr := ioutil.ReadAll(resp.Body)
  35557. // if ioErr != nil {
  35558. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35560. // return
  35561. // }
  35562. // var respJSON map[string]interface{}
  35563. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35564. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35566. // return
  35567. // }
  35568. //
  35569. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35570. // result, _ := json.Marshal(respJSON)
  35571. //
  35572. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35573. // utils.ErrorLog("解析失败:%v", err)
  35574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35575. // return
  35576. // }
  35577. //
  35578. // if res.Infcode == 0 {
  35579. //
  35580. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35581. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35582. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35583. // resp, requestErr := http.Get(api)
  35584. // if requestErr != nil {
  35585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35586. // return
  35587. // }
  35588. //
  35589. // body, ioErr := ioutil.ReadAll(resp.Body)
  35590. // if ioErr != nil {
  35591. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35593. // return
  35594. // }
  35595. // var respJSON map[string]interface{}
  35596. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35597. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35599. // return
  35600. // }
  35601. // var res Result2001
  35602. //
  35603. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35604. // result2, _ := json.Marshal(respJSON)
  35605. //
  35606. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35607. // utils.ErrorLog("解析失败:%v", err)
  35608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35609. // return
  35610. // }
  35611. //
  35612. // if res.Infcode == 0 {
  35613. // c.ServeSuccessJSON(map[string]interface{}{
  35614. // "msg": res.Output.Trtinfo,
  35615. // })
  35616. // }
  35617. //
  35618. // } else {
  35619. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35620. // return
  35621. // }
  35622. //
  35623. // } else {
  35624. //
  35625. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35626. // var dat map[string]interface{}
  35627. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35628. // fmt.Println(dat)
  35629. // } else {
  35630. // fmt.Println(err)
  35631. // }
  35632. // userJSONBytes, _ := json.Marshal(dat)
  35633. // var res ResultTwo
  35634. // var res10265 ResultTwo10265
  35635. // if miConfig.Code == "H15049901371" {
  35636. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35637. // utils.ErrorLog("解析失败:%v", err)
  35638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35639. // return
  35640. // }
  35641. // res.ErrMsg = res10265.ErrMsg
  35642. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35643. // res.Infcode = infocode
  35644. // res.Output = res10265.Output
  35645. // res.InfRefmsgid = res10265.InfRefmsgid
  35646. // } else {
  35647. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35648. // utils.ErrorLog("解析失败:%v", err)
  35649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35650. // return
  35651. // }
  35652. // }
  35653. //
  35654. // var user_name string
  35655. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35656. // if role.ID == 0 {
  35657. // user_name = "xxx"
  35658. // } else {
  35659. // user_name = role.UserName
  35660. // }
  35661. //
  35662. // baseParams := models.BaseParams{
  35663. // SecretKey: miConfig.SecretKey,
  35664. // FixmedinsCode: miConfig.Code,
  35665. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35666. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35667. // OrgName: miConfig.OrgName,
  35668. // Doctor: user_name,
  35669. // }
  35670. //
  35671. // if config.IsOpen == 1 {
  35672. // if miConfig.Code == "H15049901371" {
  35673. // if med_type == "14" {
  35674. // if insutype == "390" {
  35675. // med_type = "9933"
  35676. // } else if insutype == "310" {
  35677. // med_type = "990502"
  35678. // }
  35679. // } else if med_type == "11" {
  35680. // med_type = "11"
  35681. // }
  35682. // }
  35683. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35684. // var dat map[string]interface{}
  35685. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35686. // fmt.Println(dat)
  35687. // } else {
  35688. // fmt.Println(err)
  35689. // }
  35690. // var res Result2001
  35691. // var res10265 Result2001Org10265
  35692. // if miConfig.Code == "H15049901371" {
  35693. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35694. // utils.ErrorLog("解析失败:%v", err)
  35695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35696. // return
  35697. // }
  35698. // res.ErrMsg = res10265.ErrMsg
  35699. // res.Output = res10265.Output
  35700. // res.InfRefmsgid = res10265.InfRefmsgid
  35701. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35702. // res.Infcode = infocode
  35703. // } else {
  35704. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35705. // utils.ErrorLog("解析失败:%v", err)
  35706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35707. // return
  35708. // }
  35709. // }
  35710. // if res.Infcode == 0 {
  35711. // c.ServeSuccessJSON(map[string]interface{}{
  35712. // "msg": res.Output.Trtinfo,
  35713. // })
  35714. // }
  35715. // }
  35716. // }
  35717. //}
  35718. //func (c *HisApiController) PutRecord() {
  35719. // id, _ := c.GetInt64("id")
  35720. // record_time := c.GetString("record_time")
  35721. // timeLayout := "2006-01-02"
  35722. // loc, _ := time.LoadLocation("Local")
  35723. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35724. // if err != nil {
  35725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35726. // return
  35727. // }
  35728. // recordDateTime := theTime.Unix()
  35729. //
  35730. // adminInfo := c.GetAdminUserInfo()
  35731. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35732. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35733. //
  35734. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35735. //
  35736. // fmt.Println(miConfig.SecretKey)
  35737. //
  35738. // if patient == nil {
  35739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35740. // return
  35741. // }
  35742. // if len(patient.IdCardNo) == 0 {
  35743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35744. // return
  35745. // }
  35746. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35747. // if config.IsOpen == 1 {
  35748. // 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
  35749. // resp, requestErr := http.Get(api)
  35750. // if requestErr != nil {
  35751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35752. // return
  35753. // }
  35754. // defer resp.Body.Close()
  35755. // body, ioErr := ioutil.ReadAll(resp.Body)
  35756. // if ioErr != nil {
  35757. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35759. // return
  35760. // }
  35761. // var respJSON map[string]interface{}
  35762. //
  35763. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35764. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35766. // return
  35767. // }
  35768. //
  35769. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35770. // userJSONBytes, _ := json.Marshal(userJSON)
  35771. // var res ResultTwo
  35772. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35773. // utils.ErrorLog("解析失败:%v", err)
  35774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35775. // return
  35776. // }
  35777. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35778. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35779. // infoStr := string(Iinfos)
  35780. // idetinfoStr := string(Idetinfos)
  35781. //
  35782. // if res.Infcode == 0 {
  35783. // his := models.VMHisPatient{
  35784. // Status: 1,
  35785. // Ctime: time.Now().Unix(),
  35786. // Mtime: time.Now().Unix(),
  35787. // PsnNo: res.Output.Baseinfo.PsnNo,
  35788. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35789. // Certno: res.Output.Baseinfo.Certno,
  35790. // PsnName: res.Output.Baseinfo.PsnName,
  35791. // Gend: res.Output.Baseinfo.Gend,
  35792. // Naty: res.Output.Baseinfo.Naty,
  35793. // Brdy: res.Output.Baseinfo.Brdy,
  35794. // Age: res.Output.Baseinfo.Age,
  35795. // Iinfo: infoStr,
  35796. // Idetinfo: idetinfoStr,
  35797. // PatientId: patient.ID,
  35798. // RecordDate: theTime.Unix(),
  35799. // UserOrgId: adminInfo.CurrentOrgId,
  35800. // AdminUserId: adminInfo.AdminUser.Id,
  35801. // IsReturn: 1,
  35802. // }
  35803. //
  35804. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35805. // //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")
  35806. // //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")
  35807. //
  35808. // //var dat map[string]interface{}
  35809. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35810. // // fmt.Println(dat)
  35811. // //} else {
  35812. // // fmt.Println(err)
  35813. // //}
  35814. //
  35815. // var dat2 map[string]interface{}
  35816. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35817. // fmt.Println(dat2)
  35818. // } else {
  35819. // fmt.Println(err)
  35820. // }
  35821. //
  35822. // } else {
  35823. // adminUser := c.GetAdminUserInfo()
  35824. // errlog := &models.HisOrderError{
  35825. // UserOrgId: adminUser.CurrentOrgId,
  35826. // Ctime: time.Now().Unix(),
  35827. // Mtime: time.Now().Unix(),
  35828. // ErrMsg: res.ErrMsg,
  35829. // Status: 1,
  35830. // PatientId: id,
  35831. // RecordTime: recordDateTime,
  35832. // Stage: 1,
  35833. // }
  35834. // service.CreateErrMsgLog(errlog)
  35835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35836. // return
  35837. // }
  35838. // }
  35839. //
  35840. //}
  35841. //func (c *HisApiController) GetUploadDiag() {
  35842. // id, _ := c.GetInt64("id")
  35843. // record_time := c.GetString("record_time")
  35844. //
  35845. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35846. // sick_type, _ := c.GetInt64("sick_type")
  35847. // reg_type, _ := c.GetInt64("reg_type")
  35848. //
  35849. // timeLayout := "2006-01-02"
  35850. // loc, _ := time.LoadLocation("Local")
  35851. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35852. // if err != nil {
  35853. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35854. // return
  35855. // }
  35856. //
  35857. // var patientPrescription models.HisPrescriptionInfo
  35858. // recordDateTime := theTime.Unix()
  35859. // adminInfo := c.GetAdminUserInfo()
  35860. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35861. //
  35862. // if patientPrescription.ID == 0 {
  35863. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35864. // }
  35865. //
  35866. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35867. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35868. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35869. // sickConfig, _ := service.FindSickById(sick_type)
  35870. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35871. //
  35872. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35873. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35874. // "&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 +
  35875. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35876. // resp2, requestErr2 := http.Get(api2)
  35877. // if requestErr2 != nil {
  35878. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35879. // return
  35880. // }
  35881. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35882. // if ioErr2 != nil {
  35883. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35885. // return
  35886. // }
  35887. // var respJSON2 map[string]interface{}
  35888. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35889. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35891. // return
  35892. // }
  35893. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35894. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35895. //
  35896. // var res2 ResultSix
  35897. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35898. // utils.ErrorLog("解析失败:%v", err)
  35899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35900. // return
  35901. // }
  35902. // if res2.Infcode != 0 {
  35903. // adminUser := c.GetAdminUserInfo()
  35904. // errlog := &models.HisOrderError{
  35905. // UserOrgId: adminUser.CurrentOrgId,
  35906. // Ctime: time.Now().Unix(),
  35907. // Mtime: time.Now().Unix(),
  35908. // ErrMsg: res2.ErrMsg,
  35909. // Status: 1,
  35910. // PatientId: id,
  35911. // RecordTime: recordDateTime,
  35912. // Stage: 3,
  35913. // }
  35914. // service.CreateErrMsgLog(errlog)
  35915. //
  35916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35917. // return
  35918. // }
  35919. //
  35920. // c.ServeSuccessJSON(map[string]interface{}{
  35921. // "msg": "上传成功",
  35922. // })
  35923. //
  35924. //}
  35925. type QueryResult struct {
  35926. ID int64
  35927. Name string
  35928. Code string
  35929. List_type_code string
  35930. }
  35931. func (c *HisApiController) GetCheckCode() {
  35932. ids_str := c.GetString("ids")
  35933. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35934. ids_arr := strings.Split(ids_str, ",")
  35935. var queryResult []QueryResult
  35936. ids := make([]int64, 0)
  35937. for _, item := range ids_arr {
  35938. id, _ := strconv.ParseInt(item, 10, 64)
  35939. ids = append(ids, id)
  35940. }
  35941. if record_type == 1 {
  35942. drugs, _ := service.GetBatchDrugList(ids)
  35943. for _, item := range drugs {
  35944. result := QueryResult{
  35945. ID: item.ID,
  35946. Name: item.DrugName,
  35947. Code: item.MedicalInsuranceNumber,
  35948. List_type_code: "101",
  35949. }
  35950. queryResult = append(queryResult, result)
  35951. }
  35952. } else if record_type == 2 {
  35953. goods, _ := service.GetBatchGoodInformationList(ids)
  35954. fmt.Println(goods)
  35955. for _, item := range goods {
  35956. result := QueryResult{
  35957. ID: item.ID,
  35958. Name: item.GoodName,
  35959. Code: item.SocialSecurityDirectoryCode,
  35960. List_type_code: "301",
  35961. }
  35962. queryResult = append(queryResult, result)
  35963. }
  35964. } else if record_type == 3 {
  35965. projects, _ := service.GetBathchMyPorjecgList(ids)
  35966. for _, item := range projects {
  35967. result := QueryResult{
  35968. ID: item.ID,
  35969. Name: item.ProjectName,
  35970. Code: item.MedicalCode,
  35971. List_type_code: "201",
  35972. }
  35973. queryResult = append(queryResult, result)
  35974. }
  35975. }
  35976. admin_user_id, _ := c.GetInt64("admin_user_id")
  35977. adminUser := c.GetAdminUserInfo()
  35978. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35979. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35980. var user_name string
  35981. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35982. if role.ID == 0 {
  35983. user_name = "管理员"
  35984. } else {
  35985. user_name = role.UserName
  35986. }
  35987. baseParams := models.BaseParams{
  35988. SecretKey: miConfig.SecretKey,
  35989. FixmedinsCode: miConfig.Code,
  35990. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35991. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35992. OrgName: miConfig.OrgName,
  35993. Doctor: user_name,
  35994. }
  35995. var result string
  35996. if miConfig.MdtrtareaAdmvs == "430800" {
  35997. for _, item := range queryResult {
  35998. if record_type == 1 {
  35999. 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)
  36000. } else if record_type == 2 {
  36001. fmt.Println(item.Code)
  36002. 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)
  36003. } else if record_type == 3 {
  36004. 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)
  36005. }
  36006. var dat map[string]interface{}
  36007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36008. fmt.Println(dat)
  36009. } else {
  36010. fmt.Println(err)
  36011. }
  36012. userJSONBytes, _ := json.Marshal(dat)
  36013. var res ResultSix
  36014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36015. utils.ErrorLog("解析失败:%v", err)
  36016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36017. return
  36018. }
  36019. if res.Infcode == 0 {
  36020. if record_type == 1 {
  36021. service.UpdateBaseDrugById(item.ID)
  36022. } else if record_type == 2 {
  36023. service.UpdateGoodInformaitonByDetail(item.ID)
  36024. } else if record_type == 3 {
  36025. service.UpdateProjectById(item.ID)
  36026. }
  36027. c.ServeSuccessJSON(map[string]interface{}{
  36028. "failed_code": 0,
  36029. "msg": "目录对照成功",
  36030. })
  36031. } else {
  36032. c.ServeSuccessJSON(map[string]interface{}{
  36033. "failed_code": -10,
  36034. "msg": res.ErrMsg,
  36035. })
  36036. }
  36037. }
  36038. } else {
  36039. for _, item := range queryResult {
  36040. var result string
  36041. if record_type == 1 {
  36042. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36043. } else if record_type == 2 {
  36044. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36045. } else if record_type == 3 {
  36046. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36047. }
  36048. var dat map[string]interface{}
  36049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36050. fmt.Println(dat)
  36051. } else {
  36052. fmt.Println(err)
  36053. }
  36054. userJSONBytes, _ := json.Marshal(dat)
  36055. var res ResultSix
  36056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36057. utils.ErrorLog("解析失败:%v", err)
  36058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36059. return
  36060. }
  36061. if res.Infcode == 0 {
  36062. if record_type == 1 {
  36063. service.UpdateBaseDrugById(item.ID)
  36064. } else if record_type == 2 {
  36065. service.UpdateGoodInformaitonByDetail(item.ID)
  36066. } else if record_type == 3 {
  36067. service.UpdateProjectById(item.ID)
  36068. }
  36069. c.ServeSuccessJSON(map[string]interface{}{
  36070. "failed_code": 0,
  36071. "msg": "目录对照成功",
  36072. })
  36073. } else {
  36074. c.ServeSuccessJSON(map[string]interface{}{
  36075. "failed_code": -10,
  36076. "msg": res.ErrMsg,
  36077. })
  36078. }
  36079. }
  36080. }
  36081. }
  36082. func (c *HisApiController) UnCheckCode() {
  36083. ids_str := c.GetString("ids")
  36084. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36085. admin_user_id, _ := c.GetInt64("admin_user_id")
  36086. ids_arr := strings.Split(ids_str, ",")
  36087. var queryResult []QueryResult
  36088. ids := make([]int64, 0)
  36089. for _, item := range ids_arr {
  36090. id, _ := strconv.ParseInt(item, 10, 64)
  36091. ids = append(ids, id)
  36092. }
  36093. if record_type == 1 {
  36094. drugs, _ := service.GetBatchDrugList(ids)
  36095. for _, item := range drugs {
  36096. result := QueryResult{
  36097. ID: item.ID,
  36098. Name: item.DrugName,
  36099. Code: item.MedicalInsuranceNumber,
  36100. List_type_code: "101",
  36101. }
  36102. queryResult = append(queryResult, result)
  36103. }
  36104. } else if record_type == 2 {
  36105. goods, _ := service.GetBatchGoodInformationList(ids)
  36106. for _, item := range goods {
  36107. result := QueryResult{
  36108. ID: item.ID,
  36109. Name: item.GoodName,
  36110. Code: item.SocialSecurityDirectoryCode,
  36111. List_type_code: "301",
  36112. }
  36113. queryResult = append(queryResult, result)
  36114. }
  36115. } else if record_type == 3 {
  36116. projects, _ := service.GetBathchMyPorjecgList(ids)
  36117. for _, item := range projects {
  36118. result := QueryResult{
  36119. ID: item.ID,
  36120. Name: item.ProjectName,
  36121. Code: item.MedicalCode,
  36122. List_type_code: "201",
  36123. }
  36124. queryResult = append(queryResult, result)
  36125. }
  36126. }
  36127. adminUser := c.GetAdminUserInfo()
  36128. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36129. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36130. var user_name string
  36131. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36132. if role.ID == 0 {
  36133. user_name = "xxx"
  36134. } else {
  36135. user_name = role.UserName
  36136. }
  36137. baseParams := &models.BaseParams{
  36138. SecretKey: miConfig.SecretKey,
  36139. FixmedinsCode: miConfig.Code,
  36140. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36141. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36142. OrgName: miConfig.OrgName,
  36143. Doctor: user_name,
  36144. }
  36145. if config.IsOpen == 1 {
  36146. if miConfig.MdtrtareaAdmvs == "430800" {
  36147. for _, item := range queryResult {
  36148. var result string
  36149. if record_type == 1 {
  36150. 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)
  36151. } else if record_type == 2 {
  36152. fmt.Println(item.Code)
  36153. 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)
  36154. } else if record_type == 3 {
  36155. 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)
  36156. }
  36157. var dat map[string]interface{}
  36158. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36159. fmt.Println(dat)
  36160. } else {
  36161. fmt.Println(err)
  36162. }
  36163. userJSONBytes, _ := json.Marshal(dat)
  36164. var res ResultSix
  36165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36166. utils.ErrorLog("解析失败:%v", err)
  36167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36168. return
  36169. }
  36170. if res.Infcode == 0 {
  36171. if record_type == 1 {
  36172. service.UpdateBaseDrugById(item.ID)
  36173. } else if record_type == 2 {
  36174. service.UpdateGoodInformaitonByDetail(item.ID)
  36175. } else if record_type == 3 {
  36176. service.UpdateProjectById(item.ID)
  36177. }
  36178. c.ServeSuccessJSON(map[string]interface{}{
  36179. "failed_code": 0,
  36180. "msg": "目录对照成功",
  36181. })
  36182. } else {
  36183. c.ServeSuccessJSON(map[string]interface{}{
  36184. "failed_code": -10,
  36185. "msg": res.ErrMsg,
  36186. })
  36187. }
  36188. }
  36189. } else {
  36190. for _, item := range queryResult {
  36191. var result string
  36192. if record_type == 1 {
  36193. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36194. } else if record_type == 2 {
  36195. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36196. } else if record_type == 3 {
  36197. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36198. }
  36199. var dat2 map[string]interface{}
  36200. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36201. fmt.Println(dat2)
  36202. } else {
  36203. fmt.Println(err)
  36204. }
  36205. userJSONBytes, _ := json.Marshal(dat2)
  36206. var res ResultSix
  36207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36208. utils.ErrorLog("解析失败:%v", err)
  36209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36210. return
  36211. }
  36212. if res.Infcode == 0 {
  36213. if record_type == 1 {
  36214. service.UpdateDrugByIdDetail(item.ID)
  36215. } else if record_type == 2 {
  36216. service.UpdateGoodInfoById(item.ID)
  36217. } else if record_type == 3 {
  36218. service.UpdateMyProjectById(item.ID)
  36219. }
  36220. c.ServeSuccessJSON(map[string]interface{}{
  36221. "failed_code": 0,
  36222. "msg": "撤销目录对照成功",
  36223. })
  36224. } else {
  36225. c.ServeSuccessJSON(map[string]interface{}{
  36226. "failed_code": -10,
  36227. "msg": res.ErrMsg,
  36228. })
  36229. }
  36230. }
  36231. }
  36232. }
  36233. }
  36234. func (c *HisApiController) GetPatientInfo() {
  36235. id_card_no := c.GetString("id_card_no")
  36236. admin_user_id, _ := c.GetInt64("admin_user_id")
  36237. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36238. if patient.ID == 0 {
  36239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36240. return
  36241. }
  36242. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36243. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36244. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36245. var res ResultTwo
  36246. var res10265 ResultTwo10265
  36247. if config.IsOpen == 1 {
  36248. if miConfig.MdtrtareaAdmvs == "150499" {
  36249. //请求内网数据
  36250. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36251. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36252. "&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
  36253. resp, requestErr := http.Get(api)
  36254. if requestErr != nil {
  36255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36256. return
  36257. }
  36258. body, ioErr := ioutil.ReadAll(resp.Body)
  36259. if ioErr != nil {
  36260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36262. return
  36263. }
  36264. var respJSON map[string]interface{}
  36265. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36268. return
  36269. }
  36270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36271. result_byte, _ := json.Marshal(respJSON)
  36272. result := string(result_byte)
  36273. var dat map[string]interface{}
  36274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36275. fmt.Println(dat)
  36276. } else {
  36277. fmt.Println(err)
  36278. }
  36279. userJSONBytes, _ := json.Marshal(dat)
  36280. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36281. utils.ErrorLog("解析失败:%v", err)
  36282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36283. return
  36284. }
  36285. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36286. res.Infcode = Infcode
  36287. res.ErrMsg = res10265.ErrMsg
  36288. res.Output = res10265.Output
  36289. res.InfRefmsgid = res10265.InfRefmsgid
  36290. res.RespondTime = res10265.RespondTime
  36291. res.WarnInfo = res10265.WarnInfo
  36292. } else {
  36293. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36294. var dat map[string]interface{}
  36295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36296. fmt.Println(dat)
  36297. } else {
  36298. fmt.Println(err)
  36299. }
  36300. userJSONBytes, _ := json.Marshal(dat)
  36301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36302. utils.ErrorLog("解析失败:%v", err)
  36303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36304. return
  36305. }
  36306. }
  36307. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36308. // utils.ErrorLog("解析失败:%v", err)
  36309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36310. // return
  36311. //}
  36312. for index, item := range res.Output.Iinfo {
  36313. if item.PsnInsuStas == "2" {
  36314. fmt.Println("--------")
  36315. res.Output.Iinfo[index].Insutype = "300"
  36316. res.Output.Iinfo[index].PsnInsuStas = "1"
  36317. }
  36318. }
  36319. fmt.Println(res.Output.Iinfo)
  36320. if res.Infcode != 0 {
  36321. c.ServeSuccessJSON(map[string]interface{}{
  36322. "failed_code": -10,
  36323. "msg": res.ErrMsg,
  36324. })
  36325. } else {
  36326. c.ServeSuccessJSON(map[string]interface{}{
  36327. "failed_code": 0,
  36328. "info": res,
  36329. })
  36330. }
  36331. }
  36332. }
  36333. func (c *HisApiController) PsnPutOnRecord() {
  36334. record_type, _ := c.GetInt64("type")
  36335. patient_id, _ := c.GetInt64("patient_id")
  36336. admin_user_id, _ := c.GetInt64("admin_user_id")
  36337. start_time := c.GetString("start_time")
  36338. end_time := c.GetString("end_time")
  36339. adminUser := c.GetAdminUserInfo()
  36340. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36341. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36342. var patients []*models.Patients
  36343. if record_type == 1 { //全部备案
  36344. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36345. patients = append(patients, patient...)
  36346. } else { //单个备案
  36347. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36348. patients = append(patients, patient)
  36349. }
  36350. var user_name string
  36351. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36352. if role.ID == 0 {
  36353. user_name = "xxx"
  36354. } else {
  36355. user_name = role.UserName
  36356. }
  36357. if config.IsOpen == 1 {
  36358. for _, item := range patients {
  36359. 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
  36360. resp, requestErr := http.Get(api)
  36361. if requestErr != nil {
  36362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36363. return
  36364. }
  36365. defer resp.Body.Close()
  36366. body, ioErr := ioutil.ReadAll(resp.Body)
  36367. if ioErr != nil {
  36368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36370. return
  36371. }
  36372. var respJSON map[string]interface{}
  36373. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36376. return
  36377. }
  36378. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36379. userJSONBytes, _ := json.Marshal(userJSON)
  36380. var res ResultTwo
  36381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36382. utils.ErrorLog("解析失败:%v", err)
  36383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36384. return
  36385. }
  36386. if res.Infcode == 0 {
  36387. 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)
  36388. var dat map[string]interface{}
  36389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36390. fmt.Println(dat)
  36391. } else {
  36392. fmt.Println(err)
  36393. }
  36394. userJSONBytes, _ := json.Marshal(dat)
  36395. var res2 ResultThirteen
  36396. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36397. utils.ErrorLog("解析失败:%v", err)
  36398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36399. return
  36400. }
  36401. if res2.Infcode == 0 {
  36402. psnResult := &models.GdybPsnRecord{
  36403. UserOrgId: adminUser.CurrentOrgId,
  36404. PatientId: item.ID,
  36405. PsnNo: res.Output.Baseinfo.PsnNo,
  36406. Ctime: time.Now().Unix(),
  36407. Mtime: time.Now().Unix(),
  36408. Status: 1,
  36409. IsCancel: 1,
  36410. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36411. }
  36412. service.CreatePsnRecord(psnResult)
  36413. } else {
  36414. c.ServeSuccessJSON(map[string]interface{}{
  36415. "failed_code": -10,
  36416. "msg": res2.ErrMsg,
  36417. })
  36418. return
  36419. }
  36420. }
  36421. }
  36422. }
  36423. }
  36424. func (c *HisApiController) PsnUnPutOnRecord() {
  36425. id, _ := c.GetInt64("id")
  36426. //record_type, _ := c.GetInt64("type")
  36427. admin_user_id, _ := c.GetInt64("admin_user_id")
  36428. adminUser := c.GetAdminUserInfo()
  36429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36430. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36431. var user_name string
  36432. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36433. if role.ID == 0 {
  36434. user_name = "xxx"
  36435. } else {
  36436. user_name = role.UserName
  36437. }
  36438. psn_record, _ := service.GetPsnRecordById(id)
  36439. if psn_record.ID == 0 {
  36440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36441. return
  36442. }
  36443. if config.IsOpen == 1 {
  36444. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36445. var dat map[string]interface{}
  36446. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36447. fmt.Println(dat)
  36448. } else {
  36449. fmt.Println(err)
  36450. }
  36451. userJSONBytes, _ := json.Marshal(dat)
  36452. var res ResultFourteen
  36453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36454. utils.ErrorLog("解析失败:%v", err)
  36455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36456. return
  36457. }
  36458. if res.Infcode == 0 {
  36459. psn_record.IsCancel = 2
  36460. service.CreatePsnRecord(&psn_record)
  36461. } else {
  36462. c.ServeSuccessJSON(map[string]interface{}{
  36463. "failed_code": -10,
  36464. "msg": res.ErrMsg,
  36465. })
  36466. return
  36467. }
  36468. }
  36469. }
  36470. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36471. patient_id, _ := c.GetInt64("patient_id")
  36472. insutype_two := c.GetString("insutype")
  36473. psn_no := c.GetString("psn_no")
  36474. doctor_id, _ := c.GetInt64("doctor_id")
  36475. sick_id, _ := c.GetInt64("sick_id")
  36476. department_id, _ := c.GetInt64("department_id")
  36477. start_time := c.GetString("start_time")
  36478. end_time := c.GetString("end_time")
  36479. check_time := c.GetString("check_time")
  36480. hospital_code := c.GetString("hospital_code")
  36481. hospital_name := c.GetString("hospital_name")
  36482. adminUser := c.GetAdminUserInfo()
  36483. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36484. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36485. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36486. sick, _ := service.FindSickById(sick_id)
  36487. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36488. if len(hospital_code) == 0 {
  36489. hospital_code = miConfig.Code
  36490. }
  36491. if len(hospital_name) == 0 {
  36492. hospital_name = miConfig.OrgName
  36493. }
  36494. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36495. var res ResultTwo
  36496. var res10265 ResultTwo10265
  36497. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36498. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36499. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36500. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36501. "&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
  36502. resp, requestErr := http.Get(api)
  36503. if requestErr != nil {
  36504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36505. return
  36506. }
  36507. body, ioErr := ioutil.ReadAll(resp.Body)
  36508. if ioErr != nil {
  36509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36511. return
  36512. }
  36513. var respJSON map[string]interface{}
  36514. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36517. return
  36518. }
  36519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36520. result, _ := json.Marshal(respJSON)
  36521. fmt.Println("log")
  36522. fmt.Println(string(result))
  36523. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36524. utils.ErrorLog("解析失败:%v", err)
  36525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36526. return
  36527. }
  36528. res.ErrMsg = res10265.ErrMsg
  36529. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36530. res.Infcode = infocode
  36531. res.Output = res10265.Output
  36532. res.InfRefmsgid = res10265.InfRefmsgid
  36533. } else {
  36534. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36535. if miConfig.Code == "H15049901371" {
  36536. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36537. utils.ErrorLog("解析失败:%v", err)
  36538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36539. return
  36540. }
  36541. res.ErrMsg = res10265.ErrMsg
  36542. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36543. res.Infcode = infocode
  36544. res.Output = res10265.Output
  36545. res.InfRefmsgid = res10265.InfRefmsgid
  36546. } else {
  36547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36548. utils.ErrorLog("解析失败:%v", err)
  36549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36550. return
  36551. }
  36552. }
  36553. }
  36554. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36555. infoStr := string(Iinfos)
  36556. var rf []*ResultFive
  36557. json.Unmarshal([]byte(infoStr), &rf)
  36558. var insuplc_admdvs string
  36559. var insutype string
  36560. var is390 int = 0
  36561. var is310 int = 0
  36562. var insutypes []*ResultFive
  36563. for _, item := range rf {
  36564. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36565. insutypes = append(insutypes, item)
  36566. }
  36567. }
  36568. if len(insutypes) == 1 {
  36569. insutype = insutypes[0].Insutype
  36570. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36571. } else {
  36572. for _, i := range insutypes {
  36573. if i.Insutype == "390" {
  36574. is390 = 1
  36575. }
  36576. if i.Insutype == "310" {
  36577. is310 = 1
  36578. }
  36579. }
  36580. }
  36581. if is390 == 1 {
  36582. insutype = "390"
  36583. }
  36584. if is310 == 1 {
  36585. insutype = "310"
  36586. }
  36587. if len(insutypes) == 2 {
  36588. insutype = insutype_two
  36589. }
  36590. if len(insutypes) == 0 {
  36591. insutype = "310"
  36592. }
  36593. insutype = insutype_two
  36594. fmt.Println(insutype)
  36595. for _, item := range rf {
  36596. fmt.Println(item.Insutype)
  36597. fmt.Println(insutype)
  36598. if item.Insutype == insutype {
  36599. fmt.Println(item.Insutype)
  36600. fmt.Println(insutype)
  36601. insuplc_admdvs = item.InsuplcAdmdvs
  36602. }
  36603. }
  36604. fmt.Println(insuplc_admdvs)
  36605. var res2 ResultThirteen
  36606. var res10265_2 ResultThirteen10265
  36607. if config.IsOpen == 1 {
  36608. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36609. } else {
  36610. if miConfig.MdtrtareaAdmvs == "150499" {
  36611. //
  36612. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36613. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36614. // "&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
  36615. //resp, requestErr := http.Get(api)
  36616. //if requestErr != nil {
  36617. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36618. // return
  36619. //}
  36620. //
  36621. //body, ioErr := ioutil.ReadAll(resp.Body)
  36622. //if ioErr != nil {
  36623. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36625. // return
  36626. //}
  36627. //var respJSON map[string]interface{}
  36628. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36629. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36631. // return
  36632. //}
  36633. //
  36634. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36635. //result, _ := json.Marshal(respJSON)
  36636. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36637. // utils.ErrorLog("解析失败:%v", err)
  36638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36639. // return
  36640. //}
  36641. //infocode = resThree.Infcode
  36642. //result, _ := json.Marshal(respJSON)
  36643. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36644. // utils.ErrorLog("解析失败:%v", err)
  36645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36646. // return
  36647. //}
  36648. //
  36649. //resThree.ErrMsg = resThree10265.ErrMsg
  36650. //
  36651. //resThree.Output = resThree10265.Output
  36652. //
  36653. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36654. //
  36655. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36656. //
  36657. } else {
  36658. 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)
  36659. var dat map[string]interface{}
  36660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36661. fmt.Println(dat)
  36662. } else {
  36663. fmt.Println(err)
  36664. }
  36665. userJSONBytes, _ := json.Marshal(dat)
  36666. if miConfig.Code == "H15049901371" {
  36667. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36668. utils.ErrorLog("解析失败:%v", err)
  36669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36670. return
  36671. }
  36672. res2.ErrMsg = res10265_2.ErrMsg
  36673. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36674. res2.Infcode = infocode
  36675. res2.Output = res10265_2.Output
  36676. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36677. } else {
  36678. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36679. utils.ErrorLog("解析失败:%v", err)
  36680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36681. return
  36682. }
  36683. }
  36684. }
  36685. }
  36686. if res2.Infcode == 0 {
  36687. psnResult := &models.GdybPsnNcdsRecord{
  36688. UserOrgId: adminUser.CurrentOrgId,
  36689. PatientId: patient.ID,
  36690. PsnNo: psn_no,
  36691. DoctorId: doctor.AdminUserId,
  36692. DepartmentId: department_id,
  36693. SickType: sick_id,
  36694. Insutype: insutype,
  36695. Ctime: time.Now().Unix(),
  36696. Mtime: time.Now().Unix(),
  36697. Status: 1,
  36698. IsCancel: 1,
  36699. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36700. }
  36701. service.CreatePsnNCDSRecord(psnResult)
  36702. c.ServeSuccessJSON(map[string]interface{}{
  36703. "failed_code": 0,
  36704. "msg": "备案成功",
  36705. "result": psnResult,
  36706. })
  36707. } else {
  36708. c.ServeSuccessJSON(map[string]interface{}{
  36709. "failed_code": -10,
  36710. "msg": res2.ErrMsg,
  36711. })
  36712. return
  36713. }
  36714. }
  36715. }
  36716. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36717. id, _ := c.GetInt64("id")
  36718. admin_user_id, _ := c.GetInt64("admin_user_id")
  36719. adminUser := c.GetAdminUserInfo()
  36720. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36721. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36722. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36723. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36724. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36725. //var user_name string
  36726. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36727. //if role.ID == 0 {
  36728. // user_name = "xxx"
  36729. //} else {
  36730. // user_name = role.UserName
  36731. //}
  36732. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36733. if psn_record.ID == 0 {
  36734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36735. return
  36736. }
  36737. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36738. var res ResultTwo
  36739. var res10265 ResultTwo10265
  36740. if miConfig.Code == "H15049901371" {
  36741. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36742. utils.ErrorLog("解析失败:%v", err)
  36743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36744. return
  36745. }
  36746. res.ErrMsg = res10265.ErrMsg
  36747. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36748. res.Infcode = infocode
  36749. res.Output = res10265.Output
  36750. res.InfRefmsgid = res10265.InfRefmsgid
  36751. } else {
  36752. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36753. utils.ErrorLog("解析失败:%v", err)
  36754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36755. return
  36756. }
  36757. }
  36758. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36759. infoStr := string(Iinfos)
  36760. var rf []*ResultFive
  36761. json.Unmarshal([]byte(infoStr), &rf)
  36762. var insuplc_admdvs string
  36763. var insutype string
  36764. var is390 int = 0
  36765. var is310 int = 0
  36766. var insutypes []*ResultFive
  36767. for _, item := range rf {
  36768. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36769. insutypes = append(insutypes, item)
  36770. }
  36771. }
  36772. if len(insutypes) == 1 {
  36773. insutype = insutypes[0].Insutype
  36774. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36775. } else {
  36776. for _, i := range insutypes {
  36777. if i.Insutype == "390" {
  36778. is390 = 1
  36779. }
  36780. if i.Insutype == "310" {
  36781. is310 = 1
  36782. }
  36783. }
  36784. }
  36785. if is390 == 1 {
  36786. insutype = "390"
  36787. }
  36788. if is310 == 1 {
  36789. insutype = "310"
  36790. }
  36791. if len(insutypes) == 0 {
  36792. insutype = "310"
  36793. }
  36794. insutype = psn_record.Insutype
  36795. for _, item := range rf {
  36796. if item.Insutype == insutype {
  36797. insuplc_admdvs = item.InsuplcAdmdvs
  36798. }
  36799. }
  36800. if config.IsOpen == 1 {
  36801. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36802. var dat map[string]interface{}
  36803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36804. fmt.Println(dat)
  36805. } else {
  36806. fmt.Println(err)
  36807. }
  36808. userJSONBytes, _ := json.Marshal(dat)
  36809. var res ResultFourteen
  36810. var res10265 ResultFourteen10265
  36811. if miConfig.Code == "H15049901371" {
  36812. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36813. utils.ErrorLog("解析失败:%v", err)
  36814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36815. return
  36816. }
  36817. res.ErrMsg = res10265.ErrMsg
  36818. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36819. res.Infcode = infocode
  36820. res.Output = res10265.Output
  36821. res.InfRefmsgid = res10265.InfRefmsgid
  36822. } else {
  36823. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36824. utils.ErrorLog("解析失败:%v", err)
  36825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36826. return
  36827. }
  36828. }
  36829. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36830. // utils.ErrorLog("解析失败:%v", err)
  36831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36832. // return
  36833. //}
  36834. if res.Infcode == 0 {
  36835. psn_record.IsCancel = 2
  36836. service.CreatePsnNCDSRecord(&psn_record)
  36837. c.ServeSuccessJSON(map[string]interface{}{
  36838. "failed_code": 0,
  36839. "msg": "撤销备案成功",
  36840. })
  36841. } else {
  36842. c.ServeSuccessJSON(map[string]interface{}{
  36843. "failed_code": -10,
  36844. "msg": res.ErrMsg,
  36845. })
  36846. return
  36847. }
  36848. }
  36849. }
  36850. func (c *HisApiController) TestTest() {
  36851. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36852. fmt.Println(patient.Iinfo)
  36853. }
  36854. type CustomData struct {
  36855. MsgId string
  36856. PsnNo string
  36857. Info string
  36858. }
  36859. func (c *HisApiController) ReversalData() {
  36860. var customData []*CustomData
  36861. custom := &CustomData{
  36862. MsgId: "H44022900158202103301714472004",
  36863. PsnNo: "44020000001101329945",
  36864. Info: "2207",
  36865. }
  36866. customData = append(customData, custom)
  36867. custom1 := &CustomData{
  36868. MsgId: "H4402290015820210330172057803",
  36869. PsnNo: "44020000001101161813",
  36870. Info: "2207",
  36871. }
  36872. customData = append(customData, custom1)
  36873. custom2 := &CustomData{
  36874. MsgId: "H44022900158202103301705198813",
  36875. PsnNo: "44190000133097375417",
  36876. Info: "2207",
  36877. }
  36878. customData = append(customData, custom2)
  36879. custom3 := &CustomData{
  36880. MsgId: "H44022900158202103301715524756",
  36881. PsnNo: "44020000001100187221",
  36882. Info: "2207",
  36883. }
  36884. customData = append(customData, custom3)
  36885. custom4 := &CustomData{
  36886. MsgId: "H44022900158202103301730376224",
  36887. PsnNo: "44020000001101959155",
  36888. Info: "2207",
  36889. }
  36890. customData = append(customData, custom4)
  36891. custom5 := &CustomData{
  36892. MsgId: "H44022900158202103301748008725",
  36893. PsnNo: "44020000001104246641",
  36894. Info: "2207",
  36895. }
  36896. customData = append(customData, custom5)
  36897. custom6 := &CustomData{
  36898. MsgId: "H44022900158202103301718096755",
  36899. PsnNo: "44020000001102211860",
  36900. Info: "2207",
  36901. }
  36902. customData = append(customData, custom6)
  36903. custom7 := &CustomData{
  36904. MsgId: "H44022900158202103301736551640",
  36905. PsnNo: "44020000001102687718",
  36906. Info: "2207",
  36907. }
  36908. customData = append(customData, custom7)
  36909. custom8 := &CustomData{
  36910. MsgId: "H44022900158202103301743097676",
  36911. PsnNo: "44020000001102127785",
  36912. Info: "2207",
  36913. }
  36914. customData = append(customData, custom8)
  36915. custom9 := &CustomData{
  36916. MsgId: "H44022900158202103301712304203",
  36917. PsnNo: "44020000001101518097",
  36918. Info: "2207",
  36919. }
  36920. customData = append(customData, custom9)
  36921. custom10 := &CustomData{
  36922. MsgId: "H44022900158202103301738448785",
  36923. PsnNo: "44020000001100500813",
  36924. Info: "2207",
  36925. }
  36926. customData = append(customData, custom10)
  36927. custom11 := &CustomData{
  36928. MsgId: "H44022900158202103301732455843",
  36929. PsnNo: "44020000001102690557",
  36930. Info: "2207",
  36931. }
  36932. customData = append(customData, custom11)
  36933. custom12 := &CustomData{
  36934. MsgId: "H44022900158202103301745421708",
  36935. PsnNo: "44020000001102211928",
  36936. Info: "2207",
  36937. }
  36938. customData = append(customData, custom12)
  36939. custom1212 := &CustomData{
  36940. MsgId: "H440229001582021033017351627",
  36941. PsnNo: "44020000001102481733",
  36942. Info: "2207",
  36943. }
  36944. customData = append(customData, custom1212)
  36945. custom13 := &CustomData{
  36946. MsgId: "H44022900158202103301740327951",
  36947. PsnNo: "44020000001103174866",
  36948. Info: "2207",
  36949. }
  36950. customData = append(customData, custom13)
  36951. custom14 := &CustomData{
  36952. MsgId: "H4402290015820210330174922668",
  36953. PsnNo: "44020000001102927272",
  36954. Info: "2207",
  36955. }
  36956. customData = append(customData, custom14)
  36957. custom15 := &CustomData{
  36958. MsgId: "H44022900158202103301752362273",
  36959. PsnNo: "44020000001102942890",
  36960. Info: "2207",
  36961. }
  36962. customData = append(customData, custom15)
  36963. custom16 := &CustomData{
  36964. MsgId: "H44022900158202103301751082917",
  36965. PsnNo: "44020000001101662162",
  36966. Info: "2207",
  36967. }
  36968. customData = append(customData, custom16)
  36969. custom17 := &CustomData{
  36970. MsgId: "H44022900158202103301754147728",
  36971. PsnNo: "44020000000229014511",
  36972. Info: "2207",
  36973. }
  36974. customData = append(customData, custom17)
  36975. adminUser := c.GetAdminUserInfo()
  36976. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36977. for _, item := range customData {
  36978. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36979. fmt.Println(result)
  36980. }
  36981. }
  36982. func (c *HisApiController) GetAllopatry() {
  36983. year := c.GetString("year")
  36984. month := c.GetString("month")
  36985. admin_user_id, _ := c.GetInt64("admin_user_id")
  36986. adminUser := c.GetAdminUserInfo()
  36987. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36988. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36989. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36990. var dat map[string]interface{}
  36991. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36992. fmt.Println(dat)
  36993. } else {
  36994. fmt.Println(err)
  36995. }
  36996. userJSONBytes, _ := json.Marshal(dat)
  36997. var res models.Result9001
  36998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36999. utils.ErrorLog("解析失败:%v", err)
  37000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37001. return
  37002. }
  37003. fmt.Println(res.Output.Signinoutb)
  37004. fmt.Println(res.Output.Signinoutb.SignNo)
  37005. fmt.Println(string(userJSONBytes))
  37006. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37007. var dat3 map[string]interface{}
  37008. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37009. fmt.Println(dat3)
  37010. } else {
  37011. fmt.Println(err)
  37012. }
  37013. userJSONBytes3, _ := json.Marshal(dat3)
  37014. var res3 models.Result3260
  37015. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37016. utils.ErrorLog("解析失败:%v", err)
  37017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37018. return
  37019. }
  37020. var curpage int
  37021. var pagesize int = 100
  37022. var start int = 1
  37023. //var stop int
  37024. //pagecount := 10
  37025. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37026. var res22 []models.Result3260
  37027. for curpage = 1; curpage <= pagecount; curpage++ {
  37028. if curpage == 1 {
  37029. start = 0
  37030. } else {
  37031. start = (curpage-1)*pagesize + 1
  37032. }
  37033. fmt.Println(start)
  37034. //stop = curpage * pagesize
  37035. //if stop > int(res3.Output.Totalrow) {
  37036. // stop =int(res3.Output.Totalrow)
  37037. //}
  37038. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37039. var dat2 map[string]interface{}
  37040. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37041. fmt.Println(dat)
  37042. } else {
  37043. fmt.Println(err)
  37044. }
  37045. userJSONBytes2, _ := json.Marshal(dat2)
  37046. var res2 models.Result3260
  37047. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37048. utils.ErrorLog("解析失败:%v", err)
  37049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37050. return
  37051. }
  37052. if res2.Infcode == 0 {
  37053. res22 = append(res22, res2)
  37054. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37055. //var dat2 map[string]interface{}
  37056. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37057. // fmt.Println(dat)
  37058. //} else {
  37059. // fmt.Println(err)
  37060. //}
  37061. //c.ServeSuccessJSON(map[string]interface{}{
  37062. // "list": res2.Output.Data,
  37063. //})
  37064. //continue
  37065. }
  37066. }
  37067. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37068. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37069. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37070. //var dat2 map[string]interface{}
  37071. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37072. // fmt.Println(dat)
  37073. //} else {
  37074. // fmt.Println(err)
  37075. //}
  37076. //userJSONBytes2, _ := json.Marshal(dat2)
  37077. //var res2 models.Result3260
  37078. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37079. // utils.ErrorLog("解析失败:%v", err)
  37080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37081. // return
  37082. //}
  37083. //if res2.Infcode == 0 {
  37084. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37085. // var dat2 map[string]interface{}
  37086. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37087. // fmt.Println(dat)
  37088. // } else {
  37089. // fmt.Println(err)
  37090. // }
  37091. // c.ServeSuccessJSON(map[string]interface{}{
  37092. // "list": res2.Output.Data,
  37093. // })
  37094. //}
  37095. }
  37096. func (c *HisApiController) ComfirmAllopatry() {
  37097. year := c.GetString("year")
  37098. month := c.GetString("month")
  37099. admin_user_id, _ := c.GetInt64("admin_user_id")
  37100. adminUser := c.GetAdminUserInfo()
  37101. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37102. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37103. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37104. var dat map[string]interface{}
  37105. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37106. fmt.Println(dat)
  37107. } else {
  37108. fmt.Println(err)
  37109. }
  37110. userJSONBytes, _ := json.Marshal(dat)
  37111. var res models.Result9001
  37112. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37113. utils.ErrorLog("解析失败:%v", err)
  37114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37115. return
  37116. }
  37117. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37118. var dat2 map[string]interface{}
  37119. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37120. fmt.Println(dat)
  37121. } else {
  37122. fmt.Println(err)
  37123. }
  37124. userJSONBytes2, _ := json.Marshal(dat2)
  37125. var res2 models.Result3260
  37126. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37127. utils.ErrorLog("解析失败:%v", err)
  37128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37129. return
  37130. }
  37131. //if res2.Infcode == 0 {
  37132. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37133. // var dat map[string]interface{}
  37134. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37135. // fmt.Println(dat)
  37136. // } else {
  37137. // fmt.Println(err)
  37138. // }
  37139. // userJSONBytes, _ := json.Marshal(dat)
  37140. // var res3 models.Result3261
  37141. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37142. // utils.ErrorLog("解析失败:%v", err)
  37143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37144. // return
  37145. // }
  37146. //
  37147. // if res3.Infcode == 0 {
  37148. // record := &models.HisYidiClearRecord{
  37149. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37150. // Ctime: time.Now().Unix(),
  37151. // Mtime: time.Now().Unix(),
  37152. // Status: 1,
  37153. // MsgId: msgId,
  37154. // }
  37155. // service.SaveClearRecord(record)
  37156. // c.ServeSuccessJSON(map[string]interface{}{
  37157. // "msg": "提取成功",
  37158. // })
  37159. // }
  37160. //}
  37161. }
  37162. func (c *HisApiController) RefundAllopatry() {
  37163. year := c.GetString("year")
  37164. month := c.GetString("month")
  37165. //id, _ := c.GetInt64("id")
  37166. admin_user_id, _ := c.GetInt64("admin_user_id")
  37167. adminUser := c.GetAdminUserInfo()
  37168. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37169. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37170. //record, _ := service.GetClearRecordById(id)
  37171. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37172. var dat map[string]interface{}
  37173. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37174. fmt.Println(dat)
  37175. } else {
  37176. fmt.Println(err)
  37177. }
  37178. userJSONBytes, _ := json.Marshal(dat)
  37179. var res models.Result9001
  37180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37181. utils.ErrorLog("解析失败:%v", err)
  37182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37183. return
  37184. }
  37185. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37186. var dat2 map[string]interface{}
  37187. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37188. fmt.Println(dat)
  37189. } else {
  37190. fmt.Println(err)
  37191. }
  37192. userJSONBytes2, _ := json.Marshal(dat2)
  37193. var empty ResultFourteen
  37194. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37195. utils.ErrorLog("解析失败:%v", err)
  37196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37197. return
  37198. }
  37199. if empty.Infcode == 0 {
  37200. c.ServeSuccessJSON(map[string]interface{}{
  37201. "msg": "撤销成功",
  37202. })
  37203. return
  37204. }
  37205. }
  37206. func (c *HisApiController) ReversalOtherData() {
  37207. var customData []*CustomData
  37208. custom := &CustomData{
  37209. MsgId: "H44022900158202103301714472004",
  37210. PsnNo: "44020000001101329945",
  37211. Info: "2208",
  37212. }
  37213. customData = append(customData, custom)
  37214. custom1 := &CustomData{
  37215. MsgId: "H4402290015820210330172057803",
  37216. PsnNo: "44020000001101161813",
  37217. Info: "2208",
  37218. }
  37219. customData = append(customData, custom1)
  37220. custom2 := &CustomData{
  37221. MsgId: "H44022900158202103301705198813",
  37222. PsnNo: "44190000133097375417",
  37223. Info: "2208",
  37224. }
  37225. customData = append(customData, custom2)
  37226. custom3 := &CustomData{
  37227. MsgId: "H44022900158202103301715524756",
  37228. PsnNo: "44020000001100187221",
  37229. Info: "2208",
  37230. }
  37231. customData = append(customData, custom3)
  37232. custom4 := &CustomData{
  37233. MsgId: "H44022900158202103301730376224",
  37234. PsnNo: "44020000001101959155",
  37235. Info: "2208",
  37236. }
  37237. customData = append(customData, custom4)
  37238. custom5 := &CustomData{
  37239. MsgId: "H44022900158202103301748008725",
  37240. PsnNo: "44020000001104246641",
  37241. Info: "2208",
  37242. }
  37243. customData = append(customData, custom5)
  37244. custom6 := &CustomData{
  37245. MsgId: "H44022900158202103301718096755",
  37246. PsnNo: "44020000001102211860",
  37247. Info: "2208",
  37248. }
  37249. customData = append(customData, custom6)
  37250. custom7 := &CustomData{
  37251. MsgId: "H44022900158202103301736551640",
  37252. PsnNo: "44020000001102687718",
  37253. Info: "2208",
  37254. }
  37255. customData = append(customData, custom7)
  37256. custom8 := &CustomData{
  37257. MsgId: "H44022900158202103301743097676",
  37258. PsnNo: "44020000001102127785",
  37259. Info: "2208",
  37260. }
  37261. customData = append(customData, custom8)
  37262. custom9 := &CustomData{
  37263. MsgId: "H44022900158202103301712304203",
  37264. PsnNo: "44020000001101518097",
  37265. Info: "2208",
  37266. }
  37267. customData = append(customData, custom9)
  37268. custom10 := &CustomData{
  37269. MsgId: "H44022900158202103301738448785",
  37270. PsnNo: "44020000001100500813",
  37271. Info: "2208",
  37272. }
  37273. customData = append(customData, custom10)
  37274. custom11 := &CustomData{
  37275. MsgId: "H44022900158202103301732455843",
  37276. PsnNo: "44020000001102690557",
  37277. Info: "2208",
  37278. }
  37279. customData = append(customData, custom11)
  37280. custom12 := &CustomData{
  37281. MsgId: "H44022900158202103301745421708",
  37282. PsnNo: "44020000001102211928",
  37283. Info: "2208",
  37284. }
  37285. customData = append(customData, custom12)
  37286. custom1212 := &CustomData{
  37287. MsgId: "H440229001582021033017351627",
  37288. PsnNo: "44020000001102481733",
  37289. Info: "2208",
  37290. }
  37291. customData = append(customData, custom1212)
  37292. custom13 := &CustomData{
  37293. MsgId: "H44022900158202103301740327951",
  37294. PsnNo: "44020000001103174866",
  37295. Info: "2208",
  37296. }
  37297. customData = append(customData, custom13)
  37298. custom14 := &CustomData{
  37299. MsgId: "H4402290015820210330174922668",
  37300. PsnNo: "44020000001102927272",
  37301. Info: "2208",
  37302. }
  37303. customData = append(customData, custom14)
  37304. custom15 := &CustomData{
  37305. MsgId: "H44022900158202103301752362273",
  37306. PsnNo: "44020000001102942890",
  37307. Info: "2208",
  37308. }
  37309. customData = append(customData, custom15)
  37310. custom16 := &CustomData{
  37311. MsgId: "H44022900158202103301751082917",
  37312. PsnNo: "44020000001101662162",
  37313. Info: "2208",
  37314. }
  37315. customData = append(customData, custom16)
  37316. custom17 := &CustomData{
  37317. MsgId: "H44022900158202103301754147728",
  37318. PsnNo: "44020000000229014511",
  37319. Info: "2208",
  37320. }
  37321. customData = append(customData, custom17)
  37322. adminUser := c.GetAdminUserInfo()
  37323. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37324. for _, item := range customData {
  37325. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37326. fmt.Println(result)
  37327. }
  37328. }
  37329. func PathExists(path string) (bool, error) {
  37330. _, err := os.Stat(path)
  37331. if err == nil {
  37332. return true, nil
  37333. }
  37334. if os.IsNotExist(err) {
  37335. return false, nil
  37336. }
  37337. return false, err
  37338. }
  37339. // 创建文件夹
  37340. func Mkdir(dir string) {
  37341. // 创建文件夹
  37342. exist, err := PathExists(dir)
  37343. if err != nil {
  37344. fmt.Println(err.Error())
  37345. } else {
  37346. if exist {
  37347. fmt.Println(dir + "文件夹已存在!")
  37348. } else {
  37349. // 文件夹名称,权限
  37350. err := os.Mkdir(dir, os.ModePerm)
  37351. if err != nil {
  37352. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37353. } else {
  37354. fmt.Println(dir + "文件夹创建成功!")
  37355. }
  37356. }
  37357. }
  37358. }
  37359. // 压缩文件
  37360. func Zip(srcFile string, destZip string) error {
  37361. zipfile, err := os.Create(destZip)
  37362. if err != nil {
  37363. return err
  37364. }
  37365. defer zipfile.Close()
  37366. archive := zip.NewWriter(zipfile)
  37367. defer archive.Close()
  37368. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37369. if err != nil {
  37370. return err
  37371. }
  37372. header, err := zip.FileInfoHeader(info)
  37373. if err != nil {
  37374. return err
  37375. }
  37376. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37377. // header.Name = path
  37378. if info.IsDir() {
  37379. header.Name += "/"
  37380. } else {
  37381. header.Method = zip.Deflate
  37382. }
  37383. writer, err := archive.CreateHeader(header)
  37384. if err != nil {
  37385. return err
  37386. }
  37387. if !info.IsDir() {
  37388. file, err := os.Open(path)
  37389. if err != nil {
  37390. return err
  37391. }
  37392. defer file.Close()
  37393. _, err = io.Copy(writer, file)
  37394. }
  37395. return err
  37396. })
  37397. return err
  37398. }
  37399. func ReadFile(filePath string) []byte {
  37400. f, err := os.Open(filePath)
  37401. if err != nil {
  37402. fmt.Println("read file fail", err)
  37403. return nil
  37404. }
  37405. defer f.Close()
  37406. fd, err := ioutil.ReadAll(f)
  37407. if err != nil {
  37408. fmt.Println("read to fd fail", err)
  37409. return nil
  37410. }
  37411. return fd
  37412. }
  37413. func saveLogq(result string, request string, infno string, desc string) {
  37414. dir := "日志"
  37415. utils.Mkdir(dir)
  37416. month := time.Unix(1557042972, 0).Format("1")
  37417. year := time.Now().Format("2006")
  37418. month = time.Now().Format("01")
  37419. day := time.Now().Format("02")
  37420. hour := time.Now().Format("15")
  37421. min := time.Now().Format("04")
  37422. sec := time.Now().Format("05")
  37423. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37424. file := year + month + day + "_log"
  37425. file_name := file + ".txt"
  37426. file_path := "日志" + "/" + file_name
  37427. exist, _ := utils.PathExists(file_path)
  37428. if exist { //存在
  37429. fmt.Println("存在")
  37430. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37431. if err != nil {
  37432. fmt.Println("read fail")
  37433. }
  37434. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37435. n, _ := f.Seek(0, 2)
  37436. _, err = f.WriteAt([]byte(content), n)
  37437. } else { //不存在
  37438. fmt.Println("文件不存在,创建文件")
  37439. f, err := os.Create("日志" + "/" + file_name)
  37440. defer f.Close()
  37441. if err != nil {
  37442. } else {
  37443. _, err = f.Write([]byte("记录日志"))
  37444. }
  37445. }
  37446. }
  37447. func saveLog(result string, request string, infno string, desc string) {
  37448. org_id, _ := beego.AppConfig.Int64("org_id")
  37449. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37450. dir := miConfig.OrgName + "日志"
  37451. utils.Mkdir(dir)
  37452. month := time.Unix(1557042972, 0).Format("1")
  37453. year := time.Now().Format("2006")
  37454. month = time.Now().Format("01")
  37455. day := time.Now().Format("02")
  37456. hour := time.Now().Format("15")
  37457. min := time.Now().Format("04")
  37458. sec := time.Now().Format("05")
  37459. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37460. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37461. file_name := file + ".txt"
  37462. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37463. exist, _ := utils.PathExists(file_path)
  37464. if exist { //存在
  37465. fmt.Println("存在")
  37466. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37467. if err != nil {
  37468. fmt.Println("read fail")
  37469. }
  37470. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37471. n, _ := f.Seek(0, 2)
  37472. _, err = f.WriteAt([]byte(content), n)
  37473. } else { //不存在
  37474. fmt.Println("文件不存在,创建文件")
  37475. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37476. defer f.Close()
  37477. if err != nil {
  37478. } else {
  37479. _, err = f.Write([]byte("记录日志"))
  37480. }
  37481. }
  37482. }
  37483. type Charset string
  37484. const (
  37485. UTF8 = Charset("UTF-8")
  37486. GB18030 = Charset("GB18030")
  37487. )
  37488. func ConvertToString(src string, srcCode string, tagCode string) string {
  37489. srcCoder := mahonia.NewDecoder(srcCode)
  37490. srcResult := srcCoder.ConvertString(src)
  37491. tagCoder := mahonia.NewDecoder(tagCode)
  37492. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37493. result := string(cdata)
  37494. return result
  37495. }
  37496. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37497. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37498. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37499. var token string
  37500. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37501. var api string
  37502. if miConfig.MdtrtareaAdmvs == "320921" {
  37503. 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 +
  37504. "&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
  37505. fmt.Println(api)
  37506. } else {
  37507. 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 +
  37508. "&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
  37509. }
  37510. resp, requestErr := http.Get(api)
  37511. if requestErr != nil {
  37512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37513. return ""
  37514. }
  37515. body, ioErr := ioutil.ReadAll(resp.Body)
  37516. if ioErr != nil {
  37517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37519. return ""
  37520. }
  37521. var respJSON map[string]interface{}
  37522. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37525. return ""
  37526. }
  37527. var status string
  37528. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37529. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37530. var res ResultTwo //1101结果
  37531. var res10265 ResultTwo10265 //1101结果
  37532. if status == "0" { //读卡成功
  37533. var card_info string //卡信息
  37534. var busi_card_info string
  37535. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37536. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37537. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37538. fmt.Println(card_info)
  37539. fmt.Println(busi_card_info)
  37540. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37541. result, _ := json.Marshal(respJSON)
  37542. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37543. utils.ErrorLog("解析失败:%v", err)
  37544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37545. return ""
  37546. }
  37547. res.ErrMsg = res10265.ErrMsg
  37548. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37549. res.Infcode = infocode
  37550. res.Output = res10265.Output
  37551. res.InfRefmsgid = res10265.InfRefmsgid
  37552. if res.Infcode == 0 {
  37553. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37554. if err == gorm.ErrRecordNotFound {
  37555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37556. return ""
  37557. } else if err != nil {
  37558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37559. return ""
  37560. } else {
  37561. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37562. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37563. infoStr := string(Iinfos)
  37564. idetinfoStr := string(Idetinfos)
  37565. psn := &models.HisPsn{
  37566. PsnNo: res.Output.Baseinfo.PsnNo,
  37567. PatientId: patient.ID,
  37568. Certno: res.Output.Baseinfo.Certno,
  37569. Gend: res.Output.Baseinfo.Gend,
  37570. Naty: res.Output.Baseinfo.Naty,
  37571. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37572. PsnName: res.Output.Baseinfo.PsnName,
  37573. Idetinfo: idetinfoStr,
  37574. Insuinfo: infoStr,
  37575. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37576. CardInfo: card_info,
  37577. VerifyNumber: token,
  37578. }
  37579. service.CreateHisPsn(psn)
  37580. return token
  37581. }
  37582. }
  37583. } else {
  37584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37585. return ""
  37586. }
  37587. } else { //读卡失败
  37588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37589. return ""
  37590. }
  37591. return token
  37592. }
  37593. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37594. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37595. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37596. var token string
  37597. var api string
  37598. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37599. "&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
  37600. fmt.Println(api)
  37601. resp, requestErr := http.Get(api)
  37602. if requestErr != nil {
  37603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37604. return ""
  37605. }
  37606. body, ioErr := ioutil.ReadAll(resp.Body)
  37607. if ioErr != nil {
  37608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37610. return ""
  37611. }
  37612. var respJSON map[string]interface{}
  37613. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37616. return ""
  37617. }
  37618. var status string
  37619. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37620. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37621. var res ResultTwo //1101结果
  37622. if status == "1" { //读卡成功
  37623. var card_info string //卡信息
  37624. var busi_card_info string
  37625. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37626. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37627. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37628. fmt.Println(card_info)
  37629. fmt.Println(busi_card_info)
  37630. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37631. result, _ := json.Marshal(respJSON)
  37632. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37633. utils.ErrorLog("解析失败:%v", err)
  37634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37635. return ""
  37636. }
  37637. if res.Infcode == 0 {
  37638. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37639. if err == gorm.ErrRecordNotFound {
  37640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37641. return ""
  37642. } else if err != nil {
  37643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37644. return ""
  37645. } else {
  37646. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37647. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37648. infoStr := string(Iinfos)
  37649. idetinfoStr := string(Idetinfos)
  37650. psn := &models.HisPsn{
  37651. PsnNo: res.Output.Baseinfo.PsnNo,
  37652. PatientId: patient.ID,
  37653. Certno: res.Output.Baseinfo.Certno,
  37654. Gend: res.Output.Baseinfo.Gend,
  37655. Naty: res.Output.Baseinfo.Naty,
  37656. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37657. PsnName: res.Output.Baseinfo.PsnName,
  37658. Idetinfo: idetinfoStr,
  37659. Insuinfo: infoStr,
  37660. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37661. CardInfo: card_info,
  37662. VerifyNumber: token,
  37663. }
  37664. service.CreateHisPsn(psn)
  37665. return token
  37666. }
  37667. }
  37668. } else {
  37669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37670. return ""
  37671. }
  37672. return token
  37673. }
  37674. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37675. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37676. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37677. var token string
  37678. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37679. var api string
  37680. if miConfig.MdtrtareaAdmvs == "320921" {
  37681. 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 +
  37682. "&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
  37683. fmt.Println(api)
  37684. } else {
  37685. 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 +
  37686. "&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
  37687. }
  37688. resp, requestErr := http.Get(api)
  37689. if requestErr != nil {
  37690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37691. return ""
  37692. }
  37693. body, ioErr := ioutil.ReadAll(resp.Body)
  37694. if ioErr != nil {
  37695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37697. return ""
  37698. }
  37699. var respJSON map[string]interface{}
  37700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37703. return ""
  37704. }
  37705. var status string
  37706. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37707. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37708. var res ResultTwo //1101结果
  37709. var res10265 ResultTwo10265 //1101结果
  37710. if status == "0" { //读卡成功
  37711. var card_info string //卡信息
  37712. var busi_card_info string
  37713. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37714. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37715. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37716. fmt.Println(card_info)
  37717. fmt.Println(busi_card_info)
  37718. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37719. result, _ := json.Marshal(respJSON)
  37720. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37721. utils.ErrorLog("解析失败:%v", err)
  37722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37723. return ""
  37724. }
  37725. res.ErrMsg = res10265.ErrMsg
  37726. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37727. res.Infcode = infocode
  37728. res.Output = res10265.Output
  37729. res.InfRefmsgid = res10265.InfRefmsgid
  37730. if res.Infcode == 0 {
  37731. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37732. if err == gorm.ErrRecordNotFound {
  37733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37734. return ""
  37735. } else if err != nil {
  37736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37737. return ""
  37738. } else {
  37739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37741. infoStr := string(Iinfos)
  37742. idetinfoStr := string(Idetinfos)
  37743. psn := &models.HisPsn{
  37744. PsnNo: res.Output.Baseinfo.PsnNo,
  37745. PatientId: patient.ID,
  37746. Certno: res.Output.Baseinfo.Certno,
  37747. Gend: res.Output.Baseinfo.Gend,
  37748. Naty: res.Output.Baseinfo.Naty,
  37749. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37750. PsnName: res.Output.Baseinfo.PsnName,
  37751. Idetinfo: idetinfoStr,
  37752. Insuinfo: infoStr,
  37753. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37754. CardInfo: card_info,
  37755. VerifyNumber: token,
  37756. }
  37757. service.CreateHisPsn(psn)
  37758. return token
  37759. }
  37760. }
  37761. } else {
  37762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37763. return ""
  37764. }
  37765. } else { //读卡失败
  37766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37767. return ""
  37768. }
  37769. return token
  37770. }
  37771. func DeleteExtraSpaceTwo(s string) string {
  37772. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37773. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37774. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37775. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37776. s2 := make([]byte, len(s1)) //定义字符数组切片
  37777. copy(s2, s1) //将字符串复制到切片
  37778. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37779. for len(spc_index) > 0 { //找到适配项
  37780. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37781. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37782. }
  37783. return string(s2)
  37784. }
  37785. func Remove0000(s string) string {
  37786. str := make([]rune, 0, len(s))
  37787. for _, v := range []rune(s) {
  37788. if v == 0 {
  37789. continue
  37790. }
  37791. str = append(str, v)
  37792. }
  37793. return string(str)
  37794. }
  37795. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37796. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37797. readCard := DllDef.MustFindProc("EcQuery")
  37798. pCardInfo := make([]byte, 8192)
  37799. pBusiCardInfo := make([]byte, 8192)
  37800. data := make(map[string]interface{})
  37801. //pData := make(map[string]interface{})
  37802. inputData := make(map[string]interface{})
  37803. inputData["orgId"] = code
  37804. inputData["businessType"] = "01101"
  37805. inputData["operatorId"] = operator_id
  37806. inputData["operatorName"] = operator_name
  37807. inputData["officeId"] = "001"
  37808. inputData["officeName"] = "血透室"
  37809. //
  37810. data["data"] = inputData
  37811. data["transType"] = "ec.query"
  37812. data["orgId"] = code
  37813. bytesData, _ := json.Marshal(data)
  37814. pCardInfo = bytesData
  37815. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37816. fmt.Println(ret2)
  37817. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37818. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37819. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37820. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37821. if ret2 != 0 {
  37822. return "", ""
  37823. }
  37824. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37825. }
  37826. func DeleteExtraSpace(s string) string {
  37827. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37828. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37829. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37830. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37831. s2 := make([]byte, len(s1)) //定义字符数组切片
  37832. copy(s2, s1) //将字符串复制到切片
  37833. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37834. for len(spc_index) > 0 { //找到适配项
  37835. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37836. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37837. }
  37838. return string(s2)
  37839. }
  37840. // 对账
  37841. func (c *HisApiController) Post3202() {
  37842. start_time := c.GetString("start_time")
  37843. end_time := c.GetString("end_time")
  37844. //insutype := c.GetString("insutype")
  37845. clr_type := c.GetString("clr_type")
  37846. clr_org := c.GetString("clr_optins")
  37847. admin_user_id, _ := c.GetInt64("admin_user_id")
  37848. adminUser := c.GetAdminUserInfo()
  37849. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37850. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37851. if len(clr_org) == 0 {
  37852. clr_org = miConfig.MdtrtareaAdmvs
  37853. }
  37854. timeLayout := "2006-01-02"
  37855. loc, _ := time.LoadLocation("Local")
  37856. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37857. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37858. var orders []*models.HisOrder
  37859. if clr_org == "421300" {
  37860. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37861. } else if clr_org == "420902" {
  37862. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37863. } else {
  37864. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37865. }
  37866. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37867. //fixmedins_setl_cnt := int64(len(orders))
  37868. var medfee_sumamt float64
  37869. var acct_pay float64
  37870. var fund_pay_sumamt float64
  37871. for _, item := range orders {
  37872. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37873. acct_pay = acct_pay + item.AcctPay
  37874. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37875. }
  37876. //var medfee_sumamt_two float64
  37877. //var acct_pay_two float64
  37878. //var fund_pay_sumamt_two float64
  37879. //for _, item := range orders_two {
  37880. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37881. // acct_pay_two = acct_pay_two + item.AcctPay
  37882. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37883. //}
  37884. //var user_name string
  37885. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37886. //if role.ID == 0 {
  37887. // user_name = "xxx"
  37888. //} else {
  37889. // user_name = role.UserName
  37890. //}
  37891. var res ResultSix
  37892. if config.IsOpen == 1 {
  37893. var bps []*models.BusinessParamsTwo
  37894. var bp models.BusinessParamsTwo
  37895. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37896. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37897. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37898. bp.MedfeeSumamt = medfee_sumamt_str
  37899. bp.AcctPay = acct_pay_str
  37900. bp.FundPaySumamt = fund_pay_sumamt_str
  37901. bp.Insutype = ""
  37902. bp.StmtBegndate = start_time
  37903. bp.ClrType = clr_type
  37904. bp.SetlOptins = clr_org
  37905. bp.StmtEnddate = end_time
  37906. bps = append(bps, &bp)
  37907. data := make(map[string]interface{})
  37908. data["bps"] = bps
  37909. data["org_name"] = miConfig.OrgName
  37910. data["doctor"] = role.UserName
  37911. data["fixmedins_code"] = miConfig.Code
  37912. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37913. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37914. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37915. if miConfig.MdtrtareaAdmvs == "421300" {
  37916. client := &http.Client{}
  37917. bytesData, _ := json.Marshal(data)
  37918. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37919. resp, _ := client.Do(req)
  37920. defer resp.Body.Close()
  37921. body, ioErr := ioutil.ReadAll(resp.Body)
  37922. if ioErr != nil {
  37923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37925. return
  37926. }
  37927. var respJSON map[string]interface{}
  37928. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37931. return
  37932. }
  37933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37934. userJSONBytes, _ := json.Marshal(respJSON)
  37935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37936. utils.ErrorLog("解析失败:%v", err)
  37937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37938. return
  37939. }
  37940. }
  37941. if miConfig.MdtrtareaAdmvs == "420200" {
  37942. client := &http.Client{}
  37943. bytesData, _ := json.Marshal(data)
  37944. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37945. resp, _ := client.Do(req)
  37946. defer resp.Body.Close()
  37947. body, ioErr := ioutil.ReadAll(resp.Body)
  37948. if ioErr != nil {
  37949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37951. return
  37952. }
  37953. var respJSON map[string]interface{}
  37954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37957. return
  37958. }
  37959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37960. userJSONBytes, _ := json.Marshal(respJSON)
  37961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37962. utils.ErrorLog("解析失败:%v", err)
  37963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37964. return
  37965. }
  37966. }
  37967. if miConfig.MdtrtareaAdmvs == "421182" {
  37968. client := &http.Client{}
  37969. bytesData, _ := json.Marshal(data)
  37970. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37971. resp, _ := client.Do(req)
  37972. defer resp.Body.Close()
  37973. body, ioErr := ioutil.ReadAll(resp.Body)
  37974. if ioErr != nil {
  37975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37977. return
  37978. }
  37979. var respJSON map[string]interface{}
  37980. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37983. return
  37984. }
  37985. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37986. userJSONBytes, _ := json.Marshal(respJSON)
  37987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37988. utils.ErrorLog("解析失败:%v", err)
  37989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37990. return
  37991. }
  37992. }
  37993. if miConfig.MdtrtareaAdmvs == "420902" {
  37994. client := &http.Client{}
  37995. bytesData, _ := json.Marshal(data)
  37996. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37997. resp, _ := client.Do(req)
  37998. defer resp.Body.Close()
  37999. body, ioErr := ioutil.ReadAll(resp.Body)
  38000. if ioErr != nil {
  38001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38003. return
  38004. }
  38005. var respJSON map[string]interface{}
  38006. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38009. return
  38010. }
  38011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38012. userJSONBytes, _ := json.Marshal(respJSON)
  38013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38014. utils.ErrorLog("解析失败:%v", err)
  38015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38016. return
  38017. }
  38018. }
  38019. if res.Infcode == 0 {
  38020. c.ServeSuccessJSON(map[string]interface{}{
  38021. "msg": "发起成功",
  38022. })
  38023. } else {
  38024. c.ServeSuccessJSON(map[string]interface{}{
  38025. "failed_code": -10,
  38026. "msg": res.ErrMsg,
  38027. })
  38028. }
  38029. }
  38030. }
  38031. func (c *HisApiController) Post3204a() {
  38032. start_time := c.GetString("start_time")
  38033. end_time := c.GetString("end_time")
  38034. //insutype := c.GetString("insutype")
  38035. clr_type := c.GetString("clr_type")
  38036. clr_org := c.GetString("clr_optins")
  38037. admin_user_id, _ := c.GetInt64("admin_user_id")
  38038. adminUser := c.GetAdminUserInfo()
  38039. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38040. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38041. if len(clr_org) == 0 {
  38042. clr_org = miConfig.MdtrtareaAdmvs
  38043. }
  38044. timeLayout := "2006-01-02"
  38045. loc, _ := time.LoadLocation("Local")
  38046. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38047. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38048. var orders []*models.HisOrder
  38049. if clr_org == "421300" {
  38050. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38051. } else if clr_org == "420902" {
  38052. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38053. } else {
  38054. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38055. }
  38056. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38057. //fixmedins_setl_cnt := int64(len(orders))
  38058. var medfee_sumamt float64
  38059. var acct_pay float64
  38060. var fund_pay_sumamt float64
  38061. for _, item := range orders {
  38062. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38063. acct_pay = acct_pay + item.AcctPay
  38064. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38065. }
  38066. //var medfee_sumamt_two float64
  38067. //var acct_pay_two float64
  38068. //var fund_pay_sumamt_two float64
  38069. //for _, item := range orders_two {
  38070. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38071. // acct_pay_two = acct_pay_two + item.AcctPay
  38072. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38073. //}
  38074. //var user_name string
  38075. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38076. //if role.ID == 0 {
  38077. // user_name = "xxx"
  38078. //} else {
  38079. // user_name = role.UserName
  38080. //}
  38081. var res ResultSix
  38082. if config.IsOpen == 1 {
  38083. var bps []*models.BusinessParamsTwo
  38084. var bp models.BusinessParamsTwo
  38085. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38086. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38087. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38088. bp.MedfeeSumamt = medfee_sumamt_str
  38089. bp.AcctPay = acct_pay_str
  38090. bp.FundPaySumamt = fund_pay_sumamt_str
  38091. bp.Insutype = ""
  38092. bp.StmtBegndate = start_time
  38093. bp.ClrType = clr_type
  38094. bp.SetlOptins = clr_org
  38095. bp.StmtEnddate = end_time
  38096. bps = append(bps, &bp)
  38097. data := make(map[string]interface{})
  38098. data["bps"] = bps
  38099. data["org_name"] = miConfig.OrgName
  38100. data["doctor"] = role.UserName
  38101. data["fixmedins_code"] = miConfig.Code
  38102. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38103. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38104. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38105. if miConfig.MdtrtareaAdmvs == "421300" {
  38106. client := &http.Client{}
  38107. bytesData, _ := json.Marshal(data)
  38108. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38109. resp, _ := client.Do(req)
  38110. defer resp.Body.Close()
  38111. body, ioErr := ioutil.ReadAll(resp.Body)
  38112. if ioErr != nil {
  38113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38115. return
  38116. }
  38117. var respJSON map[string]interface{}
  38118. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38121. return
  38122. }
  38123. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38124. userJSONBytes, _ := json.Marshal(respJSON)
  38125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38126. utils.ErrorLog("解析失败:%v", err)
  38127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38128. return
  38129. }
  38130. }
  38131. if miConfig.MdtrtareaAdmvs == "420200" {
  38132. client := &http.Client{}
  38133. bytesData, _ := json.Marshal(data)
  38134. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38135. resp, _ := client.Do(req)
  38136. defer resp.Body.Close()
  38137. body, ioErr := ioutil.ReadAll(resp.Body)
  38138. if ioErr != nil {
  38139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38141. return
  38142. }
  38143. var respJSON map[string]interface{}
  38144. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38147. return
  38148. }
  38149. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38150. userJSONBytes, _ := json.Marshal(respJSON)
  38151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38152. utils.ErrorLog("解析失败:%v", err)
  38153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38154. return
  38155. }
  38156. }
  38157. if miConfig.MdtrtareaAdmvs == "421182" {
  38158. client := &http.Client{}
  38159. bytesData, _ := json.Marshal(data)
  38160. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38161. resp, _ := client.Do(req)
  38162. defer resp.Body.Close()
  38163. body, ioErr := ioutil.ReadAll(resp.Body)
  38164. if ioErr != nil {
  38165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38167. return
  38168. }
  38169. var respJSON map[string]interface{}
  38170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38173. return
  38174. }
  38175. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38176. userJSONBytes, _ := json.Marshal(respJSON)
  38177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38178. utils.ErrorLog("解析失败:%v", err)
  38179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38180. return
  38181. }
  38182. }
  38183. if miConfig.MdtrtareaAdmvs == "420902" {
  38184. client := &http.Client{}
  38185. bytesData, _ := json.Marshal(data)
  38186. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38187. resp, _ := client.Do(req)
  38188. defer resp.Body.Close()
  38189. body, ioErr := ioutil.ReadAll(resp.Body)
  38190. if ioErr != nil {
  38191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38193. return
  38194. }
  38195. var respJSON map[string]interface{}
  38196. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38199. return
  38200. }
  38201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38202. userJSONBytes, _ := json.Marshal(respJSON)
  38203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38204. utils.ErrorLog("解析失败:%v", err)
  38205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38206. return
  38207. }
  38208. }
  38209. if res.Infcode == 0 {
  38210. c.ServeSuccessJSON(map[string]interface{}{
  38211. "msg": "撤销成功",
  38212. })
  38213. } else {
  38214. c.ServeSuccessJSON(map[string]interface{}{
  38215. "failed_code": -10,
  38216. "msg": res.ErrMsg,
  38217. })
  38218. }
  38219. }
  38220. }
  38221. func (c *HisApiController) Post3204() {
  38222. admin_user_id, _ := c.GetInt64("admin_user_id")
  38223. id := c.GetString("id")
  38224. adminUser := c.GetAdminUserInfo()
  38225. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38226. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38227. //clr_org := miConfig.MdtrtareaAdmvs
  38228. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38229. var res ResultSix
  38230. if config.IsOpen == 1 {
  38231. data := make(map[string]interface{})
  38232. data["id"] = id
  38233. data["org_name"] = miConfig.OrgName
  38234. data["doctor"] = role.UserName
  38235. data["fixmedins_code"] = miConfig.Code
  38236. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38237. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38238. client := &http.Client{}
  38239. bytesData, _ := json.Marshal(data)
  38240. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38241. resp, _ := client.Do(req)
  38242. defer resp.Body.Close()
  38243. body, ioErr := ioutil.ReadAll(resp.Body)
  38244. if ioErr != nil {
  38245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38247. return
  38248. }
  38249. var respJSON map[string]interface{}
  38250. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38253. return
  38254. }
  38255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38256. userJSONBytes, _ := json.Marshal(respJSON)
  38257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38258. utils.ErrorLog("解析失败:%v", err)
  38259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38260. return
  38261. }
  38262. if res.Infcode == 0 {
  38263. c.ServeSuccessJSON(map[string]interface{}{
  38264. "msg": "发起成功",
  38265. })
  38266. } else {
  38267. c.ServeSuccessJSON(map[string]interface{}{
  38268. "failed_code": -10,
  38269. "msg": res.ErrMsg,
  38270. })
  38271. }
  38272. }
  38273. }
  38274. func (c *HisApiController) Post8404() {
  38275. admin_user_id, _ := c.GetInt64("admin_user_id")
  38276. month := c.GetString("month")
  38277. adminUser := c.GetAdminUserInfo()
  38278. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38279. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38280. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38281. var res ResultSix
  38282. if config.IsOpen == 1 {
  38283. data := make(map[string]interface{})
  38284. data["month"] = month
  38285. data["org_name"] = miConfig.OrgName
  38286. data["doctor"] = role.UserName
  38287. data["fixmedins_code"] = miConfig.Code
  38288. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38289. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38290. client := &http.Client{}
  38291. bytesData, _ := json.Marshal(data)
  38292. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38293. resp, _ := client.Do(req)
  38294. defer resp.Body.Close()
  38295. body, ioErr := ioutil.ReadAll(resp.Body)
  38296. if ioErr != nil {
  38297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38299. return
  38300. }
  38301. var respJSON map[string]interface{}
  38302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38305. return
  38306. }
  38307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38308. userJSONBytes, _ := json.Marshal(respJSON)
  38309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38310. utils.ErrorLog("解析失败:%v", err)
  38311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38312. return
  38313. }
  38314. if res.Infcode == 0 {
  38315. c.ServeSuccessJSON(map[string]interface{}{
  38316. "msg": "查询成功",
  38317. })
  38318. } else {
  38319. c.ServeSuccessJSON(map[string]interface{}{
  38320. "failed_code": -10,
  38321. "msg": res.ErrMsg,
  38322. })
  38323. }
  38324. }
  38325. }
  38326. func (c *HisApiController) Post3202b() {
  38327. start_time := c.GetString("start_time")
  38328. end_time := c.GetString("end_time")
  38329. //insutype := c.GetString("insutype")
  38330. clr_type := c.GetString("clr_type")
  38331. clr_org := c.GetString("clr_optins")
  38332. admin_user_id, _ := c.GetInt64("admin_user_id")
  38333. adminUser := c.GetAdminUserInfo()
  38334. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38335. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38336. if len(clr_org) == 0 {
  38337. clr_org = miConfig.MdtrtareaAdmvs
  38338. }
  38339. timeLayout := "2006-01-02"
  38340. loc, _ := time.LoadLocation("Local")
  38341. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38342. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38343. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38344. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38345. //fixmedins_setl_cnt := int64(len(orders))
  38346. var medfee_sumamt float64
  38347. var acct_pay float64
  38348. var fund_pay_sumamt float64
  38349. for _, item := range orders {
  38350. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38351. acct_pay = acct_pay + item.AcctPay
  38352. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38353. }
  38354. //var medfee_sumamt_two float64
  38355. //var acct_pay_two float64
  38356. //var fund_pay_sumamt_two float64
  38357. //for _, item := range orders_two {
  38358. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38359. // acct_pay_two = acct_pay_two + item.AcctPay
  38360. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38361. //}
  38362. //var user_name string
  38363. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38364. //if role.ID == 0 {
  38365. // user_name = "xxx"
  38366. //} else {
  38367. // user_name = role.UserName
  38368. //}
  38369. var res ResultSix
  38370. if config.IsOpen == 1 {
  38371. var bps []*models.BusinessParamsTwo
  38372. var bp models.BusinessParamsTwo
  38373. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38374. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38375. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38376. bp.MedfeeSumamt = medfee_sumamt_str
  38377. bp.AcctPay = acct_pay_str
  38378. bp.FundPaySumamt = fund_pay_sumamt_str
  38379. bp.Insutype = "390"
  38380. bp.StmtBegndate = start_time
  38381. bp.ClrType = clr_type
  38382. bp.SetlOptins = clr_org
  38383. bp.StmtEnddate = end_time
  38384. bps = append(bps, &bp)
  38385. data := make(map[string]interface{})
  38386. data["bps"] = bps
  38387. data["org_name"] = miConfig.OrgName
  38388. data["doctor"] = role.UserName
  38389. data["fixmedins_code"] = miConfig.Code
  38390. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38391. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38392. if miConfig.MdtrtareaAdmvs == "421300" {
  38393. client := &http.Client{}
  38394. bytesData, _ := json.Marshal(data)
  38395. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38396. resp, _ := client.Do(req)
  38397. defer resp.Body.Close()
  38398. body, ioErr := ioutil.ReadAll(resp.Body)
  38399. if ioErr != nil {
  38400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38402. return
  38403. }
  38404. var respJSON map[string]interface{}
  38405. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38408. return
  38409. }
  38410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38411. userJSONBytes, _ := json.Marshal(respJSON)
  38412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38413. utils.ErrorLog("解析失败:%v", err)
  38414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38415. return
  38416. }
  38417. }
  38418. if miConfig.MdtrtareaAdmvs == "420200" {
  38419. client := &http.Client{}
  38420. bytesData, _ := json.Marshal(data)
  38421. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38422. resp, _ := client.Do(req)
  38423. defer resp.Body.Close()
  38424. body, ioErr := ioutil.ReadAll(resp.Body)
  38425. if ioErr != nil {
  38426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38428. return
  38429. }
  38430. var respJSON map[string]interface{}
  38431. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38434. return
  38435. }
  38436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38437. userJSONBytes, _ := json.Marshal(respJSON)
  38438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38439. utils.ErrorLog("解析失败:%v", err)
  38440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38441. return
  38442. }
  38443. }
  38444. if miConfig.MdtrtareaAdmvs == "421182" {
  38445. client := &http.Client{}
  38446. bytesData, _ := json.Marshal(data)
  38447. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38448. resp, _ := client.Do(req)
  38449. defer resp.Body.Close()
  38450. body, ioErr := ioutil.ReadAll(resp.Body)
  38451. if ioErr != nil {
  38452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38454. return
  38455. }
  38456. var respJSON map[string]interface{}
  38457. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38460. return
  38461. }
  38462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38463. userJSONBytes, _ := json.Marshal(respJSON)
  38464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38465. utils.ErrorLog("解析失败:%v", err)
  38466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38467. return
  38468. }
  38469. }
  38470. if res.Infcode == 0 {
  38471. c.ServeSuccessJSON(map[string]interface{}{
  38472. "msg": "发起成功",
  38473. })
  38474. } else {
  38475. c.ServeSuccessJSON(map[string]interface{}{
  38476. "failed_code": -10,
  38477. "msg": res.ErrMsg,
  38478. })
  38479. }
  38480. }
  38481. }
  38482. func (c *HisApiController) Post1608() {
  38483. start_time := c.GetString("start_time")
  38484. end_time := c.GetString("end_time")
  38485. admin_user_id, _ := c.GetInt64("admin_user_id")
  38486. adminUser := c.GetAdminUserInfo()
  38487. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38488. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38489. timeLayout := "2006-01-02"
  38490. loc, _ := time.LoadLocation("Local")
  38491. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38492. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38493. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38494. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38495. fixmedins_setl_cnt := int64(len(orders))
  38496. var medfee_sumamt float64
  38497. var func_smamt float64
  38498. for _, item := range orders {
  38499. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38500. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38501. }
  38502. times := strings.Split(start_time, "-")
  38503. time_tows := strings.Split(end_time, "-")
  38504. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38505. var res ResultSix
  38506. if config.IsOpen == 1 {
  38507. //var bps []*models.BusinessParamsTwo
  38508. //var bp models.BusinessParamsTwo
  38509. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38510. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38511. data := make(map[string]interface{})
  38512. data["org_name"] = miConfig.OrgName
  38513. data["doctor"] = role.UserName
  38514. data["func_smamt"] = func_smamt_str
  38515. data["fixmedins_code"] = miConfig.Code
  38516. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38517. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38518. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38519. data["medfee_sumamt"] = medfee_sumamt_str
  38520. data["start_time"] = times[0] + times[1] + times[2]
  38521. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38522. if miConfig.MdtrtareaAdmvs == "421300" {
  38523. client := &http.Client{}
  38524. bytesData, _ := json.Marshal(data)
  38525. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38526. resp, _ := client.Do(req)
  38527. defer resp.Body.Close()
  38528. body, ioErr := ioutil.ReadAll(resp.Body)
  38529. if ioErr != nil {
  38530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38532. return
  38533. }
  38534. var respJSON map[string]interface{}
  38535. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38538. return
  38539. }
  38540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38541. userJSONBytes, _ := json.Marshal(respJSON)
  38542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38543. utils.ErrorLog("解析失败:%v", err)
  38544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38545. return
  38546. }
  38547. }
  38548. if miConfig.MdtrtareaAdmvs == "420200" {
  38549. client := &http.Client{}
  38550. bytesData, _ := json.Marshal(data)
  38551. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38552. resp, _ := client.Do(req)
  38553. defer resp.Body.Close()
  38554. body, ioErr := ioutil.ReadAll(resp.Body)
  38555. if ioErr != nil {
  38556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38558. return
  38559. }
  38560. var respJSON map[string]interface{}
  38561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38564. return
  38565. }
  38566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38567. userJSONBytes, _ := json.Marshal(respJSON)
  38568. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38569. utils.ErrorLog("解析失败:%v", err)
  38570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38571. return
  38572. }
  38573. }
  38574. if miConfig.MdtrtareaAdmvs == "421182" {
  38575. client := &http.Client{}
  38576. bytesData, _ := json.Marshal(data)
  38577. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38578. resp, _ := client.Do(req)
  38579. defer resp.Body.Close()
  38580. body, ioErr := ioutil.ReadAll(resp.Body)
  38581. if ioErr != nil {
  38582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38584. return
  38585. }
  38586. var respJSON map[string]interface{}
  38587. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38590. return
  38591. }
  38592. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38593. userJSONBytes, _ := json.Marshal(respJSON)
  38594. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38595. utils.ErrorLog("解析失败:%v", err)
  38596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38597. return
  38598. }
  38599. }
  38600. if res.Infcode == 0 {
  38601. c.ServeSuccessJSON(map[string]interface{}{
  38602. "msg": "发起成功",
  38603. })
  38604. } else {
  38605. c.ServeSuccessJSON(map[string]interface{}{
  38606. "failed_code": -10,
  38607. "msg": res.ErrMsg,
  38608. })
  38609. }
  38610. }
  38611. }
  38612. // 5.11.1.1【5262】结算信息按时间段查询
  38613. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38614. admin_user_id, _ := c.GetInt64("admin_user_id")
  38615. adminUser := c.GetAdminUserInfo()
  38616. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38617. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38618. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38619. var res Result5262
  38620. if config.IsOpen == 1 {
  38621. if miConfig.MdtrtareaAdmvs == "421300" {
  38622. data := make(map[string]interface{})
  38623. data["bps"] = bp
  38624. data["org_name"] = miConfig.OrgName
  38625. data["doctor"] = role.UserName
  38626. data["fixmedins_code"] = miConfig.Code
  38627. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38628. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38629. data["page"] = strconv.FormatInt(page, 10)
  38630. data["limit"] = strconv.FormatInt(limit, 10)
  38631. fmt.Println(data)
  38632. client := &http.Client{}
  38633. bytesData, _ := json.Marshal(data)
  38634. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38635. resp, _ := client.Do(req)
  38636. defer resp.Body.Close()
  38637. body, ioErr := ioutil.ReadAll(resp.Body)
  38638. if ioErr != nil {
  38639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38641. return
  38642. }
  38643. var respJSON map[string]interface{}
  38644. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38647. return
  38648. }
  38649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38650. userJSONBytes, _ := json.Marshal(respJSON)
  38651. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38652. utils.ErrorLog("解析失败:%v", err)
  38653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38654. return
  38655. }
  38656. }
  38657. if miConfig.MdtrtareaAdmvs == "420200" {
  38658. data := make(map[string]interface{})
  38659. data["bps"] = bp
  38660. data["org_name"] = miConfig.OrgName
  38661. data["doctor"] = role.UserName
  38662. data["fixmedins_code"] = miConfig.Code
  38663. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38664. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38665. data["page"] = strconv.FormatInt(page, 10)
  38666. data["limit"] = strconv.FormatInt(limit, 10)
  38667. fmt.Println(data)
  38668. client := &http.Client{}
  38669. bytesData, _ := json.Marshal(data)
  38670. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38671. resp, _ := client.Do(req)
  38672. defer resp.Body.Close()
  38673. body, ioErr := ioutil.ReadAll(resp.Body)
  38674. if ioErr != nil {
  38675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38677. return
  38678. }
  38679. var respJSON map[string]interface{}
  38680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38683. return
  38684. }
  38685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38686. userJSONBytes, _ := json.Marshal(respJSON)
  38687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38688. utils.ErrorLog("解析失败:%v", err)
  38689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38690. return
  38691. }
  38692. }
  38693. if miConfig.MdtrtareaAdmvs == "421182" {
  38694. data := make(map[string]interface{})
  38695. data["bps"] = bp
  38696. data["org_name"] = miConfig.OrgName
  38697. data["doctor"] = role.UserName
  38698. data["fixmedins_code"] = miConfig.Code
  38699. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38701. data["page"] = strconv.FormatInt(page, 10)
  38702. data["limit"] = strconv.FormatInt(limit, 10)
  38703. fmt.Println(data)
  38704. client := &http.Client{}
  38705. bytesData, _ := json.Marshal(data)
  38706. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38707. resp, _ := client.Do(req)
  38708. defer resp.Body.Close()
  38709. body, ioErr := ioutil.ReadAll(resp.Body)
  38710. if ioErr != nil {
  38711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38713. return
  38714. }
  38715. var respJSON map[string]interface{}
  38716. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38719. return
  38720. }
  38721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38722. userJSONBytes, _ := json.Marshal(respJSON)
  38723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38724. utils.ErrorLog("解析失败:%v", err)
  38725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38726. return
  38727. }
  38728. }
  38729. if miConfig.MdtrtareaAdmvs == "420902" {
  38730. data := make(map[string]interface{})
  38731. data["bps"] = bp
  38732. data["org_name"] = miConfig.OrgName
  38733. data["doctor"] = role.UserName
  38734. data["fixmedins_code"] = miConfig.Code
  38735. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38736. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38737. data["page"] = strconv.FormatInt(page, 10)
  38738. data["limit"] = strconv.FormatInt(limit, 10)
  38739. fmt.Println(data)
  38740. client := &http.Client{}
  38741. bytesData, _ := json.Marshal(data)
  38742. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38743. resp, _ := client.Do(req)
  38744. defer resp.Body.Close()
  38745. body, ioErr := ioutil.ReadAll(resp.Body)
  38746. if ioErr != nil {
  38747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38749. return
  38750. }
  38751. var respJSON map[string]interface{}
  38752. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38755. return
  38756. }
  38757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38758. userJSONBytes, _ := json.Marshal(respJSON)
  38759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38760. utils.ErrorLog("解析失败:%v", err)
  38761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38762. return
  38763. }
  38764. }
  38765. if res.Infcode == 0 {
  38766. c.ServeSuccessJSON(map[string]interface{}{
  38767. "order": res.Output.Result,
  38768. "total": res.Output.PageInfo.RecordCounts,
  38769. })
  38770. } else {
  38771. c.ServeSuccessJSON(map[string]interface{}{
  38772. "failed_code": -10,
  38773. "msg": res.ErrMsg,
  38774. })
  38775. }
  38776. }
  38777. }
  38778. // 5.11.1.2【5267】异地结算信息时间段查询
  38779. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38780. admin_user_id, _ := c.GetInt64("admin_user_id")
  38781. adminUser := c.GetAdminUserInfo()
  38782. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38783. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38784. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38785. var res Result5267
  38786. if config.IsOpen == 1 {
  38787. if miConfig.MdtrtareaAdmvs == "421300" {
  38788. data := make(map[string]interface{})
  38789. data["bps"] = bp
  38790. data["org_name"] = miConfig.OrgName
  38791. data["doctor"] = role.UserName
  38792. data["fixmedins_code"] = miConfig.Code
  38793. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38794. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38795. data["page"] = page
  38796. data["limit"] = limit
  38797. fmt.Println(data)
  38798. client := &http.Client{}
  38799. bytesData, _ := json.Marshal(data)
  38800. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38801. resp, _ := client.Do(req)
  38802. defer resp.Body.Close()
  38803. body, ioErr := ioutil.ReadAll(resp.Body)
  38804. if ioErr != nil {
  38805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38807. return
  38808. }
  38809. var respJSON map[string]interface{}
  38810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38813. return
  38814. }
  38815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38816. userJSONBytes, _ := json.Marshal(respJSON)
  38817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38818. utils.ErrorLog("解析失败:%v", err)
  38819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38820. return
  38821. }
  38822. }
  38823. if miConfig.MdtrtareaAdmvs == "420200" {
  38824. data := make(map[string]interface{})
  38825. data["bps"] = bp
  38826. data["org_name"] = miConfig.OrgName
  38827. data["doctor"] = role.UserName
  38828. data["fixmedins_code"] = miConfig.Code
  38829. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38830. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38831. data["page"] = page
  38832. data["limit"] = limit
  38833. fmt.Println(data)
  38834. client := &http.Client{}
  38835. bytesData, _ := json.Marshal(data)
  38836. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38837. resp, _ := client.Do(req)
  38838. defer resp.Body.Close()
  38839. body, ioErr := ioutil.ReadAll(resp.Body)
  38840. if ioErr != nil {
  38841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38843. return
  38844. }
  38845. var respJSON map[string]interface{}
  38846. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38849. return
  38850. }
  38851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38852. userJSONBytes, _ := json.Marshal(respJSON)
  38853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38854. utils.ErrorLog("解析失败:%v", err)
  38855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38856. return
  38857. }
  38858. }
  38859. if miConfig.MdtrtareaAdmvs == "421182" {
  38860. data := make(map[string]interface{})
  38861. data["bps"] = bp
  38862. data["org_name"] = miConfig.OrgName
  38863. data["doctor"] = role.UserName
  38864. data["fixmedins_code"] = miConfig.Code
  38865. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38866. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38867. data["page"] = page
  38868. data["limit"] = limit
  38869. fmt.Println(data)
  38870. client := &http.Client{}
  38871. bytesData, _ := json.Marshal(data)
  38872. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38873. resp, _ := client.Do(req)
  38874. defer resp.Body.Close()
  38875. body, ioErr := ioutil.ReadAll(resp.Body)
  38876. if ioErr != nil {
  38877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38879. return
  38880. }
  38881. var respJSON map[string]interface{}
  38882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38885. return
  38886. }
  38887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38888. userJSONBytes, _ := json.Marshal(respJSON)
  38889. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38890. utils.ErrorLog("解析失败:%v", err)
  38891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38892. return
  38893. }
  38894. }
  38895. if res.Infcode == 0 {
  38896. c.ServeSuccessJSON(map[string]interface{}{
  38897. "order": res.Output.Result,
  38898. "total": res.Output.PageInfo.RecordCounts,
  38899. })
  38900. } else {
  38901. c.ServeSuccessJSON(map[string]interface{}{
  38902. "failed_code": -10,
  38903. "msg": res.ErrMsg,
  38904. })
  38905. }
  38906. }
  38907. }
  38908. func (c *HisApiController) Post3501() {
  38909. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38910. data := make(map[string]interface{})
  38911. var struct3501s []models.Struct3501
  38912. var struct3501 models.Struct3501
  38913. struct3501.OrgName = miConfig.OrgName
  38914. struct3501.AccessKey = miConfig.AccessKey
  38915. struct3501.RequestUrl = miConfig.Url
  38916. struct3501.SecretKey = miConfig.SecretKey
  38917. struct3501.ManuDate = "2022-08-17"
  38918. struct3501.FixmedinsBchno = ""
  38919. struct3501.ManuLotnum = ""
  38920. struct3501.RxFlag = "0"
  38921. struct3501.ExpyEnd = "2022-08-17"
  38922. struct3501.Invdate = "2022-08-17"
  38923. struct3501.InvCnt = "20.25"
  38924. struct3501.Memo = ""
  38925. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38926. struct3501.FixmedinsHilistId = miConfig.Code
  38927. struct3501.FixmedinsHilistName = miConfig.OrgName
  38928. struct3501s = append(struct3501s, struct3501)
  38929. data["struct_3501s"] = struct3501s
  38930. client := &http.Client{}
  38931. bytesData, _ := json.Marshal(data)
  38932. var req *http.Request
  38933. if miConfig.MdtrtareaAdmvs == "320921" {
  38934. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38935. } else {
  38936. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38937. }
  38938. resp, _ := client.Do(req)
  38939. defer resp.Body.Close()
  38940. body, ioErr := ioutil.ReadAll(resp.Body)
  38941. if ioErr != nil {
  38942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38944. return
  38945. }
  38946. var respJSON map[string]interface{}
  38947. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38950. return
  38951. }
  38952. var res ResultSix
  38953. var resSix10265 ResultSix10265 //1101结果
  38954. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38955. result, _ := json.Marshal(respJSON)
  38956. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38957. utils.ErrorLog("解析失败:%v", err)
  38958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38959. return
  38960. }
  38961. res.InfRefmsgid = resSix10265.InfRefmsgid
  38962. res.Output = resSix10265.Output
  38963. res.ErrMsg = resSix10265.ErrMsg
  38964. res.Cainfo = resSix10265.Cainfo
  38965. res.WarnMsg = resSix10265.WarnMsg
  38966. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38967. res.Infcode = infocode
  38968. if infocode == 0 {
  38969. c.ServeSuccessJSON(map[string]interface{}{
  38970. "msg": "上传成功",
  38971. })
  38972. return
  38973. } else {
  38974. c.ServeSuccessJSON(map[string]interface{}{
  38975. "failed_code": -10,
  38976. "msg": res.ErrMsg,
  38977. })
  38978. return
  38979. }
  38980. }
  38981. func (c *HisApiController) Post3502() {
  38982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38983. data := make(map[string]interface{})
  38984. var struct3502s []models.Struct3502
  38985. var struct3502 models.Struct3502
  38986. struct3502.OrgName = miConfig.OrgName
  38987. struct3502.AccessKey = miConfig.AccessKey
  38988. struct3502.RequestUrl = miConfig.Url
  38989. struct3502.SecretKey = miConfig.SecretKey
  38990. struct3502.ManuDate = "2022-08-15"
  38991. struct3502.FixmedinsBchno = ""
  38992. struct3502.ManuLotnum = ""
  38993. struct3502.RxFlag = "0"
  38994. struct3502.ExpyEnd = "2022-08-15"
  38995. struct3502.Invdate = "2022-08-15"
  38996. struct3502.InvCnt = "20.25"
  38997. struct3502.Memo = ""
  38998. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38999. struct3502.FixmedinsHilistId = miConfig.Code
  39000. struct3502.FixmedinsHilistName = miConfig.OrgName
  39001. struct3502s = append(struct3502s, struct3502)
  39002. data["struct_3502s"] = struct3502s
  39003. client := &http.Client{}
  39004. bytesData, _ := json.Marshal(data)
  39005. var req *http.Request
  39006. if miConfig.MdtrtareaAdmvs == "320921" {
  39007. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39008. } else {
  39009. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39010. }
  39011. resp, _ := client.Do(req)
  39012. defer resp.Body.Close()
  39013. body, ioErr := ioutil.ReadAll(resp.Body)
  39014. if ioErr != nil {
  39015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39017. return
  39018. }
  39019. var respJSON map[string]interface{}
  39020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39023. return
  39024. }
  39025. var res ResultSix
  39026. var resSix10265 ResultSix10265 //1101结果
  39027. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39028. result, _ := json.Marshal(respJSON)
  39029. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39030. utils.ErrorLog("解析失败:%v", err)
  39031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39032. return
  39033. }
  39034. res.InfRefmsgid = resSix10265.InfRefmsgid
  39035. res.Output = resSix10265.Output
  39036. res.ErrMsg = resSix10265.ErrMsg
  39037. res.Cainfo = resSix10265.Cainfo
  39038. res.WarnMsg = resSix10265.WarnMsg
  39039. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39040. res.Infcode = infocode
  39041. if infocode == 0 {
  39042. c.ServeSuccessJSON(map[string]interface{}{
  39043. "msg": "上传成功",
  39044. })
  39045. return
  39046. } else {
  39047. c.ServeSuccessJSON(map[string]interface{}{
  39048. "failed_code": -10,
  39049. "msg": res.ErrMsg,
  39050. })
  39051. return
  39052. }
  39053. }
  39054. func (c *HisApiController) Post3503() {
  39055. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39056. data := make(map[string]interface{})
  39057. var struct3501s []models.Struct3501
  39058. var struct3501 models.Struct3501
  39059. struct3501.OrgName = miConfig.OrgName
  39060. struct3501.AccessKey = miConfig.AccessKey
  39061. struct3501.RequestUrl = miConfig.Url
  39062. struct3501.SecretKey = miConfig.SecretKey
  39063. struct3501.ManuDate = "2022-08-15"
  39064. struct3501.FixmedinsBchno = ""
  39065. struct3501.ManuLotnum = ""
  39066. struct3501.RxFlag = "0"
  39067. struct3501.ExpyEnd = "2022-08-15"
  39068. struct3501.Invdate = "2022-08-15"
  39069. struct3501.InvCnt = "20.25"
  39070. struct3501.Memo = ""
  39071. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39072. struct3501.FixmedinsHilistId = miConfig.Code
  39073. struct3501.FixmedinsHilistName = miConfig.OrgName
  39074. struct3501s = append(struct3501s, struct3501)
  39075. data["struct_3501s"] = struct3501s
  39076. client := &http.Client{}
  39077. bytesData, _ := json.Marshal(data)
  39078. var req *http.Request
  39079. if miConfig.MdtrtareaAdmvs == "320921" {
  39080. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39081. } else {
  39082. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39083. }
  39084. resp, _ := client.Do(req)
  39085. defer resp.Body.Close()
  39086. body, ioErr := ioutil.ReadAll(resp.Body)
  39087. if ioErr != nil {
  39088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39090. return
  39091. }
  39092. var respJSON map[string]interface{}
  39093. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39096. return
  39097. }
  39098. var res ResultSix
  39099. var resSix10265 ResultSix10265 //1101结果
  39100. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39101. result, _ := json.Marshal(respJSON)
  39102. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39103. utils.ErrorLog("解析失败:%v", err)
  39104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39105. return
  39106. }
  39107. res.InfRefmsgid = resSix10265.InfRefmsgid
  39108. res.Output = resSix10265.Output
  39109. res.ErrMsg = resSix10265.ErrMsg
  39110. res.Cainfo = resSix10265.Cainfo
  39111. res.WarnMsg = resSix10265.WarnMsg
  39112. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39113. res.Infcode = infocode
  39114. if infocode == 0 {
  39115. c.ServeSuccessJSON(map[string]interface{}{
  39116. "msg": "上传成功",
  39117. })
  39118. return
  39119. } else {
  39120. c.ServeSuccessJSON(map[string]interface{}{
  39121. "failed_code": -10,
  39122. "msg": res.ErrMsg,
  39123. })
  39124. return
  39125. }
  39126. }
  39127. func (c *HisApiController) Post3504() {
  39128. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39129. data := make(map[string]interface{})
  39130. var struct3501s []models.Struct3501
  39131. var struct3501 models.Struct3501
  39132. struct3501.OrgName = miConfig.OrgName
  39133. struct3501.AccessKey = miConfig.AccessKey
  39134. struct3501.RequestUrl = miConfig.Url
  39135. struct3501.SecretKey = miConfig.SecretKey
  39136. struct3501.ManuDate = "2022-08-15"
  39137. struct3501.FixmedinsBchno = ""
  39138. struct3501.ManuLotnum = ""
  39139. struct3501.RxFlag = "0"
  39140. struct3501.ExpyEnd = "2022-08-15"
  39141. struct3501.Invdate = "2022-08-15"
  39142. struct3501.InvCnt = "20.25"
  39143. struct3501.Memo = ""
  39144. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39145. struct3501.FixmedinsHilistId = miConfig.Code
  39146. struct3501.FixmedinsHilistName = miConfig.OrgName
  39147. struct3501s = append(struct3501s, struct3501)
  39148. data["struct_3501s"] = struct3501s
  39149. client := &http.Client{}
  39150. bytesData, _ := json.Marshal(data)
  39151. var req *http.Request
  39152. if miConfig.MdtrtareaAdmvs == "320921" {
  39153. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39154. } else {
  39155. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39156. }
  39157. resp, _ := client.Do(req)
  39158. defer resp.Body.Close()
  39159. body, ioErr := ioutil.ReadAll(resp.Body)
  39160. if ioErr != nil {
  39161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39163. return
  39164. }
  39165. var respJSON map[string]interface{}
  39166. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39169. return
  39170. }
  39171. var res ResultSix
  39172. var resSix10265 ResultSix10265 //1101结果
  39173. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39174. result, _ := json.Marshal(respJSON)
  39175. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39176. utils.ErrorLog("解析失败:%v", err)
  39177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39178. return
  39179. }
  39180. res.InfRefmsgid = resSix10265.InfRefmsgid
  39181. res.Output = resSix10265.Output
  39182. res.ErrMsg = resSix10265.ErrMsg
  39183. res.Cainfo = resSix10265.Cainfo
  39184. res.WarnMsg = resSix10265.WarnMsg
  39185. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39186. res.Infcode = infocode
  39187. if infocode == 0 {
  39188. c.ServeSuccessJSON(map[string]interface{}{
  39189. "msg": "上传成功",
  39190. })
  39191. return
  39192. } else {
  39193. c.ServeSuccessJSON(map[string]interface{}{
  39194. "failed_code": -10,
  39195. "msg": res.ErrMsg,
  39196. })
  39197. return
  39198. }
  39199. }
  39200. func (c *HisApiController) Post3505() {
  39201. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39202. data := make(map[string]interface{})
  39203. var struct3501s []models.Struct3501
  39204. var struct3501 models.Struct3501
  39205. struct3501.OrgName = miConfig.OrgName
  39206. struct3501.AccessKey = miConfig.AccessKey
  39207. struct3501.RequestUrl = miConfig.Url
  39208. struct3501.SecretKey = miConfig.SecretKey
  39209. struct3501.ManuDate = "2022-08-15"
  39210. struct3501.FixmedinsBchno = ""
  39211. struct3501.ManuLotnum = ""
  39212. struct3501.RxFlag = "0"
  39213. struct3501.ExpyEnd = "2022-08-15"
  39214. struct3501.Invdate = "2022-08-15"
  39215. struct3501.InvCnt = "20.25"
  39216. struct3501.Memo = ""
  39217. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39218. struct3501.FixmedinsHilistId = miConfig.Code
  39219. struct3501.FixmedinsHilistName = miConfig.OrgName
  39220. struct3501s = append(struct3501s, struct3501)
  39221. data["struct_3501s"] = struct3501s
  39222. client := &http.Client{}
  39223. bytesData, _ := json.Marshal(data)
  39224. var req *http.Request
  39225. if miConfig.MdtrtareaAdmvs == "320921" {
  39226. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39227. } else {
  39228. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39229. }
  39230. resp, _ := client.Do(req)
  39231. defer resp.Body.Close()
  39232. body, ioErr := ioutil.ReadAll(resp.Body)
  39233. if ioErr != nil {
  39234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39236. return
  39237. }
  39238. var respJSON map[string]interface{}
  39239. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39242. return
  39243. }
  39244. var res ResultSix
  39245. var resSix10265 ResultSix10265 //1101结果
  39246. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39247. result, _ := json.Marshal(respJSON)
  39248. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39249. utils.ErrorLog("解析失败:%v", err)
  39250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39251. return
  39252. }
  39253. res.InfRefmsgid = resSix10265.InfRefmsgid
  39254. res.Output = resSix10265.Output
  39255. res.ErrMsg = resSix10265.ErrMsg
  39256. res.Cainfo = resSix10265.Cainfo
  39257. res.WarnMsg = resSix10265.WarnMsg
  39258. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39259. res.Infcode = infocode
  39260. if infocode == 0 {
  39261. c.ServeSuccessJSON(map[string]interface{}{
  39262. "msg": "上传成功",
  39263. })
  39264. return
  39265. } else {
  39266. c.ServeSuccessJSON(map[string]interface{}{
  39267. "failed_code": -10,
  39268. "msg": res.ErrMsg,
  39269. })
  39270. return
  39271. }
  39272. }
  39273. func (c *HisApiController) Post3506() {
  39274. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39275. data := make(map[string]interface{})
  39276. var struct3501s []models.Struct3501
  39277. var struct3501 models.Struct3501
  39278. struct3501.OrgName = miConfig.OrgName
  39279. struct3501.AccessKey = miConfig.AccessKey
  39280. struct3501.RequestUrl = miConfig.Url
  39281. struct3501.SecretKey = miConfig.SecretKey
  39282. struct3501.ManuDate = "2022-08-15"
  39283. struct3501.FixmedinsBchno = ""
  39284. struct3501.ManuLotnum = ""
  39285. struct3501.RxFlag = "0"
  39286. struct3501.ExpyEnd = "2022-08-15"
  39287. struct3501.Invdate = "2022-08-15"
  39288. struct3501.InvCnt = "20.25"
  39289. struct3501.Memo = ""
  39290. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39291. struct3501.FixmedinsHilistId = miConfig.Code
  39292. struct3501.FixmedinsHilistName = miConfig.OrgName
  39293. struct3501s = append(struct3501s, struct3501)
  39294. data["struct_3501s"] = struct3501s
  39295. client := &http.Client{}
  39296. bytesData, _ := json.Marshal(data)
  39297. var req *http.Request
  39298. if miConfig.MdtrtareaAdmvs == "320921" {
  39299. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39300. } else {
  39301. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39302. }
  39303. resp, _ := client.Do(req)
  39304. defer resp.Body.Close()
  39305. body, ioErr := ioutil.ReadAll(resp.Body)
  39306. if ioErr != nil {
  39307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39309. return
  39310. }
  39311. var respJSON map[string]interface{}
  39312. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39315. return
  39316. }
  39317. var res ResultSix
  39318. var resSix10265 ResultSix10265 //1101结果
  39319. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39320. result, _ := json.Marshal(respJSON)
  39321. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39322. utils.ErrorLog("解析失败:%v", err)
  39323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39324. return
  39325. }
  39326. res.InfRefmsgid = resSix10265.InfRefmsgid
  39327. res.Output = resSix10265.Output
  39328. res.ErrMsg = resSix10265.ErrMsg
  39329. res.Cainfo = resSix10265.Cainfo
  39330. res.WarnMsg = resSix10265.WarnMsg
  39331. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39332. res.Infcode = infocode
  39333. if infocode == 0 {
  39334. c.ServeSuccessJSON(map[string]interface{}{
  39335. "msg": "上传成功",
  39336. })
  39337. return
  39338. } else {
  39339. c.ServeSuccessJSON(map[string]interface{}{
  39340. "failed_code": -10,
  39341. "msg": res.ErrMsg,
  39342. })
  39343. return
  39344. }
  39345. }
  39346. func (c *HisApiController) Post3507() {
  39347. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39348. data := make(map[string]interface{})
  39349. var struct3501s []models.Struct3501
  39350. var struct3501 models.Struct3501
  39351. struct3501.OrgName = miConfig.OrgName
  39352. struct3501.AccessKey = miConfig.AccessKey
  39353. struct3501.RequestUrl = miConfig.Url
  39354. struct3501.SecretKey = miConfig.SecretKey
  39355. struct3501.ManuDate = "2022-08-15"
  39356. struct3501.FixmedinsBchno = ""
  39357. struct3501.ManuLotnum = ""
  39358. struct3501.RxFlag = "0"
  39359. struct3501.ExpyEnd = "2022-08-15"
  39360. struct3501.Invdate = "2022-08-15"
  39361. struct3501.InvCnt = "20.25"
  39362. struct3501.Memo = ""
  39363. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39364. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39365. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39366. struct3501s = append(struct3501s, struct3501)
  39367. data["struct_3501s"] = struct3501s
  39368. client := &http.Client{}
  39369. bytesData, _ := json.Marshal(data)
  39370. var req *http.Request
  39371. if miConfig.MdtrtareaAdmvs == "320921" {
  39372. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39373. } else {
  39374. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39375. }
  39376. resp, _ := client.Do(req)
  39377. defer resp.Body.Close()
  39378. body, ioErr := ioutil.ReadAll(resp.Body)
  39379. if ioErr != nil {
  39380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39382. return
  39383. }
  39384. var respJSON map[string]interface{}
  39385. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39388. return
  39389. }
  39390. var res ResultSix
  39391. var resSix10265 ResultSix10265 //1101结果
  39392. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39393. result, _ := json.Marshal(respJSON)
  39394. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39395. utils.ErrorLog("解析失败:%v", err)
  39396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39397. return
  39398. }
  39399. res.InfRefmsgid = resSix10265.InfRefmsgid
  39400. res.Output = resSix10265.Output
  39401. res.ErrMsg = resSix10265.ErrMsg
  39402. res.Cainfo = resSix10265.Cainfo
  39403. res.WarnMsg = resSix10265.WarnMsg
  39404. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39405. res.Infcode = infocode
  39406. if infocode == 0 {
  39407. c.ServeSuccessJSON(map[string]interface{}{
  39408. "msg": "上传成功",
  39409. })
  39410. return
  39411. } else {
  39412. c.ServeSuccessJSON(map[string]interface{}{
  39413. "failed_code": -10,
  39414. "msg": res.ErrMsg,
  39415. })
  39416. return
  39417. }
  39418. }
  39419. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39420. // WebSocket服务器地址
  39421. serverURL := "ws://127.0.0.1:8899"
  39422. // 解析WebSocket服务器地址
  39423. u, err := url.Parse(serverURL)
  39424. if err != nil {
  39425. }
  39426. // 建立WebSocket连接
  39427. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39428. if err != nil {
  39429. }
  39430. defer conn.Close()
  39431. input2 := make(map[string]interface{})
  39432. input := make(map[string]interface{})
  39433. inputData := make(map[string]interface{})
  39434. inputData["orgId"] = code
  39435. inputData["businessType"] = "01101"
  39436. inputData["operatorId"] = operator_id
  39437. inputData["operatorName"] = operator_name
  39438. inputData["officeId"] = "001"
  39439. inputData["officeName"] = "血透室"
  39440. inputData["deviceType"] = ""
  39441. input["data"] = inputData
  39442. input["orgId"] = code
  39443. input["transType"] = "ec.query"
  39444. //if md == ""
  39445. if md[:4] == "4403" {
  39446. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39447. } else if md[:4] == "4401" {
  39448. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39449. } else {
  39450. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39451. }
  39452. input2["indata"] = input
  39453. fmt.Println(input2)
  39454. bytesData, _ := json.Marshal(input2)
  39455. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39456. if err != nil {
  39457. fmt.Println(err)
  39458. }
  39459. // 接收消息
  39460. _, receivedMessage, err := conn.ReadMessage()
  39461. if err != nil {
  39462. fmt.Println(err)
  39463. }
  39464. return "", string(receivedMessage)
  39465. }
  39466. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39467. // WebSocket服务器地址
  39468. serverURL := "ws://127.0.0.1:8899"
  39469. // 解析WebSocket服务器地址
  39470. u, err := url.Parse(serverURL)
  39471. if err != nil {
  39472. }
  39473. // 建立WebSocket连接
  39474. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39475. if err != nil {
  39476. }
  39477. defer conn.Close()
  39478. input2 := make(map[string]interface{})
  39479. input := make(map[string]interface{})
  39480. inputData := make(map[string]interface{})
  39481. inputData["orgId"] = code
  39482. inputData["businessType"] = "01101"
  39483. inputData["operatorId"] = operator_id
  39484. inputData["operatorName"] = operator_name
  39485. inputData["officeId"] = "001"
  39486. inputData["officeName"] = "血透室"
  39487. inputData["deviceType"] = ""
  39488. input["data"] = inputData
  39489. input["orgId"] = code
  39490. input["transType"] = "ec.query"
  39491. //if md == ""
  39492. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39493. input2["indata"] = input
  39494. fmt.Println(input2)
  39495. bytesData, _ := json.Marshal(input2)
  39496. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39497. if err != nil {
  39498. fmt.Println(err)
  39499. }
  39500. // 接收消息
  39501. _, receivedMessage, err := conn.ReadMessage()
  39502. if err != nil {
  39503. fmt.Println(err)
  39504. }
  39505. return "", string(receivedMessage)
  39506. }
  39507. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39508. // WebSocket服务器地址
  39509. serverURL := "ws://127.0.0.1:8899"
  39510. // 解析WebSocket服务器地址
  39511. u, err := url.Parse(serverURL)
  39512. if err != nil {
  39513. }
  39514. // 建立WebSocket连接
  39515. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39516. if err != nil {
  39517. }
  39518. defer conn.Close()
  39519. input2 := make(map[string]interface{})
  39520. input := make(map[string]interface{})
  39521. inputData := make(map[string]interface{})
  39522. inputData["orgId"] = code
  39523. inputData["businessType"] = "01301"
  39524. inputData["operatorId"] = operator_id
  39525. inputData["operatorName"] = operator_name
  39526. inputData["officeId"] = "001"
  39527. inputData["officeName"] = "血透室"
  39528. inputData["deviceType"] = ""
  39529. input["data"] = inputData
  39530. input["orgId"] = code
  39531. input["transType"] = "ec.query"
  39532. //if md == ""
  39533. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39534. input2["indata"] = input
  39535. fmt.Println(input2)
  39536. bytesData, _ := json.Marshal(input2)
  39537. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39538. if err != nil {
  39539. fmt.Println(err)
  39540. }
  39541. // 接收消息
  39542. _, receivedMessage, err := conn.ReadMessage()
  39543. if err != nil {
  39544. fmt.Println(err)
  39545. }
  39546. return "", string(receivedMessage)
  39547. }
  39548. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39549. // WebSocket服务器地址
  39550. serverURL := "ws://127.0.0.1:8899"
  39551. // 解析WebSocket服务器地址
  39552. u, err := url.Parse(serverURL)
  39553. if err != nil {
  39554. }
  39555. // 建立WebSocket连接
  39556. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39557. if err != nil {
  39558. }
  39559. defer conn.Close()
  39560. input2 := make(map[string]interface{})
  39561. input := make(map[string]interface{})
  39562. inputData := make(map[string]interface{})
  39563. inputData["orgId"] = code
  39564. inputData["businessType"] = "01103"
  39565. inputData["operatorId"] = operator_id
  39566. inputData["operatorName"] = operator_name
  39567. inputData["officeId"] = "001"
  39568. inputData["officeName"] = "血透室"
  39569. inputData["deviceType"] = ""
  39570. input["data"] = inputData
  39571. input["orgId"] = code
  39572. input["transType"] = "ec.query"
  39573. //if md ==
  39574. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39575. input2["indata"] = input
  39576. fmt.Println(input2)
  39577. bytesData, _ := json.Marshal(input2)
  39578. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39579. if err != nil {
  39580. fmt.Println(err)
  39581. }
  39582. // 接收消息
  39583. _, receivedMessage, err := conn.ReadMessage()
  39584. if err != nil {
  39585. fmt.Println(err)
  39586. }
  39587. return "", string(receivedMessage)
  39588. }
  39589. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39590. // WebSocket服务器地址
  39591. serverURL := "ws://127.0.0.1:8899"
  39592. // 解析WebSocket服务器地址
  39593. u, err := url.Parse(serverURL)
  39594. if err != nil {
  39595. }
  39596. // 建立WebSocket连接
  39597. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39598. if err != nil {
  39599. }
  39600. defer conn.Close()
  39601. input2 := make(map[string]interface{})
  39602. input := make(map[string]interface{})
  39603. inputData := make(map[string]interface{})
  39604. inputData["orgId"] = code
  39605. inputData["businessType"] = "01101"
  39606. inputData["operatorId"] = operator_id
  39607. inputData["operatorName"] = operator_name
  39608. inputData["officeId"] = "001"
  39609. inputData["officeName"] = "血透室"
  39610. inputData["deviceType"] = ""
  39611. input["data"] = inputData
  39612. input["orgId"] = code
  39613. input["transType"] = "ec.query"
  39614. //if md == ""
  39615. if md[:4] == "4403" {
  39616. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39617. } else if md[:4] == "4401" {
  39618. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39619. } else {
  39620. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39621. }
  39622. input2["indata"] = input
  39623. fmt.Println(input2)
  39624. bytesData, _ := json.Marshal(input2)
  39625. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39626. if err != nil {
  39627. fmt.Println(err)
  39628. }
  39629. // 接收消息
  39630. _, receivedMessage, err := conn.ReadMessage()
  39631. if err != nil {
  39632. fmt.Println(err)
  39633. }
  39634. return "", string(receivedMessage)
  39635. }
  39636. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39637. // WebSocket服务器地址
  39638. serverURL := "ws://127.0.0.1:8899"
  39639. // 解析WebSocket服务器地址
  39640. u, err := url.Parse(serverURL)
  39641. if err != nil {
  39642. }
  39643. // 建立WebSocket连接
  39644. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39645. if err != nil {
  39646. }
  39647. defer conn.Close()
  39648. input2 := make(map[string]interface{})
  39649. input := make(map[string]interface{})
  39650. inputData := make(map[string]interface{})
  39651. inputData["orgId"] = code
  39652. inputData["businessType"] = "01301"
  39653. inputData["operatorId"] = operator_id
  39654. inputData["operatorName"] = operator_name
  39655. inputData["officeId"] = "001"
  39656. inputData["officeName"] = "血透室"
  39657. inputData["deviceType"] = ""
  39658. input["data"] = inputData
  39659. input["orgId"] = code
  39660. input["transType"] = "ec.query"
  39661. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39662. input2["indata"] = input
  39663. bytesData, _ := json.Marshal(input2)
  39664. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39665. if err != nil {
  39666. fmt.Println(err)
  39667. }
  39668. // 接收消息
  39669. _, receivedMessage, err := conn.ReadMessage()
  39670. if err != nil {
  39671. fmt.Println(err)
  39672. }
  39673. return "", string(receivedMessage)
  39674. }
  39675. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39676. newArr = make([]string, 0)
  39677. for i := 0; i < len(arr); i++ {
  39678. repeat := false
  39679. for j := i + 1; j < len(arr); j++ {
  39680. if arr[i] == arr[j] {
  39681. repeat = true
  39682. break
  39683. }
  39684. }
  39685. if !repeat {
  39686. newArr = append(newArr, arr[i])
  39687. }
  39688. }
  39689. return
  39690. }
  39691. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39692. if len(idNumber) != 18 {
  39693. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39694. }
  39695. // 提取出生日期
  39696. year, err := strconv.Atoi(idNumber[6:10])
  39697. if err != nil {
  39698. return "", 0, err
  39699. }
  39700. month, err := strconv.Atoi(idNumber[10:12])
  39701. if err != nil {
  39702. return "", 0, err
  39703. }
  39704. day, err := strconv.Atoi(idNumber[12:14])
  39705. if err != nil {
  39706. return "", 0, err
  39707. }
  39708. // 格式化生日字符串
  39709. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39710. birthdateFormatted := birthdate.Format("2006-01-02")
  39711. // 计算年龄
  39712. today := time.Now()
  39713. age := today.Year() - birthdate.Year()
  39714. if today.YearDay() < birthdate.YearDay() {
  39715. age--
  39716. }
  39717. return birthdateFormatted, age, nil
  39718. }
  39719. // 从身份证号码中提取出生年月日
  39720. func getBirthDateFromIDCard(idCard string) (string, error) {
  39721. // 身份证号码长度应为18位
  39722. if len(idCard) != 18 {
  39723. return "", fmt.Errorf("身份证号码长度应为18位")
  39724. }
  39725. // 提取出生日期部分 (YYYYMMDD)
  39726. birthDateStr := idCard[6:14]
  39727. // 解析出生日期
  39728. birthDate, err := time.Parse("20060102", birthDateStr)
  39729. if err != nil {
  39730. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39731. }
  39732. // 格式化出生日期为 YYYY-MM-DD
  39733. formattedDate := birthDate.Format("2006-01-02")
  39734. return formattedDate, nil
  39735. }