his_api_controller.go 1.6MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611
  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. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  117. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  118. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  119. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  120. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  121. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  122. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  123. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  124. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  125. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  126. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  127. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  128. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  129. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  130. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  131. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  132. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  133. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  134. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  135. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  136. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  137. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  138. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  139. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  140. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  141. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  142. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  143. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  144. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  145. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  146. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  147. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  148. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  149. //库盘和变更
  150. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  151. //删除库盘和变更
  152. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  153. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  154. //药品变更
  155. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  156. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  157. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  158. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  159. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  160. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  161. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  162. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  163. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  164. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  165. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  166. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  167. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  168. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  169. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController) Get3201() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. 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)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  185. return
  186. //c.ServeSuccessJSON(map[string]interface{}{
  187. // "msg": "成功",
  188. //})
  189. }
  190. func (c *HisApiController) Get3508() {
  191. admin_user_id, _ := c.GetInt64("admin_user_id")
  192. drug_id, _ := c.GetInt64("id")
  193. start_time := c.GetString("start_time")
  194. end_time := c.GetString("end_time")
  195. adminUser := c.GetAdminUserInfo()
  196. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  198. drug, _ := service.GetDrugByID(drug_id)
  199. var struct3508 models.Struct3508
  200. struct3508.OrgName = miConfig.OrgName
  201. struct3508.FixmedinsCode = miConfig.Code
  202. struct3508.AccessKey = miConfig.AccessKey
  203. struct3508.Opter = curRoles.UserName
  204. struct3508.RequestUrl = miConfig.Url
  205. struct3508.Url = miConfig.Url
  206. struct3508.AppId = miConfig.Cainfo
  207. struct3508.AppSecret = miConfig.AppSecret
  208. struct3508.Enckey = miConfig.EncKey
  209. struct3508.SignKey = miConfig.SignKey
  210. struct3508.SecretKey = miConfig.SecretKey
  211. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  212. struct3508.Begndate = start_time
  213. struct3508.Enddate = end_time
  214. result1, result2, _ := service.FJyb3508(struct3508)
  215. saveLog(result1, result2, "3508", "3508")
  216. var res models.Result3508
  217. var respJSON2 map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. userJSONBytes2, _ := json.Marshal(respJSON2)
  224. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode == -1 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. } else {
  235. c.ServeSuccessJSON(map[string]interface{}{
  236. "info": res.Output,
  237. })
  238. }
  239. }
  240. func (c *HisApiController) Get3509() {
  241. admin_user_id, _ := c.GetInt64("admin_user_id")
  242. drug_id, _ := c.GetInt64("id")
  243. start_time := c.GetString("start_time")
  244. end_time := c.GetString("end_time")
  245. adminUser := c.GetAdminUserInfo()
  246. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  248. drug, _ := service.GetDrugByID(drug_id)
  249. var struct3508 models.Struct3509
  250. struct3508.OrgName = miConfig.OrgName
  251. struct3508.FixmedinsCode = miConfig.Code
  252. struct3508.AccessKey = miConfig.AccessKey
  253. struct3508.Opter = curRoles.UserName
  254. struct3508.RequestUrl = miConfig.Url
  255. struct3508.Url = miConfig.Url
  256. struct3508.AppId = miConfig.Cainfo
  257. struct3508.AppSecret = miConfig.AppSecret
  258. struct3508.Enckey = miConfig.EncKey
  259. struct3508.SignKey = miConfig.SignKey
  260. struct3508.SecretKey = miConfig.SecretKey
  261. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  262. struct3508.Begndate = start_time
  263. struct3508.Enddate = end_time
  264. result1, result2, _ := service.FJyb3509(struct3508)
  265. saveLog(result1, result2, "3509", "3509")
  266. var res models.Result3509
  267. var respJSON2 map[string]interface{}
  268. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  271. return
  272. }
  273. userJSONBytes2, _ := json.Marshal(respJSON2)
  274. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  275. utils.ErrorLog("解析失败:%v", err)
  276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  277. return
  278. }
  279. if res.Infcode == -1 {
  280. c.ServeSuccessJSON(map[string]interface{}{
  281. "failed_code": -10,
  282. "msg": res.ErrMsg,
  283. })
  284. } else {
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "info": res.Output,
  287. })
  288. }
  289. }
  290. func (c *HisApiController) Get3510() {
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. drug_id, _ := c.GetInt64("id")
  293. start_time := c.GetString("start_time")
  294. end_time := c.GetString("end_time")
  295. adminUser := c.GetAdminUserInfo()
  296. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  298. drug, _ := service.GetDrugByID(drug_id)
  299. var struct3508 models.Struct3510
  300. struct3508.FixmedinsCode = miConfig.Code
  301. struct3508.OrgName = miConfig.OrgName
  302. struct3508.AccessKey = miConfig.AccessKey
  303. struct3508.Opter = curRoles.UserName
  304. struct3508.RequestUrl = miConfig.Url
  305. struct3508.Url = miConfig.Url
  306. struct3508.AppId = miConfig.Cainfo
  307. struct3508.AppSecret = miConfig.AppSecret
  308. struct3508.Enckey = miConfig.EncKey
  309. struct3508.SignKey = miConfig.SignKey
  310. struct3508.SecretKey = miConfig.SecretKey
  311. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  312. struct3508.Begndate = start_time
  313. struct3508.Enddate = end_time
  314. result1, result2, _ := service.FJyb3510(struct3508)
  315. saveLog(result1, result2, "3510", "3510")
  316. var res models.Result3510
  317. var respJSON2 map[string]interface{}
  318. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  321. return
  322. }
  323. userJSONBytes2, _ := json.Marshal(respJSON2)
  324. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  327. return
  328. }
  329. if res.Infcode == -1 {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": res.ErrMsg,
  333. })
  334. } else {
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "info": res.Output,
  337. })
  338. }
  339. }
  340. func (c *HisApiController) Get3511() {
  341. admin_user_id, _ := c.GetInt64("admin_user_id")
  342. drug_id, _ := c.GetInt64("id")
  343. start_time := c.GetString("start_time")
  344. end_time := c.GetString("end_time")
  345. adminUser := c.GetAdminUserInfo()
  346. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  348. drug, _ := service.GetDrugByID(drug_id)
  349. var struct3508 models.Struct3511
  350. struct3508.FixmedinsCode = miConfig.Code
  351. struct3508.OrgName = miConfig.OrgName
  352. struct3508.AccessKey = miConfig.AccessKey
  353. struct3508.Opter = curRoles.UserName
  354. struct3508.RequestUrl = miConfig.Url
  355. struct3508.Url = miConfig.Url
  356. struct3508.AppId = miConfig.Cainfo
  357. struct3508.AppSecret = miConfig.AppSecret
  358. struct3508.Enckey = miConfig.EncKey
  359. struct3508.SignKey = miConfig.SignKey
  360. struct3508.SecretKey = miConfig.SecretKey
  361. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  362. struct3508.Begndate = start_time
  363. struct3508.Enddate = end_time
  364. result1, result2, _ := service.FJyb3511(struct3508)
  365. saveLog(result1, result2, "3511", "3511")
  366. var res models.Result3511
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode == -1 {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. } else {
  385. c.ServeSuccessJSON(map[string]interface{}{
  386. "info": res.Output,
  387. })
  388. }
  389. }
  390. func (c *HisApiController) Get3512() {
  391. admin_user_id, _ := c.GetInt64("admin_user_id")
  392. drug_id, _ := c.GetInt64("id")
  393. start_time := c.GetString("start_time")
  394. end_time := c.GetString("end_time")
  395. adminUser := c.GetAdminUserInfo()
  396. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  398. drug, _ := service.GetDrugByID(drug_id)
  399. var struct3508 models.Struct3512
  400. struct3508.FixmedinsCode = miConfig.Code
  401. struct3508.OrgName = miConfig.OrgName
  402. struct3508.AccessKey = miConfig.AccessKey
  403. struct3508.Opter = curRoles.UserName
  404. struct3508.RequestUrl = miConfig.Url
  405. struct3508.Url = miConfig.Url
  406. struct3508.AppId = miConfig.Cainfo
  407. struct3508.AppSecret = miConfig.AppSecret
  408. struct3508.Enckey = miConfig.EncKey
  409. struct3508.SignKey = miConfig.SignKey
  410. struct3508.SecretKey = miConfig.SecretKey
  411. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  412. struct3508.Begndate = start_time
  413. struct3508.Enddate = end_time
  414. result1, result2, _ := service.FJyb3512(struct3508)
  415. saveLog(result1, result2, "3512", "3512")
  416. var res models.Result3512
  417. var respJSON2 map[string]interface{}
  418. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  421. return
  422. }
  423. userJSONBytes2, _ := json.Marshal(respJSON2)
  424. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == -1 {
  430. c.ServeSuccessJSON(map[string]interface{}{
  431. "failed_code": -10,
  432. "msg": res.ErrMsg,
  433. })
  434. } else {
  435. c.ServeSuccessJSON(map[string]interface{}{
  436. "info": res.Output,
  437. })
  438. }
  439. }
  440. func (c *HisApiController) Get3513() {
  441. admin_user_id, _ := c.GetInt64("admin_user_id")
  442. drug_id, _ := c.GetInt64("id")
  443. start_time := c.GetString("start_time")
  444. end_time := c.GetString("end_time")
  445. adminUser := c.GetAdminUserInfo()
  446. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  448. drug, _ := service.GetDrugByID(drug_id)
  449. var struct3508 models.Struct3513
  450. struct3508.FixmedinsCode = miConfig.Code
  451. struct3508.OrgName = miConfig.OrgName
  452. struct3508.AccessKey = miConfig.AccessKey
  453. struct3508.Opter = curRoles.UserName
  454. struct3508.RequestUrl = miConfig.Url
  455. struct3508.Url = miConfig.Url
  456. struct3508.AppId = miConfig.Cainfo
  457. struct3508.AppSecret = miConfig.AppSecret
  458. struct3508.Enckey = miConfig.EncKey
  459. struct3508.SignKey = miConfig.SignKey
  460. struct3508.SecretKey = miConfig.SecretKey
  461. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  462. struct3508.Begndate = start_time
  463. struct3508.Enddate = end_time
  464. result1, result2, _ := service.FJyb3513(struct3508)
  465. saveLog(result1, result2, "3513", "3513")
  466. var res models.Result3513
  467. var respJSON2 map[string]interface{}
  468. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  471. return
  472. }
  473. userJSONBytes2, _ := json.Marshal(respJSON2)
  474. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  475. utils.ErrorLog("解析失败:%v", err)
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  477. return
  478. }
  479. if res.Infcode == -1 {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "failed_code": -10,
  482. "msg": res.ErrMsg,
  483. })
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "info": res.Output,
  487. })
  488. }
  489. }
  490. func (c *HisApiController) Get35081() {
  491. admin_user_id, _ := c.GetInt64("admin_user_id")
  492. drug_id, _ := c.GetInt64("id")
  493. //start_time := c.GetString("start_time")
  494. //end_time := c.GetString("end_time")
  495. page, _ := c.GetInt("page")
  496. adminUser := c.GetAdminUserInfo()
  497. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  499. drug, _ := service.GetDrugByID(drug_id)
  500. var struct3508 models.Struct35081
  501. struct3508.FixmedinsCode = miConfig.Code
  502. struct3508.OrgName = miConfig.OrgName
  503. struct3508.AccessKey = miConfig.AccessKey
  504. struct3508.Opter = curRoles.UserName
  505. struct3508.RequestUrl = miConfig.Url
  506. struct3508.Url = miConfig.Url
  507. struct3508.AppId = miConfig.Cainfo
  508. struct3508.AppSecret = miConfig.AppSecret
  509. struct3508.Enckey = miConfig.EncKey
  510. struct3508.SignKey = miConfig.SignKey
  511. struct3508.SecretKey = miConfig.SecretKey
  512. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  513. struct3508.PageNum = page
  514. struct3508.PageSize = 10
  515. result1, result2, _ := service.FJyb35081(struct3508)
  516. saveLog(result1, result2, "35081", "35081")
  517. var res models.Result35081
  518. var respJSON2 map[string]interface{}
  519. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  522. return
  523. }
  524. userJSONBytes2, _ := json.Marshal(respJSON2)
  525. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  526. utils.ErrorLog("解析失败:%v", err)
  527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  528. return
  529. }
  530. if res.Infcode == -1 {
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "failed_code": -10,
  533. "msg": res.ErrMsg,
  534. })
  535. } else {
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "info": res.Output,
  538. })
  539. }
  540. }
  541. func (c *HisApiController) Get35082() {
  542. admin_user_id, _ := c.GetInt64("admin_user_id")
  543. drug_id, _ := c.GetInt64("id")
  544. //start_time := c.GetString("start_time")
  545. //end_time := c.GetString("end_time")
  546. page, _ := c.GetInt("page")
  547. adminUser := c.GetAdminUserInfo()
  548. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. drug, _ := service.GetDrugByID(drug_id)
  551. var struct3508 models.Struct35082
  552. struct3508.FixmedinsCode = miConfig.Code
  553. struct3508.OrgName = miConfig.OrgName
  554. struct3508.AccessKey = miConfig.AccessKey
  555. struct3508.Opter = curRoles.UserName
  556. struct3508.RequestUrl = miConfig.Url
  557. struct3508.Url = miConfig.Url
  558. struct3508.AppId = miConfig.Cainfo
  559. struct3508.AppSecret = miConfig.AppSecret
  560. struct3508.Enckey = miConfig.EncKey
  561. struct3508.SignKey = miConfig.SignKey
  562. struct3508.SecretKey = miConfig.SecretKey
  563. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  564. struct3508.PageNum = page
  565. struct3508.PageSize = 10
  566. result1, result2, _ := service.FJyb35082(struct3508)
  567. saveLog(result1, result2, "35082", "35082")
  568. var res models.Result35082
  569. var respJSON2 map[string]interface{}
  570. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. userJSONBytes2, _ := json.Marshal(respJSON2)
  576. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  577. utils.ErrorLog("解析失败:%v", err)
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  579. return
  580. }
  581. if res.Infcode == -1 {
  582. c.ServeSuccessJSON(map[string]interface{}{
  583. "failed_code": -10,
  584. "msg": res.ErrMsg,
  585. })
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "info": res.Output,
  589. })
  590. }
  591. }
  592. func (c *HisApiController) FJ3501AND3502() {
  593. ids := c.GetString("ids")
  594. admin_user_id, _ := c.GetInt64("admin_user_id")
  595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  596. id_arr := strings.Split(ids, ",")
  597. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  599. //库盘
  600. var errs []string
  601. for _, drug := range drugs {
  602. if drug.IsPc == 0 {
  603. var res2 ResultSix
  604. var res3 ResultSix
  605. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  606. var struct3501 models.Struct3501
  607. struct3501.Code = miConfig.Code
  608. struct3501.OrgName = miConfig.OrgName
  609. struct3501.AccessKey = miConfig.AccessKey
  610. struct3501.Opter = roles.UserName
  611. struct3501.RequestUrl = miConfig.Url
  612. struct3501.Url = miConfig.Url
  613. struct3501.AppId = miConfig.Cainfo
  614. struct3501.AppSecret = miConfig.AppSecret
  615. struct3501.Enckey = miConfig.EncKey
  616. struct3501.SignKey = miConfig.SignKey
  617. struct3501.SecretKey = miConfig.SecretKey
  618. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  621. struct3501.RxFlag = "1"
  622. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  623. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  624. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  625. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  626. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  627. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  628. struct3501.FixmedinsBchno = number
  629. struct3501.DrugTracCodg = drug.DrugCode
  630. memo := make(map[string]interface{})
  631. memo["pric"] = drug.Price
  632. bytesData, _ := json.Marshal(memo)
  633. struct3501.Memo = string(bytesData)
  634. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  635. result1, result2, _ := service.FJyb3501(struct3501)
  636. saveLog(result1, result2, "3501", "3501")
  637. //saveLog(result, requestLog, "2201", "挂号")
  638. var respJSON2 map[string]interface{}
  639. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. userJSONBytes2, _ := json.Marshal(respJSON2)
  645. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  646. utils.ErrorLog("解析失败:%v", err)
  647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  648. return
  649. }
  650. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  651. data := make(map[string]interface{})
  652. data["struct_3501s"] = struct3501
  653. client := &http.Client{}
  654. bytesData, _ := json.Marshal(data)
  655. var req *http.Request
  656. if miConfig.MdtrtareaAdmvs == "320921" {
  657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. } else {
  659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  660. }
  661. resp, _ := client.Do(req)
  662. defer resp.Body.Close()
  663. body, ioErr := ioutil.ReadAll(resp.Body)
  664. if ioErr != nil {
  665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  666. }
  667. var respJSON map[string]interface{}
  668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. var resSix10265 ResultSix10265 //1101结果
  674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  675. result, _ := json.Marshal(respJSON)
  676. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  677. utils.ErrorLog("解析失败:%v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  682. res2.Output = resSix10265.Output
  683. res2.ErrMsg = resSix10265.ErrMsg
  684. res2.Cainfo = resSix10265.Cainfo
  685. res2.WarnMsg = resSix10265.WarnMsg
  686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  687. res2.Infcode = infocode
  688. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  689. data := make(map[string]interface{})
  690. data["struct_3501s"] = struct3501
  691. client := &http.Client{}
  692. bytesData, _ := json.Marshal(data)
  693. var req *http.Request
  694. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  695. resp, _ := client.Do(req)
  696. defer resp.Body.Close()
  697. body, ioErr := ioutil.ReadAll(resp.Body)
  698. if ioErr != nil {
  699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  700. }
  701. var respJSON map[string]interface{}
  702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  705. return
  706. }
  707. var resSix10265 ResultSix10265 //1101结果
  708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  709. result, _ := json.Marshal(respJSON)
  710. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  711. utils.ErrorLog("解析失败:%v", err)
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. res2.InfRefmsgid = resSix10265.InfRefmsgid
  716. res2.Output = resSix10265.Output
  717. res2.ErrMsg = resSix10265.ErrMsg
  718. res2.Cainfo = resSix10265.Cainfo
  719. res2.WarnMsg = resSix10265.WarnMsg
  720. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  721. res2.Infcode = infocode
  722. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  723. data := make(map[string]interface{})
  724. data["struct_3501s"] = struct3501
  725. client := &http.Client{}
  726. bytesData, _ := json.Marshal(data)
  727. var req *http.Request
  728. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  729. resp, _ := client.Do(req)
  730. defer resp.Body.Close()
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. var resSix10265 ResultSix10265 //1101结果
  742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  743. result, _ := json.Marshal(respJSON)
  744. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  745. utils.ErrorLog("解析失败:%v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  750. res2.Output = resSix10265.Output
  751. res2.ErrMsg = resSix10265.ErrMsg
  752. res2.Cainfo = resSix10265.Cainfo
  753. res2.WarnMsg = resSix10265.WarnMsg
  754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  755. res2.Infcode = infocode
  756. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  757. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  758. saveLog(result1, result2, "3501", "3501")
  759. //saveLog(result, requestLog, "2201", "挂号")
  760. var respJSON2 map[string]interface{}
  761. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. userJSONBytes2, _ := json.Marshal(respJSON2)
  767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  768. utils.ErrorLog("解析失败:%v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. }
  773. if res2.Infcode != -1 {
  774. drug.IsPc = 1
  775. drug.Bchno = number
  776. drug.PcDate = time.Now().Unix()
  777. err := service.SaveW(drug)
  778. if err == nil {
  779. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  780. var struct3502 models.Struct3502
  781. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  784. struct3502.FixmedinsCode = miConfig.Code
  785. struct3502.Code = miConfig.Code
  786. struct3502.RxFlag = "0"
  787. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  788. struct3502.OrgName = miConfig.OrgName
  789. struct3502.Opter = roles.UserName
  790. struct3502.AccessKey = miConfig.AccessKey
  791. struct3502.RequestUrl = miConfig.Url
  792. struct3502.SecretKey = miConfig.SecretKey
  793. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  794. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  795. struct3502.Url = miConfig.Url
  796. struct3502.AppId = miConfig.Cainfo
  797. struct3502.AppSecret = miConfig.AppSecret
  798. struct3502.Enckey = miConfig.EncKey
  799. struct3502.SignKey = miConfig.SignKey
  800. struct3502.SecretKey = miConfig.SecretKey
  801. struct3502.DrugTracCodg = drug.DrugCode
  802. struct3502.Memo = ""
  803. struct3502.InvChgType = "108"
  804. struct3502.FixmedinsBchno = bg_number
  805. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  806. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  807. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  808. result11, result22, _ := service.FJyb3502(struct3502)
  809. saveLog(result11, result22, "3502", "3502")
  810. var respJSON3 map[string]interface{}
  811. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. userJSONBytes3, _ := json.Marshal(respJSON3)
  817. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  818. utils.ErrorLog("解析失败:%v", err)
  819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  820. return
  821. }
  822. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  823. data := make(map[string]interface{})
  824. data["struct_3502s"] = struct3502
  825. client := &http.Client{}
  826. bytesData, _ := json.Marshal(data)
  827. var req *http.Request
  828. if miConfig.MdtrtareaAdmvs == "320921" {
  829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. } else {
  831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  832. }
  833. resp, _ := client.Do(req)
  834. defer resp.Body.Close()
  835. body, ioErr := ioutil.ReadAll(resp.Body)
  836. if ioErr != nil {
  837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  838. }
  839. var respJSON map[string]interface{}
  840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  843. return
  844. }
  845. var resSix10265 ResultSix10265 //1101结果
  846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  847. result, _ := json.Marshal(respJSON)
  848. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  849. utils.ErrorLog("解析失败:%v", err)
  850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  851. return
  852. }
  853. res3.InfRefmsgid = resSix10265.InfRefmsgid
  854. res3.Output = resSix10265.Output
  855. res3.ErrMsg = resSix10265.ErrMsg
  856. res3.Cainfo = resSix10265.Cainfo
  857. res3.WarnMsg = resSix10265.WarnMsg
  858. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  859. res3.Infcode = infocode
  860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  861. data := make(map[string]interface{})
  862. data["struct_3502s"] = struct3502
  863. client := &http.Client{}
  864. bytesData, _ := json.Marshal(data)
  865. var req *http.Request
  866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  867. resp, _ := client.Do(req)
  868. defer resp.Body.Close()
  869. body, ioErr := ioutil.ReadAll(resp.Body)
  870. if ioErr != nil {
  871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  872. }
  873. var respJSON map[string]interface{}
  874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. var resSix10265 ResultSix10265 //1101结果
  880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  881. result, _ := json.Marshal(respJSON)
  882. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  883. utils.ErrorLog("解析失败:%v", err)
  884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  885. return
  886. }
  887. res3.InfRefmsgid = resSix10265.InfRefmsgid
  888. res3.Output = resSix10265.Output
  889. res3.ErrMsg = resSix10265.ErrMsg
  890. res3.Cainfo = resSix10265.Cainfo
  891. res3.WarnMsg = resSix10265.WarnMsg
  892. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  893. res3.Infcode = infocode
  894. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  895. data := make(map[string]interface{})
  896. data["struct_3501s"] = struct3501
  897. client := &http.Client{}
  898. bytesData, _ := json.Marshal(data)
  899. var req *http.Request
  900. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  901. resp, _ := client.Do(req)
  902. defer resp.Body.Close()
  903. body, ioErr := ioutil.ReadAll(resp.Body)
  904. if ioErr != nil {
  905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  906. }
  907. var respJSON map[string]interface{}
  908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var resSix10265 ResultSix10265 //1101结果
  914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  915. result, _ := json.Marshal(respJSON)
  916. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  917. utils.ErrorLog("解析失败:%v", err)
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  922. res2.Output = resSix10265.Output
  923. res2.ErrMsg = resSix10265.ErrMsg
  924. res2.Cainfo = resSix10265.Cainfo
  925. res2.WarnMsg = resSix10265.WarnMsg
  926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  927. res2.Infcode = infocode
  928. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  929. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  930. saveLog(result11, result22, "3502", "3502")
  931. var respJSON3 map[string]interface{}
  932. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. userJSONBytes3, _ := json.Marshal(respJSON3)
  938. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  941. return
  942. }
  943. }
  944. if res3.Infcode == -1 {
  945. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "failed_code": -10,
  948. "msg": res3.ErrMsg,
  949. })
  950. } else {
  951. drug.IsBg = 1
  952. drug.BgBchno = bg_number
  953. service.SaveW(drug)
  954. }
  955. }
  956. } else {
  957. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  958. }
  959. }
  960. //变更
  961. }
  962. if len(errs) == 0 {
  963. c.ServeSuccessJSON(map[string]interface{}{
  964. "msg": "盘存变更成功",
  965. })
  966. } else {
  967. c.ServeSuccessJSON(map[string]interface{}{
  968. "failed_code": -10,
  969. "msg": errs,
  970. })
  971. }
  972. }
  973. func (c *HisApiController) DeletePCandBG() {
  974. ids := c.GetString("ids")
  975. id_arr := strings.Split(ids, ",")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. var err []string
  981. for _, item := range drugs {
  982. if item.IsPc == 1 && item.IsBg == 1 {
  983. var res FJ3507Result
  984. var res2 FJ3507Result
  985. var struct3507 models.Struct3507
  986. struct3507.FixmedinsBchno = item.Bchno
  987. struct3507.InvDataType = "1"
  988. struct3507.Opter = roles.UserName
  989. struct3507.OrgName = miConfig.OrgName
  990. struct3507.AccessKey = miConfig.AccessKey
  991. struct3507.RequestUrl = miConfig.Url
  992. struct3507.FixmedinsCode = miConfig.Code
  993. struct3507.Code = miConfig.Code
  994. struct3507.SecretKey = miConfig.SecretKey
  995. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  996. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  997. struct3507.Url = miConfig.Url
  998. struct3507.AppId = miConfig.Cainfo
  999. struct3507.AppSecret = miConfig.AppSecret
  1000. struct3507.Enckey = miConfig.EncKey
  1001. struct3507.SignKey = miConfig.SignKey
  1002. struct3507.SecretKey = miConfig.SecretKey
  1003. if miConfig.MdtrtareaAdmvs == "350500" {
  1004. result, result1, _ := service.FJyb3507(struct3507)
  1005. saveLog(result, result1, "3507", "3507")
  1006. var respJSON2 map[string]interface{}
  1007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. userJSONBytes2, _ := json.Marshal(respJSON2)
  1013. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1014. utils.ErrorLog("解析失败:%v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. } else {
  1019. data := make(map[string]interface{})
  1020. data["struct_3507s"] = struct3507
  1021. client := &http.Client{}
  1022. bytesData, _ := json.Marshal(data)
  1023. var req *http.Request
  1024. if miConfig.MdtrtareaAdmvs == "320921" {
  1025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1026. } else {
  1027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1028. }
  1029. resp, _ := client.Do(req)
  1030. defer resp.Body.Close()
  1031. body, ioErr := ioutil.ReadAll(resp.Body)
  1032. if ioErr != nil {
  1033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1034. }
  1035. var respJSON map[string]interface{}
  1036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. var resSix10265 ResultSix10265 //1101结果
  1042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1043. result, _ := json.Marshal(respJSON)
  1044. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. res.InfRefmsgid = resSix10265.InfRefmsgid
  1050. //res.Output = resSix10265.Output
  1051. res.ErrMsg = resSix10265.ErrMsg
  1052. res.Cainfo = resSix10265.Cainfo
  1053. res.WarnMsg = resSix10265.WarnMsg
  1054. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1055. res.Infcode = infocode
  1056. }
  1057. if res.Infcode == 0 {
  1058. item.IsPc = 0
  1059. err2 := service.SaveW(item)
  1060. if err2 == nil {
  1061. var struct3507_2 models.Struct3507
  1062. struct3507_2.OrgName = miConfig.OrgName
  1063. struct3507_2.AccessKey = miConfig.AccessKey
  1064. struct3507_2.RequestUrl = miConfig.Url
  1065. struct3507_2.Opter = roles.UserName
  1066. struct3507_2.FixmedinsCode = miConfig.Code
  1067. struct3507_2.Code = miConfig.Code
  1068. struct3507_2.SecretKey = miConfig.SecretKey
  1069. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1070. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1071. struct3507_2.Url = miConfig.Url
  1072. struct3507_2.AppId = miConfig.Cainfo
  1073. struct3507_2.AppSecret = miConfig.AppSecret
  1074. struct3507_2.Enckey = miConfig.EncKey
  1075. struct3507_2.SignKey = miConfig.SignKey
  1076. struct3507_2.SecretKey = miConfig.SecretKey
  1077. struct3507_2.FixmedinsBchno = item.BgBchno
  1078. struct3507_2.InvDataType = "2"
  1079. if miConfig.MdtrtareaAdmvs == "350500" {
  1080. result11, result22, _ := service.FJyb3507(struct3507_2)
  1081. saveLog(result11, result22, "3507", "3507")
  1082. var respJSON3 map[string]interface{}
  1083. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. userJSONBytes3, _ := json.Marshal(respJSON3)
  1089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1090. utils.ErrorLog("解析失败:%v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. } else {
  1095. data := make(map[string]interface{})
  1096. data["struct_3507s"] = struct3507_2
  1097. client := &http.Client{}
  1098. bytesData, _ := json.Marshal(data)
  1099. var req *http.Request
  1100. if miConfig.MdtrtareaAdmvs == "320921" {
  1101. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1102. } else {
  1103. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1104. }
  1105. resp, _ := client.Do(req)
  1106. defer resp.Body.Close()
  1107. body, ioErr := ioutil.ReadAll(resp.Body)
  1108. if ioErr != nil {
  1109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1110. }
  1111. var respJSON map[string]interface{}
  1112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1115. return
  1116. }
  1117. var resSix10265 ResultSix10265 //1101结果
  1118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1119. result, _ := json.Marshal(respJSON)
  1120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1121. utils.ErrorLog("解析失败:%v", err)
  1122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1123. return
  1124. }
  1125. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1126. //res2.Output = resSix10265.Output
  1127. res2.ErrMsg = resSix10265.ErrMsg
  1128. res2.Cainfo = resSix10265.Cainfo
  1129. res2.WarnMsg = resSix10265.WarnMsg
  1130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1131. res2.Infcode = infocode
  1132. }
  1133. if res2.Infcode != -1 {
  1134. item.IsBg = 0
  1135. item.Bchno = ""
  1136. item.BgBchno = ""
  1137. item.PcDate = 0
  1138. service.SaveW(item)
  1139. } else {
  1140. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1141. }
  1142. }
  1143. } else {
  1144. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1145. }
  1146. }
  1147. if item.IsPc == 1 && item.IsBg == 0 {
  1148. var res FJ3507Result
  1149. var struct3507 models.Struct3507
  1150. struct3507.FixmedinsBchno = item.Bchno
  1151. struct3507.InvDataType = "1"
  1152. struct3507.Opter = roles.UserName
  1153. struct3507.FixmedinsCode = miConfig.Code
  1154. struct3507.Code = miConfig.Code
  1155. struct3507.OrgName = miConfig.OrgName
  1156. struct3507.AccessKey = miConfig.AccessKey
  1157. struct3507.RequestUrl = miConfig.Url
  1158. struct3507.SecretKey = miConfig.SecretKey
  1159. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1160. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1161. struct3507.Url = miConfig.Url
  1162. struct3507.AppId = miConfig.Cainfo
  1163. struct3507.AppSecret = miConfig.AppSecret
  1164. struct3507.Enckey = miConfig.EncKey
  1165. struct3507.SignKey = miConfig.SignKey
  1166. struct3507.SecretKey = miConfig.SecretKey
  1167. //result, result1, _ := service.FJyb3507(struct3507)
  1168. //saveLog(result, result1, "3507", "3507")
  1169. if miConfig.MdtrtareaAdmvs == "350500" {
  1170. result, result1, _ := service.FJyb3507(struct3507)
  1171. saveLog(result, result1, "3507", "3507")
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes2, _ := json.Marshal(respJSON2)
  1179. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. } else {
  1185. data := make(map[string]interface{})
  1186. data["struct_3507s"] = struct3507
  1187. client := &http.Client{}
  1188. bytesData, _ := json.Marshal(data)
  1189. var req *http.Request
  1190. if miConfig.MdtrtareaAdmvs == "320921" {
  1191. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1192. } else {
  1193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. }
  1195. resp, _ := client.Do(req)
  1196. defer resp.Body.Close()
  1197. body, ioErr := ioutil.ReadAll(resp.Body)
  1198. if ioErr != nil {
  1199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1200. }
  1201. var respJSON map[string]interface{}
  1202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. var resSix10265 ResultSix10265 //1101结果
  1208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1209. result, _ := json.Marshal(respJSON)
  1210. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. res.InfRefmsgid = resSix10265.InfRefmsgid
  1216. //res.Output = resSix10265.Output
  1217. res.ErrMsg = resSix10265.ErrMsg
  1218. res.Cainfo = resSix10265.Cainfo
  1219. res.WarnMsg = resSix10265.WarnMsg
  1220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1221. res.Infcode = infocode
  1222. }
  1223. if res.Infcode == 0 {
  1224. item.IsPc = 0
  1225. item.Bchno = ""
  1226. item.BgBchno = ""
  1227. item.PcDate = 0
  1228. service.SaveW(item)
  1229. } else {
  1230. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1231. }
  1232. }
  1233. if item.IsPc == 0 && item.IsBg == 1 {
  1234. var res FJ3507Result
  1235. var struct3507 models.Struct3507
  1236. struct3507.FixmedinsBchno = item.BgBchno
  1237. struct3507.InvDataType = "2"
  1238. struct3507.Opter = roles.UserName
  1239. struct3507.FixmedinsCode = miConfig.Code
  1240. struct3507.OrgName = miConfig.OrgName
  1241. struct3507.AccessKey = miConfig.AccessKey
  1242. struct3507.RequestUrl = miConfig.Url
  1243. struct3507.SecretKey = miConfig.SecretKey
  1244. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1245. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1246. struct3507.Url = miConfig.Url
  1247. struct3507.AppId = miConfig.Cainfo
  1248. struct3507.AppSecret = miConfig.AppSecret
  1249. struct3507.Enckey = miConfig.EncKey
  1250. struct3507.SignKey = miConfig.SignKey
  1251. struct3507.SecretKey = miConfig.SecretKey
  1252. //result, result1, _ := service.FJyb3507(struct3507)
  1253. //saveLog(result, result1, "3507", "3507")
  1254. if miConfig.MdtrtareaAdmvs == "350500" {
  1255. result, result1, _ := service.FJyb3507(struct3507)
  1256. saveLog(result, result1, "3507", "3507")
  1257. var respJSON2 map[string]interface{}
  1258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1261. return
  1262. }
  1263. userJSONBytes2, _ := json.Marshal(respJSON2)
  1264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. } else {
  1270. data := make(map[string]interface{})
  1271. data["struct_3507s"] = struct3507
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. }
  1286. var respJSON map[string]interface{}
  1287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1290. return
  1291. }
  1292. var resSix10265 ResultSix10265 //1101结果
  1293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1294. result, _ := json.Marshal(respJSON)
  1295. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1296. utils.ErrorLog("解析失败:%v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. res.InfRefmsgid = resSix10265.InfRefmsgid
  1301. //res.Output = resSix10265.Output
  1302. res.ErrMsg = resSix10265.ErrMsg
  1303. res.Cainfo = resSix10265.Cainfo
  1304. res.WarnMsg = resSix10265.WarnMsg
  1305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1306. res.Infcode = infocode
  1307. }
  1308. if res.Infcode == 0 {
  1309. item.IsBg = 0
  1310. item.Bchno = ""
  1311. item.BgBchno = ""
  1312. item.PcDate = 0
  1313. service.SaveW(item)
  1314. } else {
  1315. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1316. }
  1317. }
  1318. }
  1319. if len(err) == 0 {
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "msg": "删除盘存变更成功",
  1322. })
  1323. } else {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "failed_code": -10,
  1326. "msg": err,
  1327. })
  1328. }
  1329. }
  1330. func (c *HisApiController) DeleteXSandBG() {
  1331. ids := c.GetString("ids")
  1332. id_arr := strings.Split(ids, ",")
  1333. admin_user_id, _ := c.GetInt64("admin_user_id")
  1334. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1337. var err []string
  1338. for _, item := range flows {
  1339. if item.IsSale == 1 && item.IsChange == 1 {
  1340. var res FJ3507Result
  1341. var res2 FJ3507Result
  1342. var struct3507 models.Struct3507
  1343. struct3507.FixmedinsBchno = item.Bchno
  1344. struct3507.InvDataType = "4"
  1345. struct3507.Opter = roles.UserName
  1346. struct3507.OrgName = miConfig.OrgName
  1347. struct3507.AccessKey = miConfig.AccessKey
  1348. struct3507.RequestUrl = miConfig.Url
  1349. struct3507.FixmedinsCode = miConfig.Code
  1350. struct3507.SecretKey = miConfig.SecretKey
  1351. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1352. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1353. struct3507.Url = miConfig.Url
  1354. struct3507.AppId = miConfig.Cainfo
  1355. struct3507.AppSecret = miConfig.AppSecret
  1356. struct3507.Enckey = miConfig.EncKey
  1357. struct3507.SignKey = miConfig.SignKey
  1358. struct3507.SecretKey = miConfig.SecretKey
  1359. //result, result1, _ := service.FJyb3507(struct3507)
  1360. //saveLog(result, result1, "3507", "3507")
  1361. if miConfig.MdtrtareaAdmvs == "350500" {
  1362. result, result1, _ := service.FJyb3507(struct3507)
  1363. saveLog(result, result1, "3507", "3507")
  1364. var respJSON2 map[string]interface{}
  1365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. userJSONBytes2, _ := json.Marshal(respJSON2)
  1371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1372. utils.ErrorLog("解析失败:%v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. } else {
  1377. data := make(map[string]interface{})
  1378. data["struct_3507s"] = struct3507
  1379. client := &http.Client{}
  1380. bytesData, _ := json.Marshal(data)
  1381. var req *http.Request
  1382. if miConfig.MdtrtareaAdmvs == "320921" {
  1383. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1384. } else {
  1385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1386. }
  1387. resp, _ := client.Do(req)
  1388. defer resp.Body.Close()
  1389. body, ioErr := ioutil.ReadAll(resp.Body)
  1390. if ioErr != nil {
  1391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1392. }
  1393. var respJSON map[string]interface{}
  1394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. return
  1398. }
  1399. var resSix10265 ResultSix10265 //1101结果
  1400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1401. result, _ := json.Marshal(respJSON)
  1402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. res.InfRefmsgid = resSix10265.InfRefmsgid
  1408. //res.Output = resSix10265.Output
  1409. res.ErrMsg = resSix10265.ErrMsg
  1410. res.Cainfo = resSix10265.Cainfo
  1411. res.WarnMsg = resSix10265.WarnMsg
  1412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1413. res.Infcode = infocode
  1414. }
  1415. if res.Infcode == 0 {
  1416. item.IsSale = 0
  1417. item.SaleDate = ""
  1418. item.Bchno = ""
  1419. err2 := service.SaveDF(item)
  1420. if err2 == nil {
  1421. var struct3507_2 models.Struct3507
  1422. struct3507_2.OrgName = miConfig.OrgName
  1423. struct3507_2.AccessKey = miConfig.AccessKey
  1424. struct3507_2.RequestUrl = miConfig.Url
  1425. struct3507_2.Opter = roles.UserName
  1426. struct3507_2.FixmedinsCode = miConfig.Code
  1427. struct3507_2.Code = miConfig.Code
  1428. struct3507_2.SecretKey = miConfig.SecretKey
  1429. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1430. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1431. struct3507_2.Url = miConfig.Url
  1432. struct3507_2.AppId = miConfig.Cainfo
  1433. struct3507_2.AppSecret = miConfig.AppSecret
  1434. struct3507_2.Enckey = miConfig.EncKey
  1435. struct3507_2.SignKey = miConfig.SignKey
  1436. struct3507_2.SecretKey = miConfig.SecretKey
  1437. struct3507_2.FixmedinsBchno = item.BgBchno
  1438. struct3507_2.InvDataType = "2"
  1439. if miConfig.MdtrtareaAdmvs == "350500" {
  1440. result11, result22, _ := service.FJyb3507(struct3507_2)
  1441. saveLog(result11, result22, "3507", "3507")
  1442. var respJSON3 map[string]interface{}
  1443. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. return
  1447. }
  1448. userJSONBytes3, _ := json.Marshal(respJSON3)
  1449. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1450. utils.ErrorLog("解析失败:%v", err)
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1452. return
  1453. }
  1454. } else {
  1455. data := make(map[string]interface{})
  1456. data["struct_3507s"] = struct3507_2
  1457. client := &http.Client{}
  1458. bytesData, _ := json.Marshal(data)
  1459. var req *http.Request
  1460. if miConfig.MdtrtareaAdmvs == "320921" {
  1461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1462. } else {
  1463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1464. }
  1465. resp, _ := client.Do(req)
  1466. defer resp.Body.Close()
  1467. body, ioErr := ioutil.ReadAll(resp.Body)
  1468. if ioErr != nil {
  1469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1470. }
  1471. var respJSON map[string]interface{}
  1472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1475. return
  1476. }
  1477. var resSix10265 ResultSix10265 //1101结果
  1478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1479. result, _ := json.Marshal(respJSON)
  1480. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1481. utils.ErrorLog("解析失败:%v", err)
  1482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1483. return
  1484. }
  1485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1486. //res.Output = resSix10265.Output
  1487. res2.ErrMsg = resSix10265.ErrMsg
  1488. res2.Cainfo = resSix10265.Cainfo
  1489. res2.WarnMsg = resSix10265.WarnMsg
  1490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1491. res2.Infcode = infocode
  1492. }
  1493. if res2.Infcode == 0 {
  1494. item.IsChange = 0
  1495. item.BgBchno = ""
  1496. service.SaveDF2(item)
  1497. } else {
  1498. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1499. }
  1500. }
  1501. } else {
  1502. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1503. }
  1504. }
  1505. if item.IsSale == 2 && item.IsChange == 1 {
  1506. var res FJ3507Result
  1507. var res2 FJ3507Result
  1508. var struct3507 models.Struct3507
  1509. struct3507.FixmedinsBchno = item.Bchno
  1510. struct3507.InvDataType = "4"
  1511. struct3507.Opter = roles.UserName
  1512. struct3507.OrgName = miConfig.OrgName
  1513. struct3507.AccessKey = miConfig.AccessKey
  1514. struct3507.RequestUrl = miConfig.Url
  1515. struct3507.FixmedinsCode = miConfig.Code
  1516. struct3507.Code = miConfig.Code
  1517. struct3507.SecretKey = miConfig.SecretKey
  1518. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1519. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1520. struct3507.Url = miConfig.Url
  1521. struct3507.AppId = miConfig.Cainfo
  1522. struct3507.AppSecret = miConfig.AppSecret
  1523. struct3507.Enckey = miConfig.EncKey
  1524. struct3507.SignKey = miConfig.SignKey
  1525. struct3507.SecretKey = miConfig.SecretKey
  1526. //result, result1, _ := service.FJyb3507(struct3507)
  1527. //saveLog(result, result1, "3507", "3507")
  1528. //
  1529. //var respJSON2 map[string]interface{}
  1530. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. // return
  1534. //}
  1535. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1536. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1537. // utils.ErrorLog("解析失败:%v", err)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. //}
  1541. if miConfig.MdtrtareaAdmvs == "350500" {
  1542. result, result1, _ := service.FJyb3507(struct3507)
  1543. saveLog(result, result1, "3507", "3507")
  1544. var respJSON2 map[string]interface{}
  1545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. return
  1549. }
  1550. userJSONBytes2, _ := json.Marshal(respJSON2)
  1551. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. } else {
  1557. data := make(map[string]interface{})
  1558. data["struct_3507s"] = struct3507
  1559. client := &http.Client{}
  1560. bytesData, _ := json.Marshal(data)
  1561. var req *http.Request
  1562. if miConfig.MdtrtareaAdmvs == "320921" {
  1563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1564. } else {
  1565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1566. }
  1567. resp, _ := client.Do(req)
  1568. defer resp.Body.Close()
  1569. body, ioErr := ioutil.ReadAll(resp.Body)
  1570. if ioErr != nil {
  1571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1572. }
  1573. var respJSON map[string]interface{}
  1574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1577. return
  1578. }
  1579. var resSix10265 ResultSix10265 //1101结果
  1580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1581. result, _ := json.Marshal(respJSON)
  1582. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1583. utils.ErrorLog("解析失败:%v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. return
  1586. }
  1587. res.InfRefmsgid = resSix10265.InfRefmsgid
  1588. //res.Output = resSix10265.Output
  1589. res.ErrMsg = resSix10265.ErrMsg
  1590. res.Cainfo = resSix10265.Cainfo
  1591. res.WarnMsg = resSix10265.WarnMsg
  1592. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. }
  1595. if res.Infcode == 0 {
  1596. item.IsSale = 0
  1597. item.SaleDate = ""
  1598. item.Bchno = ""
  1599. err2 := service.SaveDF(item)
  1600. if err2 == nil {
  1601. var struct3507_2 models.Struct3507
  1602. struct3507_2.OrgName = miConfig.OrgName
  1603. struct3507_2.AccessKey = miConfig.AccessKey
  1604. struct3507_2.RequestUrl = miConfig.Url
  1605. struct3507_2.Opter = roles.UserName
  1606. struct3507_2.FixmedinsCode = miConfig.Code
  1607. struct3507_2.Code = miConfig.Code
  1608. struct3507_2.SecretKey = miConfig.SecretKey
  1609. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1610. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1611. struct3507_2.Url = miConfig.Url
  1612. struct3507_2.AppId = miConfig.Cainfo
  1613. struct3507_2.AppSecret = miConfig.AppSecret
  1614. struct3507_2.Enckey = miConfig.EncKey
  1615. struct3507_2.SignKey = miConfig.SignKey
  1616. struct3507_2.SecretKey = miConfig.SecretKey
  1617. struct3507_2.FixmedinsBchno = item.BgBchno
  1618. struct3507_2.InvDataType = "2"
  1619. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1620. //saveLog(result11, result22, "3507", "3507")
  1621. //var respJSON3 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1628. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result11, result22, _ := service.FJyb3507(struct3507_2)
  1635. saveLog(result11, result22, "3507", "3507")
  1636. var respJSON3 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes3, _ := json.Marshal(respJSON3)
  1643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507_2
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res2.ErrMsg = resSix10265.ErrMsg
  1682. res2.Cainfo = resSix10265.Cainfo
  1683. res2.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res2.Infcode = infocode
  1686. }
  1687. if res2.Infcode == 0 {
  1688. item.IsChange = 0
  1689. item.BgBchno = ""
  1690. service.SaveDF2(item)
  1691. } else {
  1692. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1693. }
  1694. }
  1695. } else {
  1696. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1697. }
  1698. }
  1699. if item.IsSale == 1 && item.IsChange == 0 {
  1700. var res FJ3507Result
  1701. var struct3507 models.Struct3507
  1702. struct3507.FixmedinsBchno = item.Bchno
  1703. struct3507.InvDataType = "4"
  1704. struct3507.Opter = roles.UserName
  1705. struct3507.FixmedinsCode = miConfig.Code
  1706. struct3507.Code = miConfig.Code
  1707. struct3507.OrgName = miConfig.OrgName
  1708. struct3507.AccessKey = miConfig.AccessKey
  1709. struct3507.RequestUrl = miConfig.Url
  1710. struct3507.SecretKey = miConfig.SecretKey
  1711. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1712. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1713. struct3507.Url = miConfig.Url
  1714. struct3507.AppId = miConfig.Cainfo
  1715. struct3507.AppSecret = miConfig.AppSecret
  1716. struct3507.Enckey = miConfig.EncKey
  1717. struct3507.SignKey = miConfig.SignKey
  1718. struct3507.SecretKey = miConfig.SecretKey
  1719. //result, result1, _ := service.FJyb3507(struct3507)
  1720. //saveLog(result, result1, "3507", "3507")
  1721. //
  1722. //var respJSON3 map[string]interface{}
  1723. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1724. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. // return
  1727. //}
  1728. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1729. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1730. // utils.ErrorLog("解析失败:%v", err)
  1731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. // return
  1733. //}
  1734. if miConfig.MdtrtareaAdmvs == "350500" {
  1735. result, result1, _ := service.FJyb3507(struct3507)
  1736. saveLog(result, result1, "3507", "3507")
  1737. var respJSON2 map[string]interface{}
  1738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. return
  1742. }
  1743. userJSONBytes2, _ := json.Marshal(respJSON2)
  1744. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. } else {
  1750. data := make(map[string]interface{})
  1751. data["struct_3507s"] = struct3507
  1752. client := &http.Client{}
  1753. bytesData, _ := json.Marshal(data)
  1754. var req *http.Request
  1755. if miConfig.MdtrtareaAdmvs == "320921" {
  1756. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1757. } else {
  1758. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1759. }
  1760. resp, _ := client.Do(req)
  1761. defer resp.Body.Close()
  1762. body, ioErr := ioutil.ReadAll(resp.Body)
  1763. if ioErr != nil {
  1764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1765. }
  1766. var respJSON map[string]interface{}
  1767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. var resSix10265 ResultSix10265 //1101结果
  1773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1774. result, _ := json.Marshal(respJSON)
  1775. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. res.InfRefmsgid = resSix10265.InfRefmsgid
  1781. //res.Output = resSix10265.Output
  1782. res.ErrMsg = resSix10265.ErrMsg
  1783. res.Cainfo = resSix10265.Cainfo
  1784. res.WarnMsg = resSix10265.WarnMsg
  1785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1786. res.Infcode = infocode
  1787. }
  1788. if res.Infcode == 0 {
  1789. item.IsSale = 0
  1790. item.SaleDate = ""
  1791. service.SaveDF(item)
  1792. } else {
  1793. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1794. }
  1795. }
  1796. if item.IsSale == 2 && item.IsChange == 0 {
  1797. var res FJ3507Result
  1798. var struct3507 models.Struct3507
  1799. struct3507.FixmedinsBchno = item.Bchno
  1800. struct3507.InvDataType = "4"
  1801. struct3507.Opter = roles.UserName
  1802. struct3507.FixmedinsCode = miConfig.Code
  1803. struct3507.Code = miConfig.Code
  1804. struct3507.OrgName = miConfig.OrgName
  1805. struct3507.AccessKey = miConfig.AccessKey
  1806. struct3507.RequestUrl = miConfig.Url
  1807. struct3507.SecretKey = miConfig.SecretKey
  1808. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1809. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1810. struct3507.Url = miConfig.Url
  1811. struct3507.AppId = miConfig.Cainfo
  1812. struct3507.AppSecret = miConfig.AppSecret
  1813. struct3507.Enckey = miConfig.EncKey
  1814. struct3507.SignKey = miConfig.SignKey
  1815. struct3507.SecretKey = miConfig.SecretKey
  1816. //result, result1, _ := service.FJyb3507(struct3507)
  1817. //saveLog(result, result1, "3507", "3507")
  1818. //
  1819. //var respJSON3 map[string]interface{}
  1820. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1821. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. //}
  1825. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1826. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1827. // utils.ErrorLog("解析失败:%v", err)
  1828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. // return
  1830. //}
  1831. if miConfig.MdtrtareaAdmvs == "350500" {
  1832. result, result1, _ := service.FJyb3507(struct3507)
  1833. saveLog(result, result1, "3507", "3507")
  1834. var respJSON2 map[string]interface{}
  1835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. userJSONBytes2, _ := json.Marshal(respJSON2)
  1841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1842. utils.ErrorLog("解析失败:%v", err)
  1843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1844. return
  1845. }
  1846. } else {
  1847. data := make(map[string]interface{})
  1848. data["struct_3507s"] = struct3507
  1849. client := &http.Client{}
  1850. bytesData, _ := json.Marshal(data)
  1851. var req *http.Request
  1852. if miConfig.MdtrtareaAdmvs == "320921" {
  1853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1854. } else {
  1855. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1856. }
  1857. resp, _ := client.Do(req)
  1858. defer resp.Body.Close()
  1859. body, ioErr := ioutil.ReadAll(resp.Body)
  1860. if ioErr != nil {
  1861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1862. }
  1863. var respJSON map[string]interface{}
  1864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. var resSix10265 ResultSix10265 //1101结果
  1870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1871. result, _ := json.Marshal(respJSON)
  1872. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1873. utils.ErrorLog("解析失败:%v", err)
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1875. return
  1876. }
  1877. res.InfRefmsgid = resSix10265.InfRefmsgid
  1878. //res.Output = resSix10265.Output
  1879. res.ErrMsg = resSix10265.ErrMsg
  1880. res.Cainfo = resSix10265.Cainfo
  1881. res.WarnMsg = resSix10265.WarnMsg
  1882. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1883. res.Infcode = infocode
  1884. }
  1885. if res.Infcode == 0 {
  1886. item.IsSale = 0
  1887. item.SaleDate = ""
  1888. item.Bchno = ""
  1889. service.SaveDF(item)
  1890. } else {
  1891. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1892. }
  1893. }
  1894. if item.IsSale == 0 && item.IsChange == 1 {
  1895. var res FJ3507Result
  1896. var struct3507 models.Struct3507
  1897. struct3507.FixmedinsBchno = item.BgBchno
  1898. struct3507.InvDataType = "2"
  1899. struct3507.Opter = roles.UserName
  1900. struct3507.FixmedinsCode = miConfig.Code
  1901. struct3507.Code = miConfig.Code
  1902. struct3507.OrgName = miConfig.OrgName
  1903. struct3507.AccessKey = miConfig.AccessKey
  1904. struct3507.RequestUrl = miConfig.Url
  1905. struct3507.SecretKey = miConfig.SecretKey
  1906. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1907. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1908. struct3507.Url = miConfig.Url
  1909. struct3507.AppId = miConfig.Cainfo
  1910. struct3507.AppSecret = miConfig.AppSecret
  1911. struct3507.Enckey = miConfig.EncKey
  1912. struct3507.SignKey = miConfig.SignKey
  1913. struct3507.SecretKey = miConfig.SecretKey
  1914. //result, result1, _ := service.FJyb3507(struct3507)
  1915. //saveLog(result, result1, "3507", "3507")
  1916. //
  1917. //var respJSON3 map[string]interface{}
  1918. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1919. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1924. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1925. // utils.ErrorLog("解析失败:%v", err)
  1926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. // return
  1928. //}
  1929. if miConfig.MdtrtareaAdmvs == "350500" {
  1930. result, result1, _ := service.FJyb3507(struct3507)
  1931. saveLog(result, result1, "3507", "3507")
  1932. var respJSON2 map[string]interface{}
  1933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. userJSONBytes2, _ := json.Marshal(respJSON2)
  1939. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1940. utils.ErrorLog("解析失败:%v", err)
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1942. return
  1943. }
  1944. } else {
  1945. data := make(map[string]interface{})
  1946. data["struct_3507s"] = struct3507
  1947. client := &http.Client{}
  1948. bytesData, _ := json.Marshal(data)
  1949. var req *http.Request
  1950. if miConfig.MdtrtareaAdmvs == "320921" {
  1951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1952. } else {
  1953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1954. }
  1955. resp, _ := client.Do(req)
  1956. defer resp.Body.Close()
  1957. body, ioErr := ioutil.ReadAll(resp.Body)
  1958. if ioErr != nil {
  1959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1960. }
  1961. var respJSON map[string]interface{}
  1962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. var resSix10265 ResultSix10265 //1101结果
  1968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1969. result, _ := json.Marshal(respJSON)
  1970. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1971. utils.ErrorLog("解析失败:%v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. res.InfRefmsgid = resSix10265.InfRefmsgid
  1976. //res.Output = resSix10265.Output
  1977. res.ErrMsg = resSix10265.ErrMsg
  1978. res.Cainfo = resSix10265.Cainfo
  1979. res.WarnMsg = resSix10265.WarnMsg
  1980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1981. res.Infcode = infocode
  1982. }
  1983. if res.Infcode == 0 {
  1984. item.IsChange = 0
  1985. item.BgBchno = ""
  1986. service.SaveDF2(item)
  1987. } else {
  1988. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1989. }
  1990. }
  1991. }
  1992. if len(err) == 0 {
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "msg": "删除销售变更成功",
  1995. })
  1996. } else {
  1997. c.ServeSuccessJSON(map[string]interface{}{
  1998. "failed_code": -10,
  1999. "msg": err,
  2000. })
  2001. }
  2002. }
  2003. //func (c *HisApiController) BatchFJ3501AND3502() {
  2004. // //ids := c.GetString("ids")
  2005. // start_time := c.GetString("start_time")
  2006. // end_time := c.GetString("end_time")
  2007. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2008. //
  2009. //
  2010. // timeLayout := "2006-01-02"
  2011. // loc, _ := time.LoadLocation("Local")
  2012. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2013. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2014. //
  2015. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2016. // //id_arr := strings.Split(ids, ",")
  2017. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2018. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2019. // //库盘
  2020. // var errs []string
  2021. // for _, drug := range drugs {
  2022. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2023. // var res2 ResultSix
  2024. // var res3 ResultSix
  2025. //
  2026. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2027. // var struct3501 models.Struct3501
  2028. // struct3501.Code = miConfig.Code
  2029. // struct3501.OrgName = miConfig.OrgName
  2030. // struct3501.AccessKey = miConfig.AccessKey
  2031. // struct3501.Opter = roles.UserName
  2032. // struct3501.RequestUrl = miConfig.Url
  2033. // struct3501.Url = miConfig.Url
  2034. // struct3501.AppId = miConfig.Cainfo
  2035. // struct3501.AppSecret = miConfig.AppSecret
  2036. // struct3501.Enckey = miConfig.EncKey
  2037. // struct3501.SignKey = miConfig.SignKey
  2038. // struct3501.SecretKey = miConfig.SecretKey
  2039. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2042. // struct3501.RxFlag = "1"
  2043. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2044. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2045. //
  2046. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2047. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2048. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2049. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2050. // struct3501.FixmedinsBchno = number
  2051. // struct3501.DrugTracCodg = drug.DrugCode
  2052. // memo := make(map[string]interface{})
  2053. // memo["pric"] = drug.Price
  2054. // bytesData, _ := json.Marshal(memo)
  2055. // struct3501.Memo = string(bytesData)
  2056. //
  2057. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2058. //
  2059. // result1, result2, _ := service.FJyb3501(struct3501)
  2060. // saveLog(result1, result2, "3501", "3501")
  2061. // //saveLog(result, requestLog, "2201", "挂号")
  2062. //
  2063. // var respJSON2 map[string]interface{}
  2064. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2067. // return
  2068. // }
  2069. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2070. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2071. // utils.ErrorLog("解析失败:%v", err)
  2072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. // return
  2074. // }
  2075. //
  2076. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2077. // data := make(map[string]interface{})
  2078. // data["struct_3501s"] = struct3501
  2079. // client := &http.Client{}
  2080. // bytesData, _ := json.Marshal(data)
  2081. // var req *http.Request
  2082. // if miConfig.MdtrtareaAdmvs == "320921" {
  2083. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2084. // } else {
  2085. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2086. // }
  2087. //
  2088. // resp, _ := client.Do(req)
  2089. // defer resp.Body.Close()
  2090. // body, ioErr := ioutil.ReadAll(resp.Body)
  2091. // if ioErr != nil {
  2092. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. // }
  2094. // var respJSON map[string]interface{}
  2095. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. // return
  2099. // }
  2100. // var resSix10265 ResultSix10265 //1101结果
  2101. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2102. // result, _ := json.Marshal(respJSON)
  2103. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2104. // utils.ErrorLog("解析失败:%v", err)
  2105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. // return
  2107. // }
  2108. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2109. // res2.Output = resSix10265.Output
  2110. // res2.ErrMsg = resSix10265.ErrMsg
  2111. // res2.Cainfo = resSix10265.Cainfo
  2112. // res2.WarnMsg = resSix10265.WarnMsg
  2113. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2114. // res2.Infcode = infocode
  2115. //
  2116. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2117. // data := make(map[string]interface{})
  2118. // data["struct_3501s"] = struct3501
  2119. // client := &http.Client{}
  2120. // bytesData, _ := json.Marshal(data)
  2121. // var req *http.Request
  2122. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2123. // resp, _ := client.Do(req)
  2124. // defer resp.Body.Close()
  2125. // body, ioErr := ioutil.ReadAll(resp.Body)
  2126. // if ioErr != nil {
  2127. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2128. // }
  2129. // var respJSON map[string]interface{}
  2130. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2131. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2133. // return
  2134. // }
  2135. // var resSix10265 ResultSix10265 //1101结果
  2136. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2137. // result, _ := json.Marshal(respJSON)
  2138. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2139. // utils.ErrorLog("解析失败:%v", err)
  2140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. // return
  2142. // }
  2143. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2144. // res2.Output = resSix10265.Output
  2145. // res2.ErrMsg = resSix10265.ErrMsg
  2146. // res2.Cainfo = resSix10265.Cainfo
  2147. // res2.WarnMsg = resSix10265.WarnMsg
  2148. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2149. // res2.Infcode = infocode
  2150. //
  2151. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2152. // data := make(map[string]interface{})
  2153. // data["struct_3501s"] = struct3501
  2154. // client := &http.Client{}
  2155. // bytesData, _ := json.Marshal(data)
  2156. // var req *http.Request
  2157. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2158. // resp, _ := client.Do(req)
  2159. // defer resp.Body.Close()
  2160. // body, ioErr := ioutil.ReadAll(resp.Body)
  2161. // if ioErr != nil {
  2162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2163. // }
  2164. // var respJSON map[string]interface{}
  2165. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2166. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. // return
  2169. // }
  2170. // var resSix10265 ResultSix10265 //1101结果
  2171. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. // result, _ := json.Marshal(respJSON)
  2173. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2174. // utils.ErrorLog("解析失败:%v", err)
  2175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. // return
  2177. // }
  2178. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2179. // res2.Output = resSix10265.Output
  2180. // res2.ErrMsg = resSix10265.ErrMsg
  2181. // res2.Cainfo = resSix10265.Cainfo
  2182. // res2.WarnMsg = resSix10265.WarnMsg
  2183. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2184. // res2.Infcode = infocode
  2185. //
  2186. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2187. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2188. // saveLog(result1, result2, "3501", "3501")
  2189. // //saveLog(result, requestLog, "2201", "挂号")
  2190. //
  2191. // var respJSON2 map[string]interface{}
  2192. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2195. // return
  2196. // }
  2197. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2198. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2199. // utils.ErrorLog("解析失败:%v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. // }
  2203. //
  2204. // }
  2205. //
  2206. // if res2.Infcode != -1 {
  2207. // drug.IsPc = 1
  2208. // drug.Bchno = number
  2209. // drug.PcDate = time.Now().Unix()
  2210. // err := service.SaveW(drug)
  2211. // if err == nil {
  2212. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2213. // var struct3502 models.Struct3502
  2214. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2217. // struct3502.FixmedinsCode = miConfig.Code
  2218. // struct3502.Code = miConfig.Code
  2219. //
  2220. // struct3502.RxFlag = "0"
  2221. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2222. // struct3502.OrgName = miConfig.OrgName
  2223. // struct3502.Opter = roles.UserName
  2224. // struct3502.AccessKey = miConfig.AccessKey
  2225. // struct3502.RequestUrl = miConfig.Url
  2226. // struct3502.SecretKey = miConfig.SecretKey
  2227. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2228. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2229. // struct3502.Url = miConfig.Url
  2230. // struct3502.AppId = miConfig.Cainfo
  2231. // struct3502.AppSecret = miConfig.AppSecret
  2232. // struct3502.Enckey = miConfig.EncKey
  2233. // struct3502.SignKey = miConfig.SignKey
  2234. // struct3502.SecretKey = miConfig.SecretKey
  2235. // struct3502.DrugTracCodg = drug.DrugCode
  2236. //
  2237. // struct3502.Memo = ""
  2238. // struct3502.InvChgType = "108"
  2239. // struct3502.FixmedinsBchno = bg_number
  2240. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2241. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2242. //
  2243. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2244. // result11, result22, _ := service.FJyb3502(struct3502)
  2245. // saveLog(result11, result22, "3502", "3502")
  2246. //
  2247. // var respJSON3 map[string]interface{}
  2248. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2249. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. // return
  2252. // }
  2253. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2254. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2255. // utils.ErrorLog("解析失败:%v", err)
  2256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2257. // return
  2258. // }
  2259. //
  2260. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2261. // data := make(map[string]interface{})
  2262. // data["struct_3502s"] = struct3502
  2263. // client := &http.Client{}
  2264. // bytesData, _ := json.Marshal(data)
  2265. // var req *http.Request
  2266. // if miConfig.MdtrtareaAdmvs == "320921" {
  2267. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2268. // } else {
  2269. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2270. // }
  2271. //
  2272. // resp, _ := client.Do(req)
  2273. // defer resp.Body.Close()
  2274. // body, ioErr := ioutil.ReadAll(resp.Body)
  2275. // if ioErr != nil {
  2276. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2277. // }
  2278. // var respJSON map[string]interface{}
  2279. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2282. // return
  2283. // }
  2284. // var resSix10265 ResultSix10265 //1101结果
  2285. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2286. // result, _ := json.Marshal(respJSON)
  2287. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2288. // utils.ErrorLog("解析失败:%v", err)
  2289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. // return
  2291. // }
  2292. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2293. // res3.Output = resSix10265.Output
  2294. // res3.ErrMsg = resSix10265.ErrMsg
  2295. // res3.Cainfo = resSix10265.Cainfo
  2296. // res3.WarnMsg = resSix10265.WarnMsg
  2297. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2298. // res3.Infcode = infocode
  2299. //
  2300. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2301. //
  2302. // data := make(map[string]interface{})
  2303. // data["struct_3502s"] = struct3502
  2304. // client := &http.Client{}
  2305. // bytesData, _ := json.Marshal(data)
  2306. // var req *http.Request
  2307. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2308. // resp, _ := client.Do(req)
  2309. // defer resp.Body.Close()
  2310. // body, ioErr := ioutil.ReadAll(resp.Body)
  2311. // if ioErr != nil {
  2312. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2313. // }
  2314. // var respJSON map[string]interface{}
  2315. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2316. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2318. // return
  2319. // }
  2320. // var resSix10265 ResultSix10265 //1101结果
  2321. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2322. // result, _ := json.Marshal(respJSON)
  2323. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2324. // utils.ErrorLog("解析失败:%v", err)
  2325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2326. // return
  2327. // }
  2328. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2329. // res3.Output = resSix10265.Output
  2330. // res3.ErrMsg = resSix10265.ErrMsg
  2331. // res3.Cainfo = resSix10265.Cainfo
  2332. // res3.WarnMsg = resSix10265.WarnMsg
  2333. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2334. // res3.Infcode = infocode
  2335. //
  2336. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2337. //
  2338. // data := make(map[string]interface{})
  2339. // data["struct_3501s"] = struct3501
  2340. // client := &http.Client{}
  2341. // bytesData, _ := json.Marshal(data)
  2342. // var req *http.Request
  2343. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2344. // resp, _ := client.Do(req)
  2345. // defer resp.Body.Close()
  2346. // body, ioErr := ioutil.ReadAll(resp.Body)
  2347. // if ioErr != nil {
  2348. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2349. // }
  2350. // var respJSON map[string]interface{}
  2351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. // return
  2355. // }
  2356. // var resSix10265 ResultSix10265 //1101结果
  2357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2358. // result, _ := json.Marshal(respJSON)
  2359. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2360. // utils.ErrorLog("解析失败:%v", err)
  2361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. // return
  2363. // }
  2364. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2365. // res2.Output = resSix10265.Output
  2366. // res2.ErrMsg = resSix10265.ErrMsg
  2367. // res2.Cainfo = resSix10265.Cainfo
  2368. // res2.WarnMsg = resSix10265.WarnMsg
  2369. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2370. // res2.Infcode = infocode
  2371. //
  2372. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2373. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2374. // saveLog(result11, result22, "3502", "3502")
  2375. //
  2376. // var respJSON3 map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2383. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2384. // utils.ErrorLog("解析失败:%v", err)
  2385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. // return
  2387. // }
  2388. // }
  2389. // if res3.Infcode == -1 {
  2390. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2391. // c.ServeSuccessJSON(map[string]interface{}{
  2392. // "failed_code": -10,
  2393. // "msg": res3.ErrMsg,
  2394. // })
  2395. // } else {
  2396. // drug.IsBg = 1
  2397. // drug.BgBchno = bg_number
  2398. // service.SaveW(drug)
  2399. // }
  2400. // }
  2401. // } else {
  2402. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2403. // }
  2404. // }
  2405. // //变更
  2406. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2407. // var res3 ResultSix
  2408. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2409. //
  2410. // var struct3502 models.Struct3502
  2411. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2414. // struct3502.FixmedinsCode = miConfig.Code
  2415. // struct3502.Code = miConfig.Code
  2416. //
  2417. // struct3502.Opter = roles.UserName
  2418. // struct3502.RxFlag = "0"
  2419. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2420. // struct3502.OrgName = miConfig.OrgName
  2421. // struct3502.AccessKey = miConfig.AccessKey
  2422. // struct3502.RequestUrl = miConfig.Url
  2423. // struct3502.SecretKey = miConfig.SecretKey
  2424. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2425. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2426. // struct3502.InvChgType = "108"
  2427. // struct3502.DrugTracCodg = drug.DrugCode
  2428. //
  2429. // struct3502.Url = miConfig.Url
  2430. // struct3502.AppId = miConfig.Cainfo
  2431. // struct3502.AppSecret = miConfig.AppSecret
  2432. // struct3502.Enckey = miConfig.EncKey
  2433. // struct3502.SignKey = miConfig.SignKey
  2434. // struct3502.SecretKey = miConfig.SecretKey
  2435. //
  2436. // struct3502.FixmedinsBchno = bg_number
  2437. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2438. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2439. //
  2440. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2441. // result1, result2, _ := service.FJyb3502(struct3502)
  2442. // saveLog(result1, result2, "3502", "3502")
  2443. // var respJSON3 map[string]interface{}
  2444. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2445. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. // return
  2448. // }
  2449. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2450. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2451. // utils.ErrorLog("解析失败:%v", err)
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. // }
  2455. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2456. // data := make(map[string]interface{})
  2457. // data["struct_3502s"] = struct3502
  2458. // client := &http.Client{}
  2459. // bytesData, _ := json.Marshal(data)
  2460. // var req *http.Request
  2461. // if miConfig.MdtrtareaAdmvs == "320921" {
  2462. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2463. // } else {
  2464. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2465. // }
  2466. // resp, _ := client.Do(req)
  2467. // defer resp.Body.Close()
  2468. // body, ioErr := ioutil.ReadAll(resp.Body)
  2469. // if ioErr != nil {
  2470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2471. // }
  2472. // var respJSON map[string]interface{}
  2473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // var resSix10265 ResultSix10265 //1101结果
  2479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2480. // result, _ := json.Marshal(respJSON)
  2481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2487. // res3.Output = resSix10265.Output
  2488. // res3.ErrMsg = resSix10265.ErrMsg
  2489. // res3.Cainfo = resSix10265.Cainfo
  2490. // res3.WarnMsg = resSix10265.WarnMsg
  2491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2492. // res3.Infcode = infocode
  2493. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2494. //
  2495. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2496. //
  2497. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2498. //
  2499. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2500. //
  2501. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2502. // saveLog(result1, result2, "3501", "3501")
  2503. // //saveLog(result, requestLog, "2201", "挂号")
  2504. //
  2505. // var respJSON2 map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. // }
  2511. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2512. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2513. // utils.ErrorLog("解析失败:%v", err)
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2515. // return
  2516. // }
  2517. //
  2518. // }
  2519. // if res3.Infcode == -1 {
  2520. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2521. // } else {
  2522. // drug.IsBg = 1
  2523. // drug.BgBchno = bg_number
  2524. // service.SaveW(drug)
  2525. // }
  2526. // }
  2527. // }
  2528. //
  2529. // if len(errs) == 0 {
  2530. // c.ServeSuccessJSON(map[string]interface{}{
  2531. // "msg": "盘存变更成功",
  2532. // })
  2533. // } else {
  2534. // c.ServeSuccessJSON(map[string]interface{}{
  2535. // "failed_code": -10,
  2536. // "msg": errs,
  2537. // })
  2538. // }
  2539. //}
  2540. func (c *HisApiController) DeleteXSandBGTwo() {
  2541. patient_id, _ := c.GetInt64("patient_id")
  2542. admin_user_id, _ := c.GetInt64("admin_user_id")
  2543. times := c.GetString("time", "")
  2544. timeLayout := "2006-01-02"
  2545. loc, _ := time.LoadLocation("Local")
  2546. var stime, etime int64
  2547. if times == "" {
  2548. stime, etime = GetNowTime()
  2549. } else {
  2550. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2551. stime = stmp.Unix()
  2552. etime = stime + 86399
  2553. }
  2554. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2555. var flows []*models.DrugFlow
  2556. for _, item := range advicelist {
  2557. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2558. flows = append(flows, flow...)
  2559. }
  2560. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2563. var err []string
  2564. for _, item := range flows {
  2565. if item.IsSale == 1 {
  2566. var res FJ3507Result
  2567. var struct3507 models.Struct3507
  2568. struct3507.FixmedinsBchno = item.Bchno
  2569. struct3507.InvDataType = "4"
  2570. struct3507.Opter = roles.UserName
  2571. struct3507.OrgName = miConfig.OrgName
  2572. struct3507.AccessKey = miConfig.AccessKey
  2573. struct3507.RequestUrl = miConfig.Url
  2574. struct3507.FixmedinsCode = miConfig.Code
  2575. struct3507.SecretKey = miConfig.SecretKey
  2576. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2577. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2578. struct3507.Url = miConfig.Url
  2579. struct3507.AppId = miConfig.Cainfo
  2580. struct3507.AppSecret = miConfig.AppSecret
  2581. struct3507.Enckey = miConfig.EncKey
  2582. struct3507.SignKey = miConfig.SignKey
  2583. struct3507.SecretKey = miConfig.SecretKey
  2584. if miConfig.MdtrtareaAdmvs == "350500" {
  2585. result, result1, _ := service.FJyb3507(struct3507)
  2586. saveLog(result, result1, "3507", "3507")
  2587. var respJSON2 map[string]interface{}
  2588. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2591. return
  2592. }
  2593. userJSONBytes2, _ := json.Marshal(respJSON2)
  2594. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2595. utils.ErrorLog("解析失败:%v", err)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2600. data := make(map[string]interface{})
  2601. data["struct_3507s"] = struct3507
  2602. client := &http.Client{}
  2603. bytesData, _ := json.Marshal(data)
  2604. var req *http.Request
  2605. if miConfig.MdtrtareaAdmvs == "320921" {
  2606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2607. } else {
  2608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2609. }
  2610. resp, _ := client.Do(req)
  2611. defer resp.Body.Close()
  2612. body, ioErr := ioutil.ReadAll(resp.Body)
  2613. if ioErr != nil {
  2614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2615. }
  2616. var respJSON map[string]interface{}
  2617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2620. return
  2621. }
  2622. var resSix10265 ResultSix10265 //1101结果
  2623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2624. result, _ := json.Marshal(respJSON)
  2625. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2626. utils.ErrorLog("解析失败:%v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. res.InfRefmsgid = resSix10265.InfRefmsgid
  2631. //res.Output = resSix10265.Output
  2632. res.ErrMsg = resSix10265.ErrMsg
  2633. res.Cainfo = resSix10265.Cainfo
  2634. res.WarnMsg = resSix10265.WarnMsg
  2635. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2636. res.Infcode = infocode
  2637. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2638. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2639. saveLog(result2, result1, "3507", "3507")
  2640. var respJSON2 map[string]interface{}
  2641. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. return
  2645. }
  2646. userJSONBytes2, _ := json.Marshal(respJSON2)
  2647. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2648. utils.ErrorLog("解析失败:%v", err)
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2650. return
  2651. }
  2652. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2653. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2654. saveLog(result2, result1, "3507", "3507")
  2655. var respJSON2 map[string]interface{}
  2656. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. userJSONBytes2, _ := json.Marshal(respJSON2)
  2662. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2668. result1, result2 := service.Jxyb3507(struct3507)
  2669. saveLog(result2, result1, "3507", "3507")
  2670. var respJSON2 map[string]interface{}
  2671. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2674. return
  2675. }
  2676. userJSONBytes2, _ := json.Marshal(respJSON2)
  2677. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2678. utils.ErrorLog("解析失败:%v", err)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. return
  2681. }
  2682. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2683. result1, result2 := service.AHyb3507(struct3507)
  2684. saveLog(result2, result1, "3507", "3507")
  2685. var respJSON2 map[string]interface{}
  2686. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2689. return
  2690. }
  2691. userJSONBytes2, _ := json.Marshal(respJSON2)
  2692. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2693. utils.ErrorLog("解析失败:%v", err)
  2694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2695. return
  2696. }
  2697. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2698. data := make(map[string]interface{})
  2699. data["struct_3507s"] = struct3507
  2700. client := &http.Client{}
  2701. bytesData, _ := json.Marshal(data)
  2702. var req *http.Request
  2703. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2704. resp, _ := client.Do(req)
  2705. defer resp.Body.Close()
  2706. body, ioErr := ioutil.ReadAll(resp.Body)
  2707. if ioErr != nil {
  2708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2709. }
  2710. var respJSON map[string]interface{}
  2711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2713. }
  2714. var resSix10265 ResultSix10265 //1101结果
  2715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2716. result, _ := json.Marshal(respJSON)
  2717. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2718. utils.ErrorLog("解析失败:%v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. res.InfRefmsgid = resSix10265.InfRefmsgid
  2723. res.ErrMsg = resSix10265.ErrMsg
  2724. res.Cainfo = resSix10265.Cainfo
  2725. res.WarnMsg = resSix10265.WarnMsg
  2726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2727. res.Infcode = infocode
  2728. }
  2729. if res.Infcode == 0 {
  2730. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2731. item.IsSale = 0
  2732. item.SaleDate = ""
  2733. item.Bchno = ""
  2734. service.SaveDF(item)
  2735. } else {
  2736. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2737. }
  2738. }
  2739. }
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "删除销售数据成功",
  2742. })
  2743. }
  2744. // 获取当天起止时间戳
  2745. func GetNowTime() (int64, int64) {
  2746. t := time.Now()
  2747. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2748. timesamp := addTime.Unix()
  2749. return timesamp, timesamp + 86399
  2750. }
  2751. func (c *HisApiController) ChangeDrugfour() {
  2752. patient_id, _ := c.GetInt64("patient_id")
  2753. admin_user_id, _ := c.GetInt64("admin_user_id")
  2754. times := c.GetString("time", "")
  2755. timeLayout := "2006-01-02"
  2756. loc, _ := time.LoadLocation("Local")
  2757. var stime, etime int64
  2758. if times == "" {
  2759. stime, etime = GetNowTime()
  2760. } else {
  2761. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2762. stime = stmp.Unix()
  2763. etime = stime + 86399
  2764. }
  2765. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2766. var flows []*models.DrugFlow
  2767. for _, item := range advicelist {
  2768. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2769. flows = append(flows, flow...)
  2770. }
  2771. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2772. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2773. var err []string
  2774. for _, item := range flows {
  2775. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2776. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2777. if prescription.OrderStatus == 2 {
  2778. if item.IsSale == 0 {
  2779. var res FJ3507Result
  2780. var res3507for10188 FJ3507ResultFor10188
  2781. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2782. //进行商品销售接口
  2783. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2784. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2785. var respJSON3 map[string]interface{}
  2786. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2789. return
  2790. }
  2791. userJSONBytes3, _ := json.Marshal(respJSON3)
  2792. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2793. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2794. utils.ErrorLog("解析失败:%v", err)
  2795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2796. return
  2797. }
  2798. //if res3507for10188.Infcode
  2799. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2800. //res.Output = resSix10265.Output
  2801. res.ErrMsg = res3507for10188.ErrMsg
  2802. res.Cainfo = res3507for10188.Cainfo
  2803. res.WarnMsg = res3507for10188.WarnMsg
  2804. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2805. res.Infcode = infocode
  2806. } else {
  2807. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2808. utils.ErrorLog("解析失败:%v", err)
  2809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2810. return
  2811. }
  2812. }
  2813. if res.Infcode == 0 {
  2814. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  2815. item.IsSale = 1
  2816. item.Bchno = number
  2817. item.SaleDate = time.Now().Format("2006-01-02")
  2818. service.SaveDF(item)
  2819. } else {
  2820. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2821. }
  2822. }
  2823. } else { //还没结,提示用户去结算,并药品追溯上传
  2824. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2825. }
  2826. }
  2827. }
  2828. str := strings.Join(err, " ")
  2829. saveLog(str, str, "3505", "3505自动上传日志")
  2830. c.ServeSuccessJSON(map[string]interface{}{
  2831. "status": "1",
  2832. "msg": err,
  2833. })
  2834. }
  2835. func (c *HisApiController) ChangeDrugFive() {
  2836. id, _ := c.GetInt64("id")
  2837. admin_user_id, _ := c.GetInt64("admin_user_id")
  2838. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2839. var flows []*models.DrugFlow
  2840. for _, item := range advicelist {
  2841. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2842. flows = append(flows, flow...)
  2843. }
  2844. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2845. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2846. var err []string
  2847. for _, item := range flows {
  2848. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2849. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2850. if prescription.OrderStatus == 2 {
  2851. if item.IsSale == 0 {
  2852. var res FJ3507Result
  2853. var res3507for10188 FJ3507ResultFor10188
  2854. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2855. //进行商品销售接口
  2856. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2857. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2858. var respJSON3 map[string]interface{}
  2859. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2862. return
  2863. }
  2864. userJSONBytes3, _ := json.Marshal(respJSON3)
  2865. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2866. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2867. utils.ErrorLog("解析失败:%v", err)
  2868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2869. return
  2870. }
  2871. //if res3507for10188.Infcode
  2872. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2873. //res.Output = resSix10265.Output
  2874. res.ErrMsg = res3507for10188.ErrMsg
  2875. res.Cainfo = res3507for10188.Cainfo
  2876. res.WarnMsg = res3507for10188.WarnMsg
  2877. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2878. res.Infcode = infocode
  2879. } else {
  2880. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2881. utils.ErrorLog("解析失败:%v", err)
  2882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2883. return
  2884. }
  2885. }
  2886. if res.Infcode == 0 {
  2887. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  2888. item.IsSale = 1
  2889. item.Bchno = number
  2890. item.SaleDate = time.Now().Format("2006-01-02")
  2891. service.SaveDF(item)
  2892. } else {
  2893. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2894. }
  2895. }
  2896. } else { //还没结,提示用户去结算,并药品追溯上传
  2897. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2898. }
  2899. }
  2900. }
  2901. str := strings.Join(err, " ")
  2902. saveLog(str, str, "3505", "3505自动上传日志")
  2903. c.ServeSuccessJSON(map[string]interface{}{
  2904. "status": "1",
  2905. "msg": err,
  2906. })
  2907. }
  2908. //func (c *HisApiController) ChangeDrugfour() {
  2909. // patient_id, _ := c.GetInt64("patient_id")
  2910. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2911. // //id_arr := strings.Split(ids, ",")
  2912. // times := c.GetString("time", "")
  2913. // timeLayout := "2006-01-02"
  2914. // loc, _ := time.LoadLocation("Local")
  2915. // var stime, etime int64
  2916. // if times == "" {
  2917. // stime, etime = GetNowTime()
  2918. // } else {
  2919. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2920. // stime = stmp.Unix()
  2921. // etime = stime + 86399
  2922. // }
  2923. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2924. // var flows []*models.DrugFlow
  2925. // for _, item := range advicelist {
  2926. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  2927. // flows = append(flows, flow...)
  2928. // }
  2929. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2930. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2931. // var err []string
  2932. //
  2933. // for _, item := range flows {
  2934. // var res3 ResultSix
  2935. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2936. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2937. // if prescription.OrderStatus == 2 {
  2938. // //已经结算
  2939. // //判断是否已经销售
  2940. // if item.IsSale == 1 { //是否已经销售,1是 0否
  2941. // //是否已经变更 1是 0否
  2942. // if item.IsChange == 0 { //没变更,进行变更操作
  2943. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2944. //
  2945. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2946. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2947. // var respJSON3 map[string]interface{}
  2948. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2949. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2951. // return
  2952. // }
  2953. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2954. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2955. // utils.ErrorLog("解析失败:%v", err)
  2956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2957. // return
  2958. // }
  2959. // if res3.Infcode == 0 {
  2960. // item.IsChange = 1
  2961. // item.BgBchno = bg_number
  2962. // service.SaveDF2(item)
  2963. // } else {
  2964. //
  2965. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2966. // }
  2967. // }
  2968. // } else { //没销售,
  2969. // var res FJ3507Result
  2970. // var res3507for10188 FJ3507ResultFor10188
  2971. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2972. //
  2973. // //进行商品销售接口
  2974. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2975. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2976. // var respJSON3 map[string]interface{}
  2977. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2978. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2980. // return
  2981. // }
  2982. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2983. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2984. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2985. // utils.ErrorLog("解析失败:%v", err)
  2986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2987. // return
  2988. // }
  2989. // //if res3507for10188.Infcode
  2990. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  2991. // //res.Output = resSix10265.Output
  2992. // res.ErrMsg = res3507for10188.ErrMsg
  2993. // res.Cainfo = res3507for10188.Cainfo
  2994. // res.WarnMsg = res3507for10188.WarnMsg
  2995. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2996. // res.Infcode = infocode
  2997. // } else {
  2998. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2999. // utils.ErrorLog("解析失败:%v", err)
  3000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3001. // return
  3002. // }
  3003. //
  3004. // }
  3005. // if res.Infcode == 0 {
  3006. // item.IsSale = 1
  3007. // item.Bchno = number
  3008. // item.SaleDate = time.Now().Format("2006-01-02")
  3009. //
  3010. // err5 := service.SaveDF(item)
  3011. // if err5 == nil {
  3012. // if item.IsChange == 0 { //没变更,进行变更操作
  3013. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3014. //
  3015. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3016. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3017. //
  3018. // var respJSON3 map[string]interface{}
  3019. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3020. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3022. // return
  3023. // }
  3024. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3025. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3026. // utils.ErrorLog("解析失败:%v", err)
  3027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3028. // return
  3029. // }
  3030. // //if res3507for10188.Infcode
  3031. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3032. // //res.Output = resSix10265.Output
  3033. // res3.ErrMsg = res3507for10188.ErrMsg
  3034. // res3.Cainfo = res3507for10188.Cainfo
  3035. // res3.WarnMsg = res3507for10188.WarnMsg
  3036. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3037. // res3.Infcode = infocode
  3038. // } else {
  3039. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3040. // utils.ErrorLog("解析失败:%v", err)
  3041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3042. // return
  3043. // }
  3044. // }
  3045. // if res3.Infcode == 0 {
  3046. // item.IsChange = 1
  3047. // item.BgBchno = bg_number
  3048. // service.SaveDF2(item)
  3049. // } else {
  3050. //
  3051. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3052. // }
  3053. // }
  3054. // }
  3055. // } else {
  3056. //
  3057. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3058. // }
  3059. // }
  3060. //
  3061. // } else { //还没结,提示用户去结算,并药品追溯上传
  3062. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3063. // }
  3064. // }
  3065. // }
  3066. // if len(err) == 0 {
  3067. // c.ServeSuccessJSON(map[string]interface{}{
  3068. // "msg": "销售变更成功",
  3069. // })
  3070. // } else {
  3071. // c.ServeSuccessJSON(map[string]interface{}{
  3072. // "failed_code": -10,
  3073. // "msg": err,
  3074. // })
  3075. // }
  3076. //}
  3077. func (c *HisApiController) ChangeDrug() {
  3078. ids := c.GetString("ids")
  3079. id_arr := strings.Split(ids, ",")
  3080. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3081. admin_user_id, _ := c.GetInt64("admin_user_id")
  3082. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3083. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3084. var err []string
  3085. for _, item := range flows {
  3086. var res3 ResultSix
  3087. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3088. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3089. if prescription.OrderStatus == 2 {
  3090. //已经结算
  3091. //判断是否已经销售
  3092. if item.IsSale == 1 { //是否已经销售,1是 0否
  3093. //是否已经变更 1是 0否
  3094. if item.IsChange == 0 { //没变更,进行变更操作
  3095. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3096. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3097. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3098. var respJSON3 map[string]interface{}
  3099. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3102. return
  3103. }
  3104. userJSONBytes3, _ := json.Marshal(respJSON3)
  3105. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3106. utils.ErrorLog("解析失败:%v", err)
  3107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3108. return
  3109. }
  3110. if res3.Infcode == 0 {
  3111. item.IsChange = 1
  3112. item.BgBchno = bg_number
  3113. service.SaveDF2(item)
  3114. } else {
  3115. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3116. }
  3117. }
  3118. } else { //没销售,
  3119. var res FJ3507Result
  3120. var res3507for10188 FJ3507ResultFor10188
  3121. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3122. //进行商品销售接口
  3123. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3124. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3125. var respJSON3 map[string]interface{}
  3126. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3129. return
  3130. }
  3131. userJSONBytes3, _ := json.Marshal(respJSON3)
  3132. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3133. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3134. utils.ErrorLog("解析失败:%v", err)
  3135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3136. return
  3137. }
  3138. //if res3507for10188.Infcode
  3139. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3140. //res.Output = resSix10265.Output
  3141. res.ErrMsg = res3507for10188.ErrMsg
  3142. res.Cainfo = res3507for10188.Cainfo
  3143. res.WarnMsg = res3507for10188.WarnMsg
  3144. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3145. res.Infcode = infocode
  3146. } else {
  3147. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3148. utils.ErrorLog("解析失败:%v", err)
  3149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3150. return
  3151. }
  3152. }
  3153. if res.Infcode == 0 {
  3154. item.IsSale = 1
  3155. item.Bchno = number
  3156. item.SaleDate = time.Now().Format("2006-01-02")
  3157. err5 := service.SaveDF(item)
  3158. if err5 == nil {
  3159. if item.IsChange == 0 { //没变更,进行变更操作
  3160. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3161. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3162. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3163. var respJSON3 map[string]interface{}
  3164. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3167. return
  3168. }
  3169. userJSONBytes3, _ := json.Marshal(respJSON3)
  3170. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3171. utils.ErrorLog("解析失败:%v", err)
  3172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. return
  3174. }
  3175. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3176. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3177. utils.ErrorLog("解析失败:%v", err)
  3178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3179. return
  3180. }
  3181. //if res3507for10188.Infcode
  3182. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3183. //res.Output = resSix10265.Output
  3184. res3.ErrMsg = res3507for10188.ErrMsg
  3185. res3.Cainfo = res3507for10188.Cainfo
  3186. res3.WarnMsg = res3507for10188.WarnMsg
  3187. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3188. res3.Infcode = infocode
  3189. } else {
  3190. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3191. utils.ErrorLog("解析失败:%v", err)
  3192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3193. return
  3194. }
  3195. }
  3196. if res3.Infcode == 0 {
  3197. item.IsChange = 1
  3198. item.BgBchno = bg_number
  3199. service.SaveDF2(item)
  3200. } else {
  3201. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3202. }
  3203. }
  3204. }
  3205. } else {
  3206. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3207. }
  3208. }
  3209. } else { //还没结算
  3210. var res3507for10188 FJ3507ResultFor10188
  3211. if item.IsChange == 0 { //没变更,进行变更操作
  3212. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3213. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3214. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3215. var respJSON3 map[string]interface{}
  3216. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3219. return
  3220. }
  3221. userJSONBytes3, _ := json.Marshal(respJSON3)
  3222. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3223. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3224. utils.ErrorLog("解析失败:%v", err)
  3225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3226. return
  3227. }
  3228. //if res3507for10188.Infcode
  3229. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3230. //res.Output = resSix10265.Output
  3231. res3.ErrMsg = res3507for10188.ErrMsg
  3232. res3.Cainfo = res3507for10188.Cainfo
  3233. res3.WarnMsg = res3507for10188.WarnMsg
  3234. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3235. res3.Infcode = infocode
  3236. } else {
  3237. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3238. utils.ErrorLog("解析失败:%v", err)
  3239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3240. return
  3241. }
  3242. }
  3243. if res3.Infcode == 0 {
  3244. item.IsChange = 1
  3245. item.BgBchno = bg_number
  3246. service.SaveDF2(item)
  3247. } else {
  3248. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3249. }
  3250. }
  3251. }
  3252. } else if item.ConsumableType == 7 {
  3253. var res3507for10188 FJ3507ResultFor10188
  3254. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3255. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3256. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3257. //判断是否已经销售
  3258. if item.IsSale == 2 { //是否已经销售,1是 0否
  3259. //是否已经变更 1是 0否
  3260. if item.IsChange == 0 { //没变更,进行变更操作
  3261. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3262. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3263. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3264. var respJSON3 map[string]interface{}
  3265. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3268. return
  3269. }
  3270. userJSONBytes3, _ := json.Marshal(respJSON3)
  3271. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3272. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3273. utils.ErrorLog("解析失败:%v", err)
  3274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3275. return
  3276. }
  3277. //if res3507for10188.Infcode
  3278. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3279. //res.Output = resSix10265.Output
  3280. res3.ErrMsg = res3507for10188.ErrMsg
  3281. res3.Cainfo = res3507for10188.Cainfo
  3282. res3.WarnMsg = res3507for10188.WarnMsg
  3283. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3284. res3.Infcode = infocode
  3285. } else {
  3286. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3287. utils.ErrorLog("解析失败:%v", err)
  3288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3289. return
  3290. }
  3291. }
  3292. if res3.Infcode == 0 {
  3293. item.IsChange = 1
  3294. item.BgBchno = bg_number
  3295. service.SaveDF2(item)
  3296. } else {
  3297. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3298. }
  3299. }
  3300. } else { //没销售,
  3301. //进行商品销售退货接口
  3302. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3303. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3304. saveLog(result111, result222, "3506", "销售退货")
  3305. var res7 FJ3507Result
  3306. //进行商品销售接口
  3307. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3308. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3309. var respJSON3 map[string]interface{}
  3310. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3313. return
  3314. }
  3315. userJSONBytes3, _ := json.Marshal(respJSON3)
  3316. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3317. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3318. utils.ErrorLog("解析失败:%v", err)
  3319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3320. return
  3321. }
  3322. //if res3507for10188.Infcode
  3323. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3324. //res.Output = resSix10265.Output
  3325. res7.ErrMsg = res3507for10188.ErrMsg
  3326. res7.Cainfo = res3507for10188.Cainfo
  3327. res7.WarnMsg = res3507for10188.WarnMsg
  3328. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3329. res7.Infcode = infocode
  3330. } else {
  3331. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3332. utils.ErrorLog("解析失败:%v", err)
  3333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3334. return
  3335. }
  3336. }
  3337. if res7.Infcode == 0 {
  3338. item.IsSale = 2
  3339. item.SaleDate = item.SaleDate
  3340. item.Bchno = number
  3341. service.SaveDF(item)
  3342. if item.IsChange == 0 { //没变更,进行变更操作
  3343. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3344. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3345. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3346. var respJSON3 map[string]interface{}
  3347. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3350. return
  3351. }
  3352. userJSONBytes3, _ := json.Marshal(respJSON3)
  3353. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3354. // utils.ErrorLog("解析失败:%v", err)
  3355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3356. // return
  3357. //}
  3358. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3359. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3360. utils.ErrorLog("解析失败:%v", err)
  3361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3362. return
  3363. }
  3364. //if res3507for10188.Infcode
  3365. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3366. //res.Output = resSix10265.Output
  3367. res3.ErrMsg = res3507for10188.ErrMsg
  3368. res3.Cainfo = res3507for10188.Cainfo
  3369. res3.WarnMsg = res3507for10188.WarnMsg
  3370. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3371. res3.Infcode = infocode
  3372. } else {
  3373. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3374. utils.ErrorLog("解析失败:%v", err)
  3375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3376. return
  3377. }
  3378. }
  3379. if res3.Infcode == 0 {
  3380. item.IsChange = 1
  3381. item.BgBchno = bg_number
  3382. service.SaveDF2(item)
  3383. } else {
  3384. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3385. }
  3386. }
  3387. } else {
  3388. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3389. }
  3390. }
  3391. } else { //还没结算
  3392. if item.IsChange == 0 { //没变更,进行变更操作
  3393. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3394. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3395. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3396. var respJSON3 map[string]interface{}
  3397. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3400. return
  3401. }
  3402. userJSONBytes3, _ := json.Marshal(respJSON3)
  3403. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3404. // utils.ErrorLog("解析失败:%v", err)
  3405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3406. // return
  3407. //}
  3408. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3409. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3410. utils.ErrorLog("解析失败:%v", err)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. //if res3507for10188.Infcode
  3415. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3416. //res.Output = resSix10265.Output
  3417. res3.ErrMsg = res3507for10188.ErrMsg
  3418. res3.Cainfo = res3507for10188.Cainfo
  3419. res3.WarnMsg = res3507for10188.WarnMsg
  3420. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3421. res3.Infcode = infocode
  3422. } else {
  3423. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3424. utils.ErrorLog("解析失败:%v", err)
  3425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3426. return
  3427. }
  3428. }
  3429. if res3.Infcode == 0 {
  3430. item.IsChange = 1
  3431. item.BgBchno = bg_number
  3432. service.SaveDF2(item)
  3433. } else {
  3434. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3435. }
  3436. }
  3437. }
  3438. }
  3439. }
  3440. if len(err) == 0 {
  3441. c.ServeSuccessJSON(map[string]interface{}{
  3442. "msg": "销售变更成功",
  3443. })
  3444. } else {
  3445. c.ServeSuccessJSON(map[string]interface{}{
  3446. "failed_code": -10,
  3447. "msg": err,
  3448. })
  3449. }
  3450. }
  3451. func (c *HisApiController) ChangeDrugtwo() {
  3452. //ids := c.GetString("ids")
  3453. //id_arr := strings.Split(ids, ",")
  3454. flows, _ := service.GetNewDrugFlowInfothree123()
  3455. admin_user_id, _ := c.GetInt64("admin_user_id")
  3456. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3457. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3458. var err []string
  3459. for _, item := range flows {
  3460. var res3 ResultSix
  3461. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3462. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3463. if prescription.OrderStatus == 2 {
  3464. //已经结算
  3465. //判断是否已经销售
  3466. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3467. // //是否已经变更 1是 0否
  3468. // if item.IsChange == 0 { //没变更,进行变更操作
  3469. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3470. //
  3471. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3472. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3473. // var respJSON3 map[string]interface{}
  3474. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3477. // return
  3478. // }
  3479. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3480. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3481. // utils.ErrorLog("解析失败:%v", err)
  3482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. // return
  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. //}
  3494. //else
  3495. { //没销售,
  3496. var res FJ3507Result
  3497. var res3507for10188 FJ3507ResultFor10188
  3498. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3499. //进行商品销售接口
  3500. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3501. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3502. var respJSON3 map[string]interface{}
  3503. if err := json.Unmarshal([]byte(string(result3)), &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. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3517. //res.Output = resSix10265.Output
  3518. res.ErrMsg = res3507for10188.ErrMsg
  3519. res.Cainfo = res3507for10188.Cainfo
  3520. res.WarnMsg = res3507for10188.WarnMsg
  3521. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3522. res.Infcode = infocode
  3523. } else {
  3524. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3525. utils.ErrorLog("解析失败:%v", err)
  3526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3527. return
  3528. }
  3529. }
  3530. if res.Infcode == 0 {
  3531. item.IsSale = 1
  3532. item.Bchno = number
  3533. item.SaleDate = time.Now().Format("2006-01-02")
  3534. service.SaveDF(item)
  3535. //if err5 == nil {
  3536. // if item.IsChange == 0 { //没变更,进行变更操作
  3537. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3538. //
  3539. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3540. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3541. //
  3542. // var respJSON3 map[string]interface{}
  3543. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3544. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3546. // return
  3547. // }
  3548. //
  3549. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3550. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3551. // utils.ErrorLog("解析失败:%v", err)
  3552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3553. // return
  3554. // }
  3555. // //if res3507for10188.Infcode
  3556. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3557. // //res.Output = resSix10265.Output
  3558. // res3.ErrMsg = res3507for10188.ErrMsg
  3559. // res3.Cainfo = res3507for10188.Cainfo
  3560. // res3.WarnMsg = res3507for10188.WarnMsg
  3561. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3562. // res3.Infcode = infocode
  3563. // } else {
  3564. //
  3565. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3566. // utils.ErrorLog("解析失败:%v", err)
  3567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3568. // return
  3569. // }
  3570. //
  3571. // }
  3572. //
  3573. // if res3.Infcode == 0 {
  3574. // item.IsChange = 1
  3575. // item.BgBchno = bg_number
  3576. // service.SaveDF2(item)
  3577. // } else {
  3578. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3579. // }
  3580. // }
  3581. //}
  3582. } else {
  3583. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3584. }
  3585. }
  3586. } else { //还没结算
  3587. var res3507for10188 FJ3507ResultFor10188
  3588. if item.IsChange == 0 { //没变更,进行变更操作
  3589. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3590. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3591. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3592. var respJSON3 map[string]interface{}
  3593. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3596. return
  3597. }
  3598. userJSONBytes3, _ := json.Marshal(respJSON3)
  3599. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3600. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3601. utils.ErrorLog("解析失败:%v", err)
  3602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3603. return
  3604. }
  3605. //if res3507for10188.Infcode
  3606. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3607. //res.Output = resSix10265.Output
  3608. res3.ErrMsg = res3507for10188.ErrMsg
  3609. res3.Cainfo = res3507for10188.Cainfo
  3610. res3.WarnMsg = res3507for10188.WarnMsg
  3611. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3612. res3.Infcode = infocode
  3613. } else {
  3614. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3615. utils.ErrorLog("解析失败:%v", err)
  3616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3617. return
  3618. }
  3619. }
  3620. if res3.Infcode == 0 {
  3621. item.IsChange = 1
  3622. item.BgBchno = bg_number
  3623. service.SaveDF2(item)
  3624. } else {
  3625. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3626. }
  3627. }
  3628. }
  3629. }
  3630. //if item.ConsumableType == 7 {
  3631. // var res3507for10188 FJ3507ResultFor10188
  3632. //
  3633. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3634. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3635. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3636. // //判断是否已经销售
  3637. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3638. // //是否已经变更 1是 0否
  3639. // if item.IsChange == 0 { //没变更,进行变更操作
  3640. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3641. //
  3642. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3643. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3644. //
  3645. // var respJSON3 map[string]interface{}
  3646. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3647. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3649. // return
  3650. // }
  3651. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3652. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3653. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3654. // utils.ErrorLog("解析失败:%v", err)
  3655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3656. // return
  3657. // }
  3658. // //if res3507for10188.Infcode
  3659. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3660. // //res.Output = resSix10265.Output
  3661. // res3.ErrMsg = res3507for10188.ErrMsg
  3662. // res3.Cainfo = res3507for10188.Cainfo
  3663. // res3.WarnMsg = res3507for10188.WarnMsg
  3664. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3665. // res3.Infcode = infocode
  3666. // } else {
  3667. //
  3668. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3669. // utils.ErrorLog("解析失败:%v", err)
  3670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. // return
  3672. // }
  3673. //
  3674. // }
  3675. // if res3.Infcode == 0 {
  3676. // item.IsChange = 1
  3677. // item.BgBchno = bg_number
  3678. // service.SaveDF2(item)
  3679. // } else {
  3680. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3681. // }
  3682. // }
  3683. // } else { //没销售,
  3684. // //进行商品销售退货接口
  3685. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3686. //
  3687. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3688. // saveLog(result111, result222, "3506", "销售退货")
  3689. // var res7 FJ3507Result
  3690. //
  3691. // //进行商品销售接口
  3692. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3693. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3694. // var respJSON3 map[string]interface{}
  3695. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3696. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3698. // return
  3699. // }
  3700. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3701. //
  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. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3710. // //res.Output = resSix10265.Output
  3711. // res7.ErrMsg = res3507for10188.ErrMsg
  3712. // res7.Cainfo = res3507for10188.Cainfo
  3713. // res7.WarnMsg = res3507for10188.WarnMsg
  3714. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3715. // res7.Infcode = infocode
  3716. // } else {
  3717. //
  3718. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3719. // utils.ErrorLog("解析失败:%v", err)
  3720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3721. // return
  3722. // }
  3723. //
  3724. // }
  3725. // if res7.Infcode == 0 {
  3726. // item.IsSale = 2
  3727. // item.SaleDate = item.SaleDate
  3728. // item.Bchno = number
  3729. // service.SaveDF(item)
  3730. // if item.IsChange == 0 { //没变更,进行变更操作
  3731. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3732. //
  3733. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3734. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3735. //
  3736. // var respJSON3 map[string]interface{}
  3737. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3738. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. // return
  3741. // }
  3742. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3743. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3744. // // utils.ErrorLog("解析失败:%v", err)
  3745. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3746. // // return
  3747. // //}
  3748. //
  3749. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3750. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3751. // utils.ErrorLog("解析失败:%v", err)
  3752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3753. // return
  3754. // }
  3755. // //if res3507for10188.Infcode
  3756. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3757. // //res.Output = resSix10265.Output
  3758. // res3.ErrMsg = res3507for10188.ErrMsg
  3759. // res3.Cainfo = res3507for10188.Cainfo
  3760. // res3.WarnMsg = res3507for10188.WarnMsg
  3761. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3762. // res3.Infcode = infocode
  3763. // } else {
  3764. //
  3765. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3766. // utils.ErrorLog("解析失败:%v", err)
  3767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3768. // return
  3769. // }
  3770. //
  3771. // }
  3772. // if res3.Infcode == 0 {
  3773. // item.IsChange = 1
  3774. // item.BgBchno = bg_number
  3775. // service.SaveDF2(item)
  3776. // } else {
  3777. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3778. // }
  3779. // }
  3780. // } else {
  3781. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3782. // }
  3783. // }
  3784. // } else { //还没结算
  3785. // if item.IsChange == 0 { //没变更,进行变更操作
  3786. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3787. //
  3788. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3789. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3790. //
  3791. // var respJSON3 map[string]interface{}
  3792. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3793. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3795. // return
  3796. // }
  3797. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3798. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3799. // // utils.ErrorLog("解析失败:%v", err)
  3800. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3801. // // return
  3802. // //}
  3803. //
  3804. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3805. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3806. // utils.ErrorLog("解析失败:%v", err)
  3807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3808. // return
  3809. // }
  3810. // //if res3507for10188.Infcode
  3811. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3812. // //res.Output = resSix10265.Output
  3813. // res3.ErrMsg = res3507for10188.ErrMsg
  3814. // res3.Cainfo = res3507for10188.Cainfo
  3815. // res3.WarnMsg = res3507for10188.WarnMsg
  3816. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3817. // res3.Infcode = infocode
  3818. // } else {
  3819. //
  3820. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3821. // utils.ErrorLog("解析失败:%v", err)
  3822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3823. // return
  3824. // }
  3825. //
  3826. // }
  3827. // if res3.Infcode == 0 {
  3828. // item.IsChange = 1
  3829. // item.BgBchno = bg_number
  3830. // service.SaveDF2(item)
  3831. // } else {
  3832. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3833. // }
  3834. // }
  3835. // }
  3836. //}
  3837. }
  3838. if len(err) == 0 {
  3839. c.ServeSuccessJSON(map[string]interface{}{
  3840. "msg": "销售变更成功",
  3841. })
  3842. } else {
  3843. c.ServeSuccessJSON(map[string]interface{}{
  3844. "failed_code": -10,
  3845. "msg": err,
  3846. })
  3847. }
  3848. }
  3849. func (c *HisApiController) ChangeDrugthree() {
  3850. //ids := c.GetString("ids")
  3851. //id_arr := strings.Split(ids, ",")
  3852. flows, _ := service.GetNewDrugFlowInfothree()
  3853. admin_user_id, _ := c.GetInt64("admin_user_id")
  3854. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3855. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3856. var err []string
  3857. for _, item := range flows {
  3858. var res3 ResultSix
  3859. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3860. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3861. if prescription.OrderStatus == 2 {
  3862. //已经结算
  3863. //判断是否已经销售
  3864. if item.IsSale == 1 { //是否已经销售,1是 0否
  3865. //是否已经变更 1是 0否
  3866. if item.IsChange == 0 { //没变更,进行变更操作
  3867. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3868. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3869. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3870. var respJSON3 map[string]interface{}
  3871. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3874. return
  3875. }
  3876. userJSONBytes3, _ := json.Marshal(respJSON3)
  3877. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3878. utils.ErrorLog("解析失败:%v", err)
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3880. return
  3881. }
  3882. if res3.Infcode == 0 {
  3883. item.IsChange = 1
  3884. item.BgBchno = bg_number
  3885. service.SaveDF2(item)
  3886. } else {
  3887. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3888. }
  3889. }
  3890. } else { //没销售,
  3891. var res FJ3507Result
  3892. var res3507for10188 FJ3507ResultFor10188
  3893. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3894. //进行商品销售接口
  3895. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3896. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3897. var respJSON3 map[string]interface{}
  3898. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3901. return
  3902. }
  3903. userJSONBytes3, _ := json.Marshal(respJSON3)
  3904. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3905. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3906. utils.ErrorLog("解析失败:%v", err)
  3907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3908. return
  3909. }
  3910. //if res3507for10188.Infcode
  3911. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3912. //res.Output = resSix10265.Output
  3913. res.ErrMsg = res3507for10188.ErrMsg
  3914. res.Cainfo = res3507for10188.Cainfo
  3915. res.WarnMsg = res3507for10188.WarnMsg
  3916. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3917. res.Infcode = infocode
  3918. } else {
  3919. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3920. utils.ErrorLog("解析失败:%v", err)
  3921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3922. return
  3923. }
  3924. }
  3925. if res.Infcode == 0 {
  3926. item.IsSale = 1
  3927. item.Bchno = number
  3928. item.SaleDate = time.Now().Format("2006-01-02")
  3929. err5 := service.SaveDF(item)
  3930. if err5 == nil {
  3931. if item.IsChange == 0 { //没变更,进行变更操作
  3932. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3933. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3934. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3935. var respJSON3 map[string]interface{}
  3936. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3942. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3943. utils.ErrorLog("解析失败:%v", err)
  3944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3945. return
  3946. }
  3947. //if res3507for10188.Infcode
  3948. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3949. //res.Output = resSix10265.Output
  3950. res3.ErrMsg = res3507for10188.ErrMsg
  3951. res3.Cainfo = res3507for10188.Cainfo
  3952. res3.WarnMsg = res3507for10188.WarnMsg
  3953. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3954. res3.Infcode = infocode
  3955. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3956. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3957. utils.ErrorLog("解析失败:%v", err)
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. return
  3960. }
  3961. //if res3507for10188.Infcode
  3962. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3963. //res.Output = resSix10265.Output
  3964. res3.ErrMsg = res3507for10188.ErrMsg
  3965. res3.Cainfo = res3507for10188.Cainfo
  3966. res3.WarnMsg = res3507for10188.WarnMsg
  3967. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3968. res3.Infcode = infocode
  3969. } else {
  3970. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3971. utils.ErrorLog("解析失败:%v", err)
  3972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3973. return
  3974. }
  3975. }
  3976. if res3.Infcode == 0 {
  3977. item.IsChange = 1
  3978. item.BgBchno = bg_number
  3979. service.SaveDF2(item)
  3980. } else {
  3981. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3982. }
  3983. }
  3984. }
  3985. } else {
  3986. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3987. }
  3988. }
  3989. } else { //还没结算
  3990. var res3507for10188 FJ3507ResultFor10188
  3991. if item.IsChange == 0 { //没变更,进行变更操作
  3992. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3993. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3994. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3995. var respJSON3 map[string]interface{}
  3996. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3999. return
  4000. }
  4001. userJSONBytes3, _ := json.Marshal(respJSON3)
  4002. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4003. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4004. utils.ErrorLog("解析失败:%v", err)
  4005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4006. return
  4007. }
  4008. //if res3507for10188.Infcode
  4009. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4010. //res.Output = resSix10265.Output
  4011. res3.ErrMsg = res3507for10188.ErrMsg
  4012. res3.Cainfo = res3507for10188.Cainfo
  4013. res3.WarnMsg = res3507for10188.WarnMsg
  4014. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4015. res3.Infcode = infocode
  4016. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4017. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4018. utils.ErrorLog("解析失败:%v", err)
  4019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4020. return
  4021. }
  4022. //if res3507for10188.Infcode
  4023. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4024. //res.Output = resSix10265.Output
  4025. res3.ErrMsg = res3507for10188.ErrMsg
  4026. res3.Cainfo = res3507for10188.Cainfo
  4027. res3.WarnMsg = res3507for10188.WarnMsg
  4028. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4029. res3.Infcode = infocode
  4030. } else {
  4031. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4032. utils.ErrorLog("解析失败:%v", err)
  4033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4034. return
  4035. }
  4036. }
  4037. if res3.Infcode == 0 {
  4038. item.IsChange = 1
  4039. item.BgBchno = bg_number
  4040. service.SaveDF2(item)
  4041. } else {
  4042. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4043. }
  4044. }
  4045. }
  4046. } else if item.ConsumableType == 7 {
  4047. var res3507for10188 FJ3507ResultFor10188
  4048. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4049. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4050. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4051. //判断是否已经销售
  4052. if item.IsSale == 2 { //是否已经销售,1是 0否
  4053. //是否已经变更 1是 0否
  4054. if item.IsChange == 0 { //没变更,进行变更操作
  4055. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4056. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4057. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4058. var respJSON3 map[string]interface{}
  4059. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4062. return
  4063. }
  4064. userJSONBytes3, _ := json.Marshal(respJSON3)
  4065. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4066. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4067. utils.ErrorLog("解析失败:%v", err)
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4069. return
  4070. }
  4071. //if res3507for10188.Infcode
  4072. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4073. //res.Output = resSix10265.Output
  4074. res3.ErrMsg = res3507for10188.ErrMsg
  4075. res3.Cainfo = res3507for10188.Cainfo
  4076. res3.WarnMsg = res3507for10188.WarnMsg
  4077. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4078. res3.Infcode = infocode
  4079. } else {
  4080. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4081. utils.ErrorLog("解析失败:%v", err)
  4082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4083. return
  4084. }
  4085. }
  4086. if res3.Infcode == 0 {
  4087. item.IsChange = 1
  4088. item.BgBchno = bg_number
  4089. service.SaveDF2(item)
  4090. } else {
  4091. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4092. }
  4093. }
  4094. } else { //没销售,
  4095. //进行商品销售退货接口
  4096. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4097. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4098. saveLog(result111, result222, "3506", "销售退货")
  4099. var res7 FJ3507Result
  4100. //进行商品销售接口
  4101. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4102. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4103. var respJSON3 map[string]interface{}
  4104. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4107. return
  4108. }
  4109. userJSONBytes3, _ := json.Marshal(respJSON3)
  4110. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4111. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4112. utils.ErrorLog("解析失败:%v", err)
  4113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4114. return
  4115. }
  4116. //if res3507for10188.Infcode
  4117. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4118. //res.Output = resSix10265.Output
  4119. res7.ErrMsg = res3507for10188.ErrMsg
  4120. res7.Cainfo = res3507for10188.Cainfo
  4121. res7.WarnMsg = res3507for10188.WarnMsg
  4122. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4123. res7.Infcode = infocode
  4124. } else {
  4125. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4126. utils.ErrorLog("解析失败:%v", err)
  4127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4128. return
  4129. }
  4130. }
  4131. if res7.Infcode == 0 {
  4132. item.IsSale = 2
  4133. item.SaleDate = item.SaleDate
  4134. item.Bchno = number
  4135. service.SaveDF(item)
  4136. if item.IsChange == 0 { //没变更,进行变更操作
  4137. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4138. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4139. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4140. var respJSON3 map[string]interface{}
  4141. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4144. return
  4145. }
  4146. userJSONBytes3, _ := json.Marshal(respJSON3)
  4147. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4148. // utils.ErrorLog("解析失败:%v", err)
  4149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4150. // return
  4151. //}
  4152. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4153. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4154. utils.ErrorLog("解析失败:%v", err)
  4155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4156. return
  4157. }
  4158. //if res3507for10188.Infcode
  4159. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4160. //res.Output = resSix10265.Output
  4161. res3.ErrMsg = res3507for10188.ErrMsg
  4162. res3.Cainfo = res3507for10188.Cainfo
  4163. res3.WarnMsg = res3507for10188.WarnMsg
  4164. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4165. res3.Infcode = infocode
  4166. } else {
  4167. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4168. utils.ErrorLog("解析失败:%v", err)
  4169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4170. return
  4171. }
  4172. }
  4173. if res3.Infcode == 0 {
  4174. item.IsChange = 1
  4175. item.BgBchno = bg_number
  4176. service.SaveDF2(item)
  4177. } else {
  4178. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4179. }
  4180. }
  4181. } else {
  4182. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4183. }
  4184. }
  4185. } else { //还没结算
  4186. if item.IsChange == 0 { //没变更,进行变更操作
  4187. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4188. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4189. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4190. var respJSON3 map[string]interface{}
  4191. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4194. return
  4195. }
  4196. userJSONBytes3, _ := json.Marshal(respJSON3)
  4197. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4198. // utils.ErrorLog("解析失败:%v", err)
  4199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. // return
  4201. //}
  4202. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4203. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4204. utils.ErrorLog("解析失败:%v", err)
  4205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4206. return
  4207. }
  4208. //if res3507for10188.Infcode
  4209. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4210. //res.Output = resSix10265.Output
  4211. res3.ErrMsg = res3507for10188.ErrMsg
  4212. res3.Cainfo = res3507for10188.Cainfo
  4213. res3.WarnMsg = res3507for10188.WarnMsg
  4214. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4215. res3.Infcode = infocode
  4216. } else {
  4217. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4218. utils.ErrorLog("解析失败:%v", err)
  4219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4220. return
  4221. }
  4222. }
  4223. if res3.Infcode == 0 {
  4224. item.IsChange = 1
  4225. item.BgBchno = bg_number
  4226. service.SaveDF2(item)
  4227. } else {
  4228. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4229. }
  4230. }
  4231. }
  4232. }
  4233. }
  4234. if len(err) == 0 {
  4235. c.ServeSuccessJSON(map[string]interface{}{
  4236. "msg": "销售变更成功",
  4237. })
  4238. } else {
  4239. c.ServeSuccessJSON(map[string]interface{}{
  4240. "failed_code": -10,
  4241. "msg": err,
  4242. })
  4243. }
  4244. }
  4245. func (c *HisApiController) ChangeDrugTen() {
  4246. start_time_str := c.GetString("start_time")
  4247. end_time_str := c.GetString("end_time")
  4248. //ids := c.GetString("ids")
  4249. //id_arr := strings.Split(ids, ",")
  4250. timeLayout := "2006-01-02"
  4251. loc, _ := time.LoadLocation("Local")
  4252. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4253. recordStartTime := theStartTime.Unix()
  4254. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4255. recordEndTime := theEndTime.Unix()
  4256. //timestamp := int64(1729612800)
  4257. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4258. admin_user_id, _ := c.GetInt64("admin_user_id")
  4259. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4260. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4261. var err []string
  4262. for _, item := range flows {
  4263. var res3 ResultSix
  4264. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4265. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4266. continue
  4267. }
  4268. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4269. continue
  4270. }
  4271. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4272. if prescription.OrderStatus == 2 {
  4273. //已经结算
  4274. //判断 是否已经销售
  4275. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4276. ////是否已经变更 1是 0否
  4277. //if item.IsChange == 0 { //没变更,进行变更操作
  4278. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4279. //
  4280. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4281. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4282. // var respJSON3 map[string]interface{}
  4283. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4284. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4286. // return
  4287. // }
  4288. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4289. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4290. // utils.ErrorLog("解析失败:%v", err)
  4291. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4292. // return
  4293. // }
  4294. // if res3.Infcode == 0 {
  4295. // item.IsChange = 1
  4296. // item.BgBchno = bg_number
  4297. // service.SaveDF2(item)
  4298. // } else {
  4299. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4300. // }
  4301. //}
  4302. //} else
  4303. if item.IsSale == 0 { //没销售,
  4304. var res FJ3507Result
  4305. var res3507for10188 FJ3507ResultFor10188
  4306. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4307. //进行商品销售接口
  4308. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4309. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4310. var respJSON3 map[string]interface{}
  4311. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4314. return
  4315. }
  4316. userJSONBytes3, _ := json.Marshal(respJSON3)
  4317. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4318. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4319. utils.ErrorLog("解析失败:%v", err)
  4320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4321. return
  4322. }
  4323. //if res3507for10188.Infcode
  4324. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4325. //res.Output = resSix10265.Output
  4326. res.ErrMsg = res3507for10188.ErrMsg
  4327. res.Cainfo = res3507for10188.Cainfo
  4328. res.WarnMsg = res3507for10188.WarnMsg
  4329. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4330. res.Infcode = infocode
  4331. } else {
  4332. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4333. utils.ErrorLog("解析失败:%v", err)
  4334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4335. return
  4336. }
  4337. }
  4338. if res.Infcode == 0 {
  4339. item.IsSale = 1
  4340. item.Bchno = number
  4341. item.SaleDate = time.Now().Format("2006-01-02")
  4342. err5 := service.SaveDF(item)
  4343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4344. //if err5 == nil {
  4345. //
  4346. // if item.IsChange == 1 { //没变更,进行变更操作
  4347. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4348. //
  4349. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4350. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4351. //
  4352. // var respJSON3 map[string]interface{}
  4353. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4354. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. // return
  4357. // }
  4358. //
  4359. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4360. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4361. // utils.ErrorLog("解析失败:%v", err)
  4362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. // return
  4364. // }
  4365. // //if res3507for10188.Infcode
  4366. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4367. // //res.Output = resSix10265.Output
  4368. // res3.ErrMsg = res3507for10188.ErrMsg
  4369. // res3.Cainfo = res3507for10188.Cainfo
  4370. // res3.WarnMsg = res3507for10188.WarnMsg
  4371. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4372. // res3.Infcode = infocode
  4373. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4374. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4375. // utils.ErrorLog("解析失败:%v", err)
  4376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4377. // return
  4378. // }
  4379. // //if res3507for10188.Infcode
  4380. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4381. // //res.Output = resSix10265.Output
  4382. // res3.ErrMsg = res3507for10188.ErrMsg
  4383. // res3.Cainfo = res3507for10188.Cainfo
  4384. // res3.WarnMsg = res3507for10188.WarnMsg
  4385. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4386. // res3.Infcode = infocode
  4387. //
  4388. // } else {
  4389. //
  4390. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4391. // utils.ErrorLog("解析失败:%v", err)
  4392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. // return
  4394. // }
  4395. //
  4396. // }
  4397. //
  4398. // if res3.Infcode == 0 {
  4399. // item.IsChange = 1
  4400. // item.BgBchno = bg_number
  4401. // service.SaveDF2(item)
  4402. // return
  4403. // } else {
  4404. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4405. // }
  4406. // }
  4407. //}
  4408. } else {
  4409. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4410. }
  4411. }
  4412. }
  4413. } else if item.ConsumableType == 7 {
  4414. var res3507for10188 FJ3507ResultFor10188
  4415. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4416. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4417. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4418. //判断是否已经销售
  4419. if item.IsSale == 2 { //是否已经销售,1是 0否
  4420. //是否已经变更 1是 0否
  4421. if item.IsChange == 0 { //没变更,进行变更操作
  4422. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4423. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4424. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4425. var respJSON3 map[string]interface{}
  4426. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4429. return
  4430. }
  4431. userJSONBytes3, _ := json.Marshal(respJSON3)
  4432. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4433. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4434. utils.ErrorLog("解析失败:%v", err)
  4435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4436. return
  4437. }
  4438. //if res3507for10188.Infcode
  4439. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4440. //res.Output = resSix10265.Output
  4441. res3.ErrMsg = res3507for10188.ErrMsg
  4442. res3.Cainfo = res3507for10188.Cainfo
  4443. res3.WarnMsg = res3507for10188.WarnMsg
  4444. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4445. res3.Infcode = infocode
  4446. } else {
  4447. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4448. utils.ErrorLog("解析失败:%v", err)
  4449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4450. return
  4451. }
  4452. }
  4453. if res3.Infcode == 0 {
  4454. item.IsChange = 1
  4455. item.BgBchno = bg_number
  4456. service.SaveDF2(item)
  4457. } else {
  4458. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4459. }
  4460. }
  4461. } else { //没销售,
  4462. //进行商品销售退货接口
  4463. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4464. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4465. saveLog(result111, result222, "3506", "销售退货")
  4466. var res7 FJ3507Result
  4467. //进行商品销售接口
  4468. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4469. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4470. var respJSON3 map[string]interface{}
  4471. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4474. return
  4475. }
  4476. userJSONBytes3, _ := json.Marshal(respJSON3)
  4477. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4478. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4479. utils.ErrorLog("解析失败:%v", err)
  4480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4481. return
  4482. }
  4483. //if res3507for10188.Infcode
  4484. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4485. //res.Output = resSix10265.Output
  4486. res7.ErrMsg = res3507for10188.ErrMsg
  4487. res7.Cainfo = res3507for10188.Cainfo
  4488. res7.WarnMsg = res3507for10188.WarnMsg
  4489. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4490. res7.Infcode = infocode
  4491. } else {
  4492. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4493. utils.ErrorLog("解析失败:%v", err)
  4494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4495. return
  4496. }
  4497. }
  4498. if res7.Infcode == 0 {
  4499. item.IsSale = 2
  4500. item.SaleDate = item.SaleDate
  4501. item.Bchno = number
  4502. service.SaveDF(item)
  4503. if item.IsChange == 0 { //没变更,进行变更操作
  4504. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4505. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4506. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4507. var respJSON3 map[string]interface{}
  4508. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4511. return
  4512. }
  4513. userJSONBytes3, _ := json.Marshal(respJSON3)
  4514. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4515. // utils.ErrorLog("解析失败:%v", err)
  4516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4517. // return
  4518. //}
  4519. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4520. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4521. utils.ErrorLog("解析失败:%v", err)
  4522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4523. return
  4524. }
  4525. //if res3507for10188.Infcode
  4526. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4527. //res.Output = resSix10265.Output
  4528. res3.ErrMsg = res3507for10188.ErrMsg
  4529. res3.Cainfo = res3507for10188.Cainfo
  4530. res3.WarnMsg = res3507for10188.WarnMsg
  4531. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4532. res3.Infcode = infocode
  4533. } else {
  4534. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4535. utils.ErrorLog("解析失败:%v", err)
  4536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4537. return
  4538. }
  4539. }
  4540. if res3.Infcode == 0 {
  4541. item.IsChange = 1
  4542. item.BgBchno = bg_number
  4543. service.SaveDF2(item)
  4544. } else {
  4545. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4546. }
  4547. }
  4548. } else {
  4549. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4550. }
  4551. }
  4552. } else { //还没结算
  4553. if item.IsChange == 0 { //没变更,进行变更操作
  4554. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4555. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4556. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4557. var respJSON3 map[string]interface{}
  4558. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4561. return
  4562. }
  4563. userJSONBytes3, _ := json.Marshal(respJSON3)
  4564. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4565. // utils.ErrorLog("解析失败:%v", err)
  4566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4567. // return
  4568. //}
  4569. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4570. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4571. utils.ErrorLog("解析失败:%v", err)
  4572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. return
  4574. }
  4575. //if res3507for10188.Infcode
  4576. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4577. //res.Output = resSix10265.Output
  4578. res3.ErrMsg = res3507for10188.ErrMsg
  4579. res3.Cainfo = res3507for10188.Cainfo
  4580. res3.WarnMsg = res3507for10188.WarnMsg
  4581. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4582. res3.Infcode = infocode
  4583. } else {
  4584. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4585. utils.ErrorLog("解析失败:%v", err)
  4586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. return
  4588. }
  4589. }
  4590. if res3.Infcode == 0 {
  4591. item.IsChange = 1
  4592. item.BgBchno = bg_number
  4593. service.SaveDF2(item)
  4594. } else {
  4595. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4596. }
  4597. }
  4598. }
  4599. }
  4600. }
  4601. if len(err) == 0 {
  4602. c.ServeSuccessJSON(map[string]interface{}{
  4603. "msg": "销售变更成功",
  4604. })
  4605. } else {
  4606. c.ServeSuccessJSON(map[string]interface{}{
  4607. "failed_code": -10,
  4608. "msg": err,
  4609. })
  4610. }
  4611. }
  4612. func ChangeDrugTenone() {
  4613. //ids := c.GetString("ids")
  4614. //id_arr := strings.Split(ids, ",")
  4615. now := time.Now()
  4616. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4617. //timestamp := int64(1729612800)
  4618. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4619. admin_user_id := int64(2463)
  4620. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4621. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4622. var err []string
  4623. for _, item := range flows {
  4624. var res3 ResultSix
  4625. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4626. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4627. continue
  4628. }
  4629. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4630. continue
  4631. }
  4632. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4633. if prescription.OrderStatus == 2 {
  4634. //已经结算
  4635. //判断是否已经销售
  4636. if item.IsSale == 1 { //是否已经销售,1是 0否
  4637. //是否已经变更 1是 0否
  4638. if item.IsChange == 0 { //没变更,进行变更操作
  4639. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4640. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4641. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4642. var respJSON3 map[string]interface{}
  4643. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4645. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4646. return
  4647. }
  4648. userJSONBytes3, _ := json.Marshal(respJSON3)
  4649. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4650. utils.ErrorLog("解析失败:%v", err)
  4651. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4652. return
  4653. }
  4654. if res3.Infcode == 0 {
  4655. item.IsChange = 1
  4656. item.BgBchno = bg_number
  4657. service.SaveDF2(item)
  4658. } else {
  4659. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4660. }
  4661. }
  4662. } else { //没销售,
  4663. var res FJ3507Result
  4664. var res3507for10188 FJ3507ResultFor10188
  4665. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4666. //进行商品销售接口
  4667. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4668. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4669. var respJSON3 map[string]interface{}
  4670. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4672. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4673. return
  4674. }
  4675. userJSONBytes3, _ := json.Marshal(respJSON3)
  4676. {
  4677. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4678. utils.ErrorLog("解析失败:%v", err)
  4679. return
  4680. }
  4681. //if res3507for10188.Infcode
  4682. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4683. //res.Output = resSix10265.Output
  4684. res.ErrMsg = res3507for10188.ErrMsg
  4685. res.Cainfo = res3507for10188.Cainfo
  4686. res.WarnMsg = res3507for10188.WarnMsg
  4687. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4688. res.Infcode = infocode
  4689. }
  4690. if res.Infcode == 0 {
  4691. item.IsSale = 1
  4692. item.Bchno = number
  4693. item.SaleDate = time.Now().Format("2006-01-02")
  4694. err5 := service.SaveDF(item)
  4695. if err5 == nil {
  4696. if item.IsChange == 1 { //没变更,进行变更操作
  4697. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4698. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4699. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4700. var respJSON3 map[string]interface{}
  4701. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4703. return
  4704. }
  4705. {
  4706. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4707. utils.ErrorLog("解析失败:%v", err)
  4708. return
  4709. }
  4710. //if res3507for10188.Infcode
  4711. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4712. //res.Output = resSix10265.Output
  4713. res3.ErrMsg = res3507for10188.ErrMsg
  4714. res3.Cainfo = res3507for10188.Cainfo
  4715. res3.WarnMsg = res3507for10188.WarnMsg
  4716. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4717. res3.Infcode = infocode
  4718. }
  4719. if res3.Infcode == 0 {
  4720. item.IsChange = 1
  4721. item.BgBchno = bg_number
  4722. service.SaveDF2(item)
  4723. } else {
  4724. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4725. }
  4726. }
  4727. }
  4728. } else {
  4729. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4730. }
  4731. }
  4732. }
  4733. }
  4734. }
  4735. }
  4736. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4737. var struct3502 models.Struct3502
  4738. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4739. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4740. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4741. struct3502.FixmedinsCode = miConfig.Code
  4742. struct3502.Code = miConfig.Code
  4743. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4744. struct3502.Opter = role.UserName
  4745. struct3502.RxFlag = "1"
  4746. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4747. struct3502.OrgName = miConfig.OrgName
  4748. struct3502.AccessKey = miConfig.AccessKey
  4749. struct3502.RequestUrl = miConfig.Url
  4750. struct3502.SecretKey = miConfig.SecretKey
  4751. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4752. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4753. struct3502.Url = miConfig.Url
  4754. struct3502.AppId = miConfig.Cainfo
  4755. struct3502.AppSecret = miConfig.AppSecret
  4756. struct3502.Enckey = miConfig.EncKey
  4757. struct3502.SignKey = miConfig.SignKey
  4758. struct3502.SecretKey = miConfig.SecretKey
  4759. struct3502.InvChgType = chgType
  4760. struct3502.FixmedinsBchno = number
  4761. struct3502.Cnt = strconv.FormatInt(count, 10)
  4762. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4763. //result1, result2, _ := service.FJyb3502(struct3502)
  4764. if miConfig.MdtrtareaAdmvs == "350500" {
  4765. result1, result2, _ := service.FJyb3502(struct3502)
  4766. //saveLog(result1, result2, "3502", "3502")
  4767. return result1, result2
  4768. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4769. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4770. return result1, result2
  4771. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4772. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4773. return result1, result2
  4774. } else {
  4775. data := make(map[string]interface{})
  4776. data["struct_3502s"] = struct3502
  4777. client := &http.Client{}
  4778. bytesData, _ := json.Marshal(data)
  4779. var req *http.Request
  4780. if miConfig.MdtrtareaAdmvs == "320921" {
  4781. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4782. } else {
  4783. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4784. }
  4785. resp, _ := client.Do(req)
  4786. defer resp.Body.Close()
  4787. body, ioErr := ioutil.ReadAll(resp.Body)
  4788. if ioErr != nil {
  4789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4790. }
  4791. var respJSON map[string]interface{}
  4792. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4794. }
  4795. //var resSix10265 ResultSix10265 //1101结果
  4796. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4797. result, _ := json.Marshal(respJSON)
  4798. return string(result), ""
  4799. }
  4800. }
  4801. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4802. var struct3505 models.Struct3505
  4803. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4804. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4805. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4806. struct3505.FixmedinsBchno = number
  4807. struct3505.Opter = role.UserName
  4808. struct3505.Bchno = "---"
  4809. struct3505.FixmedinsCode = miConfig.Code
  4810. struct3505.Code = miConfig.Code
  4811. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  4812. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4813. struct3505.PrscDrName = roles.UserName
  4814. if org_id == 10191 {
  4815. struct3505.PharName = "刘水山"
  4816. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4817. }
  4818. if org_id == 10188 {
  4819. struct3505.PharName = "李汉清"
  4820. struct3505.PharPracCertNo = "30220200932022010034"
  4821. }
  4822. if org_id == 10217 {
  4823. struct3505.PharName = "张敏"
  4824. struct3505.PharPracCertNo = "30220230432090100108"
  4825. }
  4826. if org_id == 10318 {
  4827. struct3505.PharName = "邹刘阳"
  4828. struct3505.PharPracCertNo = "210441200001378"
  4829. }
  4830. if org_id == 10402 {
  4831. struct3505.PharName = "刘韶健"
  4832. struct3505.PharPracCertNo = "2015026440262015440501001198"
  4833. }
  4834. if org_id == 9919 {
  4835. struct3505.PharName = "周君权"
  4836. struct3505.PharPracCertNo = "089644396094401375"
  4837. }
  4838. if org_id == 10644 {
  4839. struct3505.PharName = "陈金娣"
  4840. struct3505.PharPracCertNo = "20181441500320100066"
  4841. }
  4842. if org_id == 10567 {
  4843. struct3505.PharName = "范小兰"
  4844. struct3505.PharPracCertNo = "0200102079485"
  4845. }
  4846. if org_id == 10721 {
  4847. struct3505.PharName = "孙莉侠"
  4848. struct3505.PharPracCertNo = "060399"
  4849. }
  4850. if org_id == 10726 {
  4851. struct3505.PharName = "彭建福"
  4852. struct3505.PharPracCertNo = "D445281006261"
  4853. }
  4854. if org_id == 10265 {
  4855. struct3505.PharName = "李彩星"
  4856. struct3505.PharPracCertNo = "20171110600110100019"
  4857. }
  4858. if org_id == 10028 {
  4859. struct3505.PharName = "曾细平"
  4860. struct3505.PharPracCertNo = "D440307022134"
  4861. }
  4862. if org_id == 10138 {
  4863. struct3505.PharName = "彭斯遥"
  4864. struct3505.PharPracCertNo = "30220200943042010052"
  4865. }
  4866. if org_id == 10278 {
  4867. struct3505.PharName = "彭斯遥"
  4868. struct3505.PharPracCertNo = "30220200943042010052"
  4869. }
  4870. if org_id == 10610 {
  4871. struct3505.PharName = "彭斯遥"
  4872. struct3505.PharPracCertNo = "30220200943042010052"
  4873. }
  4874. if org_id == 10537 {
  4875. struct3505.PharName = "彭斯遥"
  4876. struct3505.PharPracCertNo = "30220200943042010052"
  4877. }
  4878. if org_id == 9504 {
  4879. struct3505.PharName = "资美红"
  4880. struct3505.PharPracCertNo = "D440904006635"
  4881. }
  4882. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4883. struct3505.SetlId = order.SetlId
  4884. struct3505.MdtrtSn = order.MdtrtId
  4885. struct3505.ManuLotnum = drug.BatchNumber
  4886. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4887. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  4888. struct3505.RxFlag = "1"
  4889. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  4890. struct3505.TrdnFlag = "0"
  4891. } else {
  4892. struct3505.TrdnFlag = "1"
  4893. }
  4894. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  4895. struct3505.TrdnFlag = "1"
  4896. }
  4897. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  4898. struct3505.TrdnFlag = "0"
  4899. }
  4900. struct3505.RtalDocno = order.Number
  4901. struct3505.PsnCertType = "01"
  4902. struct3505.CertNo = order.Certno
  4903. struct3505.PsnNo = order.PsnNo
  4904. struct3505.PsnName = order.PsnName
  4905. struct3505.Url = miConfig.Url
  4906. struct3505.AppId = miConfig.Cainfo
  4907. struct3505.AppSecret = miConfig.AppSecret
  4908. struct3505.Enckey = miConfig.EncKey
  4909. struct3505.SignKey = miConfig.SignKey
  4910. struct3505.SecretKey = miConfig.SecretKey
  4911. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4912. struct3505.SelRetnCnt = strValue
  4913. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4914. struct3505.SelRetnOpterName = role.UserName
  4915. if order.IsMedicineInsurance == 1 {
  4916. struct3505.MdtrtSetlType = "1"
  4917. } else {
  4918. struct3505.MdtrtSetlType = "2"
  4919. }
  4920. struct3505.OrgName = miConfig.OrgName
  4921. struct3505.AccessKey = miConfig.AccessKey
  4922. struct3505.RequestUrl = miConfig.Url
  4923. struct3505.SecretKey = miConfig.SecretKey
  4924. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4925. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4926. struct3505.Cainfo = miConfig.Cainfo
  4927. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4928. if miConfig.MdtrtareaAdmvs == "350500" {
  4929. result1, result2, _ := service.FJyb3505(struct3505)
  4930. return result1, result2
  4931. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4932. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4933. return result1, result2
  4934. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4935. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  4936. return result1, result2
  4937. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  4938. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  4939. return result1, result2
  4940. } else if miConfig.MdtrtareaAdmvs == "340699" {
  4941. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  4942. return result1, result2
  4943. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4944. data := make(map[string]interface{})
  4945. data["struct_3505s"] = struct3505
  4946. client := &http.Client{}
  4947. bytesData, _ := json.Marshal(data)
  4948. var req *http.Request
  4949. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  4950. resp, _ := client.Do(req)
  4951. defer resp.Body.Close()
  4952. body, ioErr := ioutil.ReadAll(resp.Body)
  4953. if ioErr != nil {
  4954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4955. }
  4956. var respJSON map[string]interface{}
  4957. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4959. }
  4960. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4961. result, _ := json.Marshal(respJSON)
  4962. return string(result), ""
  4963. } else {
  4964. data := make(map[string]interface{})
  4965. data["struct_3505s"] = struct3505
  4966. client := &http.Client{}
  4967. bytesData, _ := json.Marshal(data)
  4968. var req *http.Request
  4969. if miConfig.MdtrtareaAdmvs == "320921" {
  4970. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4971. } else {
  4972. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4973. }
  4974. resp, _ := client.Do(req)
  4975. defer resp.Body.Close()
  4976. body, ioErr := ioutil.ReadAll(resp.Body)
  4977. if ioErr != nil {
  4978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4979. }
  4980. var respJSON map[string]interface{}
  4981. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4983. }
  4984. //var resSix10265 ResultSix10265 //1101结果
  4985. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4986. result, _ := json.Marshal(respJSON)
  4987. return string(result), ""
  4988. }
  4989. }
  4990. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4991. var struct3505 models.Struct3505
  4992. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4993. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4994. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4995. struct3505.FixmedinsBchno = number
  4996. struct3505.Opter = role.UserName
  4997. struct3505.FixmedinsCode = miConfig.Code
  4998. struct3505.Code = miConfig.Code
  4999. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5000. struct3505.PrscDrName = roles.UserName
  5001. if org_id == 10191 {
  5002. struct3505.PharName = "刘水山"
  5003. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5004. }
  5005. if org_id == 10188 {
  5006. struct3505.PharName = "李汉清"
  5007. struct3505.PharPracCertNo = "30220200932022010034"
  5008. }
  5009. if org_id == 10217 {
  5010. struct3505.PharName = "张敏"
  5011. struct3505.PharPracCertNo = "30220230432090100108"
  5012. }
  5013. if org_id == 10318 {
  5014. struct3505.PharName = "邹刘阳"
  5015. struct3505.PharPracCertNo = "210441200001378"
  5016. }
  5017. if org_id == 10402 {
  5018. struct3505.PharName = "刘韶健"
  5019. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5020. }
  5021. if org_id == 9919 {
  5022. struct3505.PharName = "周君权"
  5023. struct3505.PharPracCertNo = "089644396094401375"
  5024. }
  5025. if org_id == 10644 {
  5026. struct3505.PharName = "陈金娣"
  5027. struct3505.PharPracCertNo = "20181441500320100066"
  5028. }
  5029. if org_id == 10567 {
  5030. struct3505.PharName = "范小兰"
  5031. struct3505.PharPracCertNo = "0200102079485"
  5032. }
  5033. if org_id == 10721 {
  5034. struct3505.PharName = "孙莉侠"
  5035. struct3505.PharPracCertNo = "060399"
  5036. }
  5037. if org_id == 10726 {
  5038. struct3505.PharName = "彭建福"
  5039. struct3505.PharPracCertNo = "D445281006261"
  5040. }
  5041. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5042. struct3505.SetlId = order.SetlId
  5043. struct3505.MdtrtSn = order.MdtrtId
  5044. struct3505.ManuLotnum = drug.Number
  5045. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5046. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5047. struct3505.RxFlag = "1"
  5048. struct3505.TrdnFlag = "0"
  5049. struct3505.RtalDocno = order.Number
  5050. struct3505.PsnCertType = "01"
  5051. struct3505.CertNo = order.Certno
  5052. struct3505.PsnNo = order.PsnNo
  5053. struct3505.PsnName = order.PsnName
  5054. struct3505.Url = miConfig.Url
  5055. struct3505.AppId = miConfig.Cainfo
  5056. struct3505.AppSecret = miConfig.AppSecret
  5057. struct3505.Enckey = miConfig.EncKey
  5058. struct3505.SignKey = miConfig.SignKey
  5059. struct3505.SecretKey = miConfig.SecretKey
  5060. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5061. struct3505.SelRetnCnt = strValue
  5062. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5063. struct3505.SelRetnOpterName = role.UserName
  5064. if order.IsMedicineInsurance == 1 {
  5065. struct3505.MdtrtSetlType = "1"
  5066. } else {
  5067. struct3505.MdtrtSetlType = "2"
  5068. }
  5069. struct3505.OrgName = miConfig.OrgName
  5070. struct3505.AccessKey = miConfig.AccessKey
  5071. struct3505.RequestUrl = miConfig.Url
  5072. struct3505.SecretKey = miConfig.SecretKey
  5073. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5074. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5075. struct3505.Cainfo = miConfig.Cainfo
  5076. struct3505.DrugTracCodg = drug.DrugCode
  5077. if miConfig.MdtrtareaAdmvs == "350500" {
  5078. result1, result2, _ := service.FJyb3505(struct3505)
  5079. return result1, result2
  5080. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5081. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5082. return result1, result2
  5083. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5084. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5085. return result1, result2
  5086. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5087. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5088. return result1, result2
  5089. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5090. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5091. return result1, result2
  5092. } else {
  5093. data := make(map[string]interface{})
  5094. data["struct_3505s"] = struct3505
  5095. client := &http.Client{}
  5096. bytesData, _ := json.Marshal(data)
  5097. var req *http.Request
  5098. if miConfig.MdtrtareaAdmvs == "320921" {
  5099. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5100. } else {
  5101. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5102. }
  5103. resp, _ := client.Do(req)
  5104. defer resp.Body.Close()
  5105. body, ioErr := ioutil.ReadAll(resp.Body)
  5106. if ioErr != nil {
  5107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5108. }
  5109. var respJSON map[string]interface{}
  5110. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5112. }
  5113. //var resSix10265 ResultSix10265 //1101结果
  5114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5115. result, _ := json.Marshal(respJSON)
  5116. return string(result), ""
  5117. }
  5118. }
  5119. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5120. var struct3506 models.Struct3506
  5121. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5122. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5123. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5124. struct3506.FixmedinsCode = miConfig.Code
  5125. struct3506.Code = miConfig.Code
  5126. struct3506.FixmedinsBchno = number
  5127. struct3506.Opter = role.UserName
  5128. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5129. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5130. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5131. struct3506.MdtrtSn = order.MdtrtId
  5132. struct3506.ExpyEnd = ""
  5133. struct3506.RxFlag = "0"
  5134. struct3506.TrdnFlag = "1"
  5135. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5136. struct3506.SelRetnCnt = strValue
  5137. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5138. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5139. struct3506.SelRetnOpterName = role.UserName
  5140. struct3506.OrgName = miConfig.OrgName
  5141. struct3506.AccessKey = miConfig.AccessKey
  5142. struct3506.RequestUrl = miConfig.Url
  5143. struct3506.SecretKey = miConfig.SecretKey
  5144. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5145. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5146. struct3506.Url = miConfig.Url
  5147. struct3506.AppId = miConfig.Cainfo
  5148. struct3506.AppSecret = miConfig.AppSecret
  5149. struct3506.Enckey = miConfig.EncKey
  5150. struct3506.SignKey = miConfig.SignKey
  5151. struct3506.SecretKey = miConfig.SecretKey
  5152. struct3506.DrugTracCodg = drug.DrugCode
  5153. if miConfig.MdtrtareaAdmvs == "350500" {
  5154. result1, result2, _ := service.FJyb3506(struct3506)
  5155. return result1, result2
  5156. } else {
  5157. data := make(map[string]interface{})
  5158. data["struct_3506s"] = struct3506
  5159. client := &http.Client{}
  5160. bytesData, _ := json.Marshal(data)
  5161. var req *http.Request
  5162. if miConfig.MdtrtareaAdmvs == "320921" {
  5163. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5164. } else {
  5165. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5166. }
  5167. resp, _ := client.Do(req)
  5168. defer resp.Body.Close()
  5169. body, ioErr := ioutil.ReadAll(resp.Body)
  5170. if ioErr != nil {
  5171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5172. }
  5173. var respJSON map[string]interface{}
  5174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5176. }
  5177. //var resSix10265 ResultSix10265 //1101结果
  5178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5179. result, _ := json.Marshal(respJSON)
  5180. return string(result), ""
  5181. }
  5182. }
  5183. func (c *HisApiController) Get1318() {
  5184. adminUser := c.GetAdminUserInfo()
  5185. admin_user_id, _ := c.GetInt64("admin_user_id")
  5186. code := c.GetString("code")
  5187. code = ""
  5188. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5189. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5190. api := ""
  5191. if miConfig.MdtrtareaAdmvs == "320921" {
  5192. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5193. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5194. } else {
  5195. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5196. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5197. }
  5198. resp, requestErr := http.Get(api)
  5199. if requestErr != nil {
  5200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5201. return
  5202. }
  5203. body, ioErr := ioutil.ReadAll(resp.Body)
  5204. if ioErr != nil {
  5205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5207. return
  5208. }
  5209. var respJSON map[string]interface{}
  5210. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5213. return
  5214. }
  5215. //var res Result2406
  5216. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5217. result, _ := json.Marshal(respJSON)
  5218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5219. utils.ErrorLog("解析失败:%v", err)
  5220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5221. return
  5222. }
  5223. if res.Infcode == "0" {
  5224. c.ServeSuccessJSON(map[string]interface{}{
  5225. "result": "",
  5226. })
  5227. } else {
  5228. c.ServeSuccessJSON(map[string]interface{}{
  5229. "failed_code": -10,
  5230. "msg": res.ErrMsg,
  5231. })
  5232. */return
  5233. //}
  5234. }
  5235. func (c *HisApiController) Get2503() {
  5236. adminUser := c.GetAdminUserInfo()
  5237. admin_user_id, _ := c.GetInt64("admin_user_id")
  5238. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5239. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5240. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5241. }
  5242. func (c *HisApiController) Get2406() {
  5243. id, _ := c.GetInt64("id")
  5244. record_time := c.GetString("record_time")
  5245. his_patient_id, _ := c.GetInt64("his_patient_id")
  5246. admin_user_id, _ := c.GetInt64("admin_user_id")
  5247. diagnosis_id := c.GetString("diagnosis")
  5248. timeLayout := "2006-01-02"
  5249. loc, _ := time.LoadLocation("Local")
  5250. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5251. if err != nil {
  5252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5253. return
  5254. }
  5255. recordDateTime := theTime.Unix()
  5256. adminUser := c.GetAdminUserInfo()
  5257. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5258. var config []*models.HisXtDiagnoseConfig
  5259. for _, item := range diagnosis_ids {
  5260. id, _ := strconv.ParseInt(item, 10, 64)
  5261. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5262. config = append(config, &diagnosisConfig)
  5263. }
  5264. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5265. fmt.Println(his_patient_id)
  5266. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5267. //timestamp := time.Now().Unix()
  5268. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5269. var patientPrescription models.HisPrescriptionInfo
  5270. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5271. if patientPrescription.ID == 0 {
  5272. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5273. }
  5274. var res2 Result2406
  5275. if miConfig.MdtrtareaAdmvs == "341203" {
  5276. data := make(map[string]interface{})
  5277. client := &http.Client{}
  5278. data["psn_no"] = his.PsnNo
  5279. data["mdtrt_id"] = his.Number
  5280. data["operator"] = roles.UserName
  5281. data["cert_no"] = his.IdCardNo
  5282. data["org_name"] = miConfig.OrgName
  5283. data["psn_name"] = his.Name
  5284. data["ipt_otp_no"] = his.IptOtpNo
  5285. data["ipt_psn_sp_flag_type"] = "0901"
  5286. data["ipt_psn_sp_flag"] = "1"
  5287. data["fixmedins_code"] = miConfig.Code
  5288. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5289. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5290. data["url"] = miConfig.Url
  5291. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5292. bytesData, _ := json.Marshal(data)
  5293. var req *http.Request
  5294. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5295. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5296. resp, _ := client.Do(req)
  5297. defer resp.Body.Close()
  5298. body, ioErr := ioutil.ReadAll(resp.Body)
  5299. if ioErr != nil {
  5300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5302. return
  5303. }
  5304. var respJSON map[string]interface{}
  5305. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5308. return
  5309. }
  5310. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5311. if status == "0" {
  5312. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5313. c.ServeSuccessJSON(map[string]interface{}{
  5314. "failed_code": -10,
  5315. "msg": err_msg,
  5316. })
  5317. return
  5318. }
  5319. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5320. userJSONBytes, _ := json.Marshal(respJSON)
  5321. fmt.Println("log")
  5322. fmt.Println(string(userJSONBytes))
  5323. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5324. utils.ErrorLog("解析失败:%v", err)
  5325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5326. return
  5327. }
  5328. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5329. data := make(map[string]interface{})
  5330. client := &http.Client{}
  5331. data["psn_no"] = his.PsnNo
  5332. data["mdtrt_id"] = his.Number
  5333. data["operator"] = roles.UserName
  5334. data["cert_no"] = his.IdCardNo
  5335. data["org_name"] = miConfig.OrgName
  5336. data["psn_name"] = his.Name
  5337. data["ipt_otp_no"] = his.IptOtpNo
  5338. data["ipt_psn_sp_flag_type"] = "0901"
  5339. data["ipt_psn_sp_flag"] = "1"
  5340. data["fixmedins_code"] = miConfig.Code
  5341. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5342. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5343. data["url"] = miConfig.Url
  5344. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5345. bytesData, _ := json.Marshal(data)
  5346. var req *http.Request
  5347. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5348. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5349. resp, _ := client.Do(req)
  5350. defer resp.Body.Close()
  5351. body, ioErr := ioutil.ReadAll(resp.Body)
  5352. if ioErr != nil {
  5353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5355. return
  5356. }
  5357. var respJSON map[string]interface{}
  5358. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5361. return
  5362. }
  5363. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5364. if status == "0" {
  5365. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5366. c.ServeSuccessJSON(map[string]interface{}{
  5367. "failed_code": -10,
  5368. "msg": err_msg,
  5369. })
  5370. return
  5371. }
  5372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5373. userJSONBytes, _ := json.Marshal(respJSON)
  5374. fmt.Println("log")
  5375. fmt.Println(string(userJSONBytes))
  5376. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5377. utils.ErrorLog("解析失败:%v", err)
  5378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5379. return
  5380. }
  5381. }
  5382. if res2.Infcode != 0 {
  5383. adminUser := c.GetAdminUserInfo()
  5384. errlog := &models.HisOrderError{
  5385. UserOrgId: adminUser.CurrentOrgId,
  5386. Ctime: time.Now().Unix(),
  5387. Mtime: time.Now().Unix(),
  5388. ErrMsg: res2.ErrMsg,
  5389. Status: 1,
  5390. PatientId: id,
  5391. RecordTime: recordDateTime,
  5392. Stage: 3,
  5393. }
  5394. service.CreateErrMsgLog(errlog)
  5395. c.ServeSuccessJSON(map[string]interface{}{
  5396. "failed_code": -10,
  5397. "msg": res2.ErrMsg,
  5398. })
  5399. return
  5400. } else {
  5401. c.ServeSuccessJSON(map[string]interface{}{
  5402. "msg": "上传成功",
  5403. })
  5404. return
  5405. }
  5406. }
  5407. func (c *HisApiController) Get4105() {
  5408. }
  5409. func (c *HisApiController) Post5302() {
  5410. patient_id, _ := c.GetInt64("id")
  5411. admin_user_id, _ := c.GetInt64("admin_user_id")
  5412. p, _ := service.GetHisPatientById(patient_id)
  5413. adminUser := c.GetAdminUserInfo()
  5414. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5415. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5416. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5417. }
  5418. func (c *HisApiController) Get4104() {
  5419. }
  5420. type Output struct {
  5421. CertNo string `json:"certno"`
  5422. PsnName string `json:"psn_name"`
  5423. CardNo string `json:"card_no"`
  5424. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5425. CardSN string `json:"card_sn"`
  5426. PsnCertType string `json:"psn_cert_type"`
  5427. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5428. MdtrtCertType string `json:"mdtrt_cert_type"`
  5429. QRCode string `json:"qrCode"`
  5430. EcToken string `json:"ecToken"`
  5431. }
  5432. type AHResponse struct {
  5433. Body AHBody `json:"body"`
  5434. Code int `json:"code"`
  5435. CSBCode int `json:"csbCode"`
  5436. Message string `json:"message"`
  5437. RequestID string `json:"requestId"`
  5438. State struct{} `json:"state"`
  5439. }
  5440. type AHBody struct {
  5441. ErrMsg string `json:"err_msg"`
  5442. InfRefMsgID string `json:"inf_refmsgid"`
  5443. InfCode int `json:"infcode"`
  5444. Output struct {
  5445. Result []struct {
  5446. BasMednFlag string `json:"bas_medn_flag"`
  5447. ChldMedcFlag string `json:"chld_medc_flag"`
  5448. ChrgitmLv string `json:"chrgitm_lv"`
  5449. Cnt float64 `json:"cnt"`
  5450. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5451. DrtReimFlag string `json:"drt_reim_flag"`
  5452. FeedetlSn string `json:"feedetl_sn"`
  5453. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5454. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5455. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5456. ListSpItemFlag string `json:"list_sp_item_flag"`
  5457. LmtUsedFlag string `json:"lmt_used_flag"`
  5458. MedChrgitmType string `json:"med_chrgitm_type"`
  5459. Memo string `json:"memo"`
  5460. OverlmtAmt float64 `json:"overlmt_amt"`
  5461. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5462. Pric float64 `json:"pric"`
  5463. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5464. SelfpayProp float64 `json:"selfpay_prop"`
  5465. } `json:"result"`
  5466. } `json:"output"`
  5467. }
  5468. type Response struct {
  5469. Output Output `json:"output"`
  5470. Infcode int `json:"infcode"`
  5471. InfRefMsgID string `json:"inf_refmsgid"`
  5472. RefMsgTime string `json:"refmsg_time"`
  5473. RespondTime string `json:"respond_time"`
  5474. ErrMsg string `json:"err_msg"`
  5475. WarnMsg string `json:"warn_msg"`
  5476. SignType string `json:"signtype"`
  5477. CAInfo string `json:"cainfo"`
  5478. }
  5479. func (c *HisApiController) Getquerydata() {
  5480. query_type, _ := c.GetInt64("type")
  5481. refd_setl_flag := c.GetString("refd_setl_flag")
  5482. med_type := c.GetString("med_type")
  5483. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5484. cert_no := c.GetString("cert_no")
  5485. psn_no := c.GetString("psn_no")
  5486. start_time := c.GetString("start_time")
  5487. end_time := c.GetString("end_time")
  5488. page, _ := c.GetInt64("page")
  5489. limit, _ := c.GetInt64("limit")
  5490. var bp models.BusinessParams5262
  5491. bp.RefdSetlFlag = refd_setl_flag
  5492. bp.MedType = med_type
  5493. bp.Certno = cert_no
  5494. bp.Psnno = psn_no
  5495. bp.QBegntime = start_time
  5496. bp.QEndtime = end_time
  5497. if query_type == 1 { //本地
  5498. Post5262(c, bp, page, limit)
  5499. } else { //异地
  5500. Post5267(c, bp, page, limit)
  5501. }
  5502. }
  5503. func (c *HisApiController) Drugscheck() {
  5504. admin_user_id, _ := c.GetInt64("admin_user_id")
  5505. adminUser := c.GetAdminUserInfo()
  5506. var queryResult []QueryResult
  5507. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5508. for _, item := range drugs {
  5509. result := QueryResult{
  5510. ID: item.ID,
  5511. Name: item.DrugName,
  5512. Code: item.MedicalInsuranceNumber,
  5513. List_type_code: "101",
  5514. }
  5515. queryResult = append(queryResult, result)
  5516. }
  5517. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5518. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5519. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5520. for _, item := range queryResult {
  5521. 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)
  5522. }
  5523. }
  5524. func (c *HisApiController) Goodcheck() {
  5525. admin_user_id, _ := c.GetInt64("admin_user_id")
  5526. adminUser := c.GetAdminUserInfo()
  5527. var queryResult []QueryResult
  5528. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5529. for _, item := range goods {
  5530. result := QueryResult{
  5531. ID: item.ID,
  5532. Name: item.GoodName,
  5533. Code: item.SocialSecurityDirectoryCode,
  5534. List_type_code: "301",
  5535. }
  5536. queryResult = append(queryResult, result)
  5537. }
  5538. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5539. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5540. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5541. for _, item := range queryResult {
  5542. 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)
  5543. //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)
  5544. }
  5545. }
  5546. func (c *HisApiController) Projectcheck() {
  5547. admin_user_id, _ := c.GetInt64("admin_user_id")
  5548. adminUser := c.GetAdminUserInfo()
  5549. var queryResult []QueryResult
  5550. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5551. for _, item := range projects {
  5552. result := QueryResult{
  5553. ID: item.ID,
  5554. Name: item.ProjectName,
  5555. Code: item.MedicalCode,
  5556. List_type_code: "201",
  5557. }
  5558. queryResult = append(queryResult, result)
  5559. }
  5560. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5561. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5562. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5563. for _, item := range queryResult {
  5564. 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)
  5565. }
  5566. }
  5567. //func (c *HisApiController)CancleDia(){
  5568. //
  5569. // id, _ := c.GetInt64("id")
  5570. // record_time := c.GetString("record_time")
  5571. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5572. //
  5573. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5574. //
  5575. // diagnosis_id := c.GetString("diagnosis")
  5576. // sick_type, _ := c.GetInt64("sick_type")
  5577. // reg_type, _ := c.GetInt64("p_type")
  5578. // begin_time := c.GetString("begin_time")
  5579. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5580. //
  5581. //
  5582. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5583. //
  5584. // fmt.Println(acct_used_flag)
  5585. //
  5586. //
  5587. // timeLayout := "2006-01-02"
  5588. // loc, _ := time.LoadLocation("Local")
  5589. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5590. // if err != nil {
  5591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5592. // return
  5593. // }
  5594. // recordDateTime := theTime.Unix()
  5595. // adminUser := c.GetAdminUserInfo()
  5596. //
  5597. //
  5598. //
  5599. //
  5600. //
  5601. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5602. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5603. // var patientPrescription models.HisPrescriptionInfo
  5604. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5605. // if patientPrescription.ID == 0 {
  5606. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5607. // }
  5608. // //if patientPrescription.Do
  5609. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5610. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5611. //
  5612. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5613. //
  5614. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5615. //
  5616. // var config []*models.HisXtDiagnoseConfig
  5617. // for _, item := range diagnosis_ids {
  5618. // id, _ := strconv.ParseInt(item, 10, 64)
  5619. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5620. // config = append(config, &diagnosisConfig)
  5621. // }
  5622. //
  5623. // sickConfig, _ := service.FindSickById(sick_type)
  5624. //
  5625. //
  5626. // data := make(map[string]interface{})
  5627. // client := &http.Client{}
  5628. // data["psn_no"] = his.PsnNo
  5629. // data["mdtrt_id"] = his.Number
  5630. // data["doctor"] = roles.UserName
  5631. // data["department"] = department.Name
  5632. // data["org_name"] = miConfig.OrgName
  5633. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5634. // data["doctor_id"] = doctor_info.DoctorNumber
  5635. // data["new_doctor_name"] = doctor_info.UserName
  5636. // data["fixmedins_code"] = miConfig.Code
  5637. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5638. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5639. // data["secret_key"] = miConfig.SecretKey
  5640. // data["sick_code"] = sickConfig.CountryCode
  5641. // data["sick_name"] = sickConfig.ClassName
  5642. // data["url"] = miConfig.Url
  5643. // data["ak"] = miConfig.AccessKey
  5644. // data["begin_time"] = begin_time
  5645. // data["cainfo"] = miConfig.Cainfo
  5646. // data["is_vaild"] = "0"
  5647. //
  5648. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5649. // data["config"] = config
  5650. // bytesData, _ := json.Marshal(data)
  5651. //
  5652. // var req *http.Request
  5653. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5654. // resp, _ := client.Do(req)
  5655. // defer resp.Body.Close()
  5656. // body, ioErr := ioutil.ReadAll(resp.Body)
  5657. // if ioErr != nil {
  5658. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5660. // return
  5661. // }
  5662. // var respJSON map[string]interface{}
  5663. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5664. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5666. // return
  5667. // }
  5668. //
  5669. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5670. // userJSONBytes, _ := json.Marshal(respJSON)
  5671. // fmt.Println("log")
  5672. // fmt.Println(string(userJSONBytes))
  5673. //
  5674. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5675. // utils.ErrorLog("解析失败:%v", err)
  5676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5677. // return
  5678. // }
  5679. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5680. // res2.Output = ressix10265.Output
  5681. // res2.ErrMsg = ressix10265.ErrMsg
  5682. // res2.Cainfo = ressix10265.Cainfo
  5683. // res2.WarnMsg = ressix10265.WarnMsg
  5684. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5685. // res2.Infcode = infocode
  5686. //
  5687. //}
  5688. func (c *HisApiController) Get4102() {
  5689. order_id, _ := c.GetInt64("order_id")
  5690. admin_user_id, _ := c.GetInt64("admin_user_id")
  5691. stas_type := c.GetString("stas_type")
  5692. order, _ := service.GetHisOrderByIDTwo(order_id)
  5693. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5694. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5695. var pp models.PublicParams
  5696. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5697. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5698. pp.FixmedinsName = miConfig.OrgName
  5699. pp.FixmedinsCode = miConfig.Code
  5700. pp.RequestUrl = miConfig.Url
  5701. pp.Cainfo = miConfig.Cainfo
  5702. pp.SecretKey = miConfig.SecretKey
  5703. pp.AccessKey = miConfig.AccessKey
  5704. pp.OpterName = curRoles.UserName
  5705. if miConfig.MdtrtareaAdmvs == "350500" {
  5706. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5707. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5708. saveLog(result, request, "4102", "清单确认")
  5709. var dat map[string]interface{}
  5710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5711. fmt.Println(dat)
  5712. } else {
  5713. fmt.Println(err)
  5714. }
  5715. var empty ResultFourteen
  5716. userJSONBytes, _ := json.Marshal(dat)
  5717. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5718. utils.ErrorLog("解析失败:%v", err)
  5719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5720. return
  5721. }
  5722. if empty.Infcode == 0 {
  5723. c.ServeSuccessJSON(map[string]interface{}{
  5724. "msg": "确认成功",
  5725. })
  5726. return
  5727. }
  5728. } else {
  5729. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5730. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5731. result3, request3 := service.Jxyb4105(pp)
  5732. saveLog(result, request, "4102", "清单确认")
  5733. saveLog(result2, request2, "4103", "清单确认")
  5734. saveLog(result3, request3, "4105", "清单统计")
  5735. var dat map[string]interface{}
  5736. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5737. fmt.Println(dat)
  5738. } else {
  5739. fmt.Println(err)
  5740. }
  5741. var empty ResultFourteen
  5742. userJSONBytes, _ := json.Marshal(dat)
  5743. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5744. utils.ErrorLog("解析失败:%v", err)
  5745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5746. return
  5747. }
  5748. if empty.Infcode == 0 {
  5749. c.ServeSuccessJSON(map[string]interface{}{
  5750. "msg": "确认成功",
  5751. })
  5752. return
  5753. }
  5754. }
  5755. }
  5756. // 对账权限查询
  5757. func (c *HisApiController) Get3260() {
  5758. admin_user_id, _ := c.GetInt64("admin_user_id")
  5759. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5760. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5761. var api string
  5762. var res models.JSResult3260
  5763. if miConfig.MdtrtareaAdmvs == "320921" {
  5764. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5765. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5766. } else {
  5767. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5768. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5769. }
  5770. resp, requestErr := http.Get(api)
  5771. if requestErr != nil {
  5772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5773. return
  5774. }
  5775. body, ioErr := ioutil.ReadAll(resp.Body)
  5776. if ioErr != nil {
  5777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5779. return
  5780. }
  5781. var respJSON map[string]interface{}
  5782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5785. return
  5786. }
  5787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5788. result, _ := json.Marshal(respJSON)
  5789. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5790. utils.ErrorLog("解析失败:%v", err)
  5791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5792. return
  5793. }
  5794. if res.Infcode == "0" {
  5795. c.ServeSuccessJSON(map[string]interface{}{
  5796. "result": res.Output.Data,
  5797. })
  5798. } else {
  5799. c.ServeSuccessJSON(map[string]interface{}{
  5800. "failed_code": -10,
  5801. "msg": res.ErrMsg,
  5802. })
  5803. return
  5804. }
  5805. }
  5806. func (c *HisApiController) Get3261() {
  5807. admin_user_id, _ := c.GetInt64("admin_user_id")
  5808. //month := c.GetString("month")
  5809. startTime := c.GetString("start_time")
  5810. //endTime, _ := c.GetString("end_time")
  5811. times := strings.Split(startTime, "-")
  5812. stmt_mon := times[0] + times[1]
  5813. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5814. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5815. var api string
  5816. var res models.JSResult3261
  5817. //var res10265 Result5301For10265
  5818. if miConfig.MdtrtareaAdmvs == "320921" {
  5819. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5820. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5821. } else {
  5822. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5823. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5824. }
  5825. resp, requestErr := http.Get(api)
  5826. if requestErr != nil {
  5827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5828. return
  5829. }
  5830. body, ioErr := ioutil.ReadAll(resp.Body)
  5831. if ioErr != nil {
  5832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5834. return
  5835. }
  5836. var respJSON map[string]interface{}
  5837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5840. return
  5841. }
  5842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5843. result, _ := json.Marshal(respJSON)
  5844. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5845. utils.ErrorLog("解析失败:%v", err)
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5847. return
  5848. }
  5849. if res.Infcode == "0" {
  5850. c.ServeSuccessJSON(map[string]interface{}{
  5851. "result": res.Output,
  5852. })
  5853. } else {
  5854. c.ServeSuccessJSON(map[string]interface{}{
  5855. "failed_code": -10,
  5856. "msg": res.ErrMsg,
  5857. })
  5858. return
  5859. }
  5860. }
  5861. type TempFun struct {
  5862. FundKey string
  5863. FundCode string
  5864. }
  5865. func (c *HisApiController) Get3262() {
  5866. admin_user_id, _ := c.GetInt64("admin_user_id")
  5867. startTime := c.GetString("start_time")
  5868. endTime := c.GetString("end_time")
  5869. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5870. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5871. //timeLayout := "2006-01-02"
  5872. //loc, _ := time.LoadLocation("Local")
  5873. //var theStartTIme int64
  5874. //if len(startTime) > 0 {
  5875. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5876. // if err != nil {
  5877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5878. // return
  5879. // }
  5880. // theStartTIme = theTime.Unix()
  5881. //}
  5882. //var theEndtTIme int64
  5883. //if len(endTime) > 0 {
  5884. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5885. // if err != nil {
  5886. // utils.ErrorLog(err.Error())
  5887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5888. // return
  5889. // }
  5890. // theEndtTIme = theTime.Unix()
  5891. //}
  5892. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5893. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5894. for _, team := range datas {
  5895. fmt.Println(team.PsnTime)
  5896. for _, team_two := range datas_two {
  5897. fmt.Println(team_two.PsnTime)
  5898. if team.FundKey == team_two.FundKey {
  5899. fmt.Println(team_two.PsnTime)
  5900. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5901. fmt.Println(team.PsnTime)
  5902. }
  5903. }
  5904. }
  5905. fmt.Println("1111")
  5906. fmt.Println(datas)
  5907. fmt.Println("1111")
  5908. var twos []models.FixMonRecDetailFileInTwo
  5909. for _, team := range datas {
  5910. var two models.FixMonRecDetailFileInTwo
  5911. two.MedType = team.MedType
  5912. two.Insutype = team.Insutype
  5913. two.PsnType = team.PsnType
  5914. two.MedType = team.MedType
  5915. two.FixBlngAdmdvs = "999999"
  5916. two.InsuAdmdvs = "555555"
  5917. two.PsnTime = team.PsnTime
  5918. two.PsnCnt = team.PsnCnt
  5919. two.FundKey = team.FundKey
  5920. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5921. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5922. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5923. two.MedfeeSumAmt = ms
  5924. two.InscpAmt = ia
  5925. two.FundPaySumAmt = fps
  5926. twos = append(twos, two)
  5927. }
  5928. //startTime := c.GetString("start_time")
  5929. //endTime, _ := c.GetString("end_time")
  5930. times := strings.Split(startTime, "-")
  5931. stmt_mon := times[0] + times[1]
  5932. var funs []models.FundDetail
  5933. for _, item := range datas {
  5934. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5935. funs = append(funs, fun...)
  5936. }
  5937. var funInfos []models.Fund
  5938. //for _, item := range funs {
  5939. // var rf []models.FundInfo
  5940. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5941. // for _, subitem := range rf {
  5942. // var fund models.Fund
  5943. // fund.FundCode = subitem.FundPayType
  5944. // fund.FundName = subitem.FundPayTypeName
  5945. // fund.FundAmt = subitem.FundPayAmt
  5946. // fund.FundKey = item.FundKey
  5947. // fund.InsuAdmdvs = "555555"
  5948. // fund.FixBlngAdmdvs = "999999"
  5949. // funInfos = append(funInfos, fund)
  5950. // }
  5951. //}
  5952. var tempFuns []TempFun
  5953. for _, funInfo := range funInfos {
  5954. var tempFun TempFun
  5955. tempFun.FundKey = funInfo.FundKey
  5956. tempFun.FundCode = funInfo.FundCode
  5957. tempFuns = append(tempFuns, tempFun)
  5958. }
  5959. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5960. fmt.Println(tempFuns)
  5961. var funInfosTwo []models.Fund
  5962. decimal.DivisionPrecision = 2
  5963. for _, item := range tempFuns {
  5964. var fund models.Fund
  5965. for _, subItem := range funInfos {
  5966. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5967. fund.FundKey = subItem.FundKey
  5968. fund.InsuAdmdvs = subItem.InsuAdmdvs
  5969. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  5970. fund.FundName = subItem.FundName
  5971. fund.FundCode = subItem.FundCode
  5972. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  5973. }
  5974. }
  5975. funInfosTwo = append(funInfosTwo, fund)
  5976. }
  5977. fmt.Println("funInfosTwo")
  5978. fmt.Println(funInfosTwo)
  5979. var upld_btch string
  5980. var empty models.JSResultEmpty
  5981. data := make(map[string]interface{})
  5982. data["org_name"] = miConfig.OrgName
  5983. data["doctor"] = curRoles.UserName
  5984. data["doctor_name"] = curRoles.UserName
  5985. data["fixmedins_code"] = miConfig.Code
  5986. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5987. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5988. data["secret_key"] = miConfig.SecretKey
  5989. data["url"] = miConfig.Url
  5990. data["ak"] = miConfig.AccessKey
  5991. data["cainfo"] = miConfig.Cainfo
  5992. data["datas"] = twos
  5993. data["fund"] = funInfosTwo
  5994. fmt.Println(twos)
  5995. month := time.Unix(1557042972, 0).Format("1")
  5996. year := time.Now().Format("2006")
  5997. month = time.Now().Format("01")
  5998. day := time.Now().Format("02")
  5999. hour := time.Now().Format("15")
  6000. min := time.Now().Format("04")
  6001. sec := time.Now().Format("05")
  6002. fix_fill_date := year + month + day + hour + min + sec
  6003. data["fix_fill_dept"] = miConfig.OrgName
  6004. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6005. data["fix_fill_psn"] = curRoles.UserName
  6006. data["fix_fill_date"] = fix_fill_date
  6007. data["stmt_loc"] = "2"
  6008. data["setl_mon"] = stmt_mon
  6009. upld_btch = "0"
  6010. data["upld_btch"] = upld_btch
  6011. //fmt.Println(data)
  6012. client := &http.Client{}
  6013. bytesData, _ := json.Marshal(data)
  6014. var req *http.Request
  6015. if miConfig.MdtrtareaAdmvs == "320921" {
  6016. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6017. } else {
  6018. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6019. }
  6020. resp, _ := client.Do(req)
  6021. defer resp.Body.Close()
  6022. body, ioErr := ioutil.ReadAll(resp.Body)
  6023. if ioErr != nil {
  6024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6026. }
  6027. var respJSON map[string]interface{}
  6028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6031. }
  6032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6033. //fmt.Println(respJSON)
  6034. result, _ := json.Marshal(respJSON)
  6035. //fmt.Println(result)
  6036. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6037. utils.ErrorLog("解析失败:%v", err)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. }
  6040. if empty.Infcode != "0" {
  6041. c.ServeSuccessJSON(map[string]interface{}{
  6042. "failed_code": -10,
  6043. "msg": empty.ErrMsg,
  6044. })
  6045. return
  6046. } else {
  6047. c.ServeSuccessJSON(map[string]interface{}{
  6048. "msg": "上传成功",
  6049. })
  6050. return
  6051. }
  6052. }
  6053. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6054. newArr = make([]TempFun, 0)
  6055. for i := 0; i < len(arr); i++ {
  6056. repeat := false
  6057. for j := i + 1; j < len(arr); j++ {
  6058. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6059. repeat = true
  6060. break
  6061. }
  6062. }
  6063. if !repeat {
  6064. newArr = append(newArr, arr[i])
  6065. }
  6066. }
  6067. return
  6068. }
  6069. func (c *HisApiController) Get3263() {
  6070. admin_user_id, _ := c.GetInt64("admin_user_id")
  6071. startTime := c.GetString("start_time")
  6072. //endTime, _ := c.GetString("end_time")
  6073. times := strings.Split(startTime, "-")
  6074. setl_mon := times[0] + times[1]
  6075. upld_btch := "0"
  6076. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6077. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6078. var result3263 models.JSResult3263
  6079. data := make(map[string]interface{})
  6080. data["org_name"] = miConfig.OrgName
  6081. data["doctor"] = curRoles.UserName
  6082. data["doctor_name"] = curRoles.UserName
  6083. data["fixmedins_code"] = miConfig.Code
  6084. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6085. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6086. data["secret_key"] = miConfig.SecretKey
  6087. data["url"] = miConfig.Url
  6088. data["ak"] = miConfig.AccessKey
  6089. data["cainfo"] = miConfig.Cainfo
  6090. data["setl_mon"] = setl_mon
  6091. data["stmt_loc"] = "2"
  6092. data["upld_btch"] = upld_btch
  6093. client := &http.Client{}
  6094. bytesData, _ := json.Marshal(data)
  6095. var req *http.Request
  6096. if miConfig.MdtrtareaAdmvs == "320921" {
  6097. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6098. } else {
  6099. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6100. }
  6101. resp, _ := client.Do(req)
  6102. defer resp.Body.Close()
  6103. body, ioErr := ioutil.ReadAll(resp.Body)
  6104. if ioErr != nil {
  6105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6107. }
  6108. var respJSON map[string]interface{}
  6109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6112. }
  6113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6114. fmt.Println(respJSON)
  6115. result, _ := json.Marshal(respJSON)
  6116. fmt.Println(result)
  6117. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6118. utils.ErrorLog("解析失败:%v", err)
  6119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. }
  6121. if result3263.Infcode != "0" {
  6122. c.ServeSuccessJSON(map[string]interface{}{
  6123. "failed_code": -10,
  6124. "msg": result3263.ErrMsg,
  6125. })
  6126. return
  6127. } else {
  6128. c.ServeSuccessJSON(map[string]interface{}{
  6129. "list": result3263.Output,
  6130. })
  6131. return
  6132. }
  6133. }
  6134. func (c *HisApiController) Get3264() {
  6135. admin_user_id, _ := c.GetInt64("admin_user_id")
  6136. startTime := c.GetString("start_time")
  6137. //endTime, _ := c.GetString("end_time")
  6138. times := strings.Split(startTime, "-")
  6139. setl_mon := times[0] + times[1]
  6140. upld_btch := "0"
  6141. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6142. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6143. //solidify_id := []
  6144. var result3263 models.JSResult3263
  6145. data := make(map[string]interface{})
  6146. data["org_name"] = miConfig.OrgName
  6147. data["doctor"] = curRoles.UserName
  6148. data["doctor_name"] = curRoles.UserName
  6149. data["fixmedins_code"] = miConfig.Code
  6150. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6151. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6152. data["secret_key"] = miConfig.SecretKey
  6153. data["url"] = miConfig.Url
  6154. data["ak"] = miConfig.AccessKey
  6155. data["cainfo"] = miConfig.Cainfo
  6156. data["setl_mon"] = setl_mon
  6157. data["stmt_loc"] = "2"
  6158. data["upld_btch"] = upld_btch
  6159. client := &http.Client{}
  6160. bytesData, _ := json.Marshal(data)
  6161. var req3263 *http.Request
  6162. if miConfig.MdtrtareaAdmvs == "320921" {
  6163. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6164. } else {
  6165. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6166. }
  6167. resp, _ := client.Do(req3263)
  6168. defer resp.Body.Close()
  6169. body, ioErr := ioutil.ReadAll(resp.Body)
  6170. if ioErr != nil {
  6171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6173. }
  6174. var respJSON3263 map[string]interface{}
  6175. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6178. }
  6179. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6180. fmt.Println(respJSON3263)
  6181. result, _ := json.Marshal(respJSON3263)
  6182. fmt.Println(result)
  6183. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6184. utils.ErrorLog("解析失败:%v", err)
  6185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6186. }
  6187. var ids []string
  6188. for _, item := range result3263.Output {
  6189. ids = append(ids, item.SolidifyID)
  6190. }
  6191. var empty models.JSResultEmpty
  6192. data2 := make(map[string]interface{})
  6193. data2["org_name"] = miConfig.OrgName
  6194. data2["doctor"] = curRoles.UserName
  6195. data2["doctor_name"] = curRoles.UserName
  6196. data2["fixmedins_code"] = miConfig.Code
  6197. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6198. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6199. data2["secret_key"] = miConfig.SecretKey
  6200. data2["url"] = miConfig.Url
  6201. data2["ak"] = miConfig.AccessKey
  6202. data2["cainfo"] = miConfig.Cainfo
  6203. data2["setl_mon"] = setl_mon
  6204. data2["stmt_loc"] = "2"
  6205. data2["upld_btch"] = upld_btch
  6206. data2["solidify_id"] = ids
  6207. client2 := &http.Client{}
  6208. bytesData2, _ := json.Marshal(data2)
  6209. var req *http.Request
  6210. if miConfig.MdtrtareaAdmvs == "320921" {
  6211. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6212. } else {
  6213. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6214. }
  6215. resp2, _ := client2.Do(req)
  6216. defer resp.Body.Close()
  6217. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6218. if ioErr2 != nil {
  6219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6221. }
  6222. var respJSON map[string]interface{}
  6223. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6226. }
  6227. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6228. fmt.Println(respJSON)
  6229. result2, _ := json.Marshal(respJSON)
  6230. fmt.Println(result2)
  6231. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6232. utils.ErrorLog("解析失败:%v", err)
  6233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6234. }
  6235. if empty.Infcode != "0" {
  6236. c.ServeSuccessJSON(map[string]interface{}{
  6237. "failed_code": -10,
  6238. "msg": empty.ErrMsg,
  6239. })
  6240. return
  6241. } else {
  6242. c.ServeSuccessJSON(map[string]interface{}{
  6243. "msg": "",
  6244. })
  6245. return
  6246. }
  6247. }
  6248. func (c *HisApiController) Get3265() {
  6249. admin_user_id, _ := c.GetInt64("admin_user_id")
  6250. startTime := c.GetString("start_time")
  6251. //endTime, _ := c.GetString("end_time")
  6252. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6253. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6254. times := strings.Split(startTime, "-")
  6255. setl_mon := times[0] + times[1]
  6256. var upld_btch string
  6257. upld_btch = "0"
  6258. //var empty models.JSResultEmpty
  6259. var result3265 models.JSResult3264
  6260. var result3263 models.JSResult3263
  6261. data2 := make(map[string]interface{})
  6262. data2["org_name"] = miConfig.OrgName
  6263. data2["doctor"] = curRoles.UserName
  6264. data2["doctor_name"] = curRoles.UserName
  6265. data2["fixmedins_code"] = miConfig.Code
  6266. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6267. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6268. data2["secret_key"] = miConfig.SecretKey
  6269. data2["url"] = miConfig.Url
  6270. data2["ak"] = miConfig.AccessKey
  6271. data2["cainfo"] = miConfig.Cainfo
  6272. data2["setl_mon"] = setl_mon
  6273. data2["stmt_loc"] = "2"
  6274. data2["upld_btch"] = upld_btch
  6275. client2 := &http.Client{}
  6276. bytesData2, _ := json.Marshal(data2)
  6277. var req3263 *http.Request
  6278. if miConfig.MdtrtareaAdmvs == "320921" {
  6279. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6280. } else {
  6281. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6282. }
  6283. resp2, _ := client2.Do(req3263)
  6284. defer resp2.Body.Close()
  6285. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6286. if ioErr2 != nil {
  6287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6289. }
  6290. var respJSON3263 map[string]interface{}
  6291. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6294. }
  6295. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6296. fmt.Println(respJSON3263)
  6297. result2, _ := json.Marshal(respJSON3263)
  6298. fmt.Println(result2)
  6299. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6300. utils.ErrorLog("解析失败:%v", err)
  6301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6302. }
  6303. var ids []string
  6304. for _, item := range result3263.Output {
  6305. ids = append(ids, item.SolidifyID)
  6306. }
  6307. data := make(map[string]interface{})
  6308. data["org_name"] = miConfig.OrgName
  6309. data["doctor"] = curRoles.UserName
  6310. data["doctor_name"] = curRoles.UserName
  6311. data["fixmedins_code"] = miConfig.Code
  6312. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6313. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6314. data["secret_key"] = miConfig.SecretKey
  6315. data["url"] = miConfig.Url
  6316. data["ak"] = miConfig.AccessKey
  6317. data["cainfo"] = miConfig.Cainfo
  6318. data["setl_mon"] = setl_mon
  6319. data["solidify_id"] = ids
  6320. month := time.Unix(1557042972, 0).Format("1")
  6321. year := time.Now().Format("2006")
  6322. month = time.Now().Format("01")
  6323. day := time.Now().Format("02")
  6324. hour := time.Now().Format("15")
  6325. min := time.Now().Format("04")
  6326. sec := time.Now().Format("05")
  6327. fix_fill_date := year + month + day + hour + min + sec
  6328. data["fix_fill_dept"] = miConfig.OrgName
  6329. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6330. data["fix_fill_psn"] = curRoles.UserName
  6331. data["fix_fill_date"] = fix_fill_date
  6332. data["stmt_loc"] = "2"
  6333. data["upld_btch"] = upld_btch
  6334. client := &http.Client{}
  6335. bytesData, _ := json.Marshal(data)
  6336. var req *http.Request
  6337. if miConfig.MdtrtareaAdmvs == "320921" {
  6338. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6339. } else {
  6340. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6341. }
  6342. resp, _ := client.Do(req)
  6343. defer resp.Body.Close()
  6344. body, ioErr := ioutil.ReadAll(resp.Body)
  6345. if ioErr != nil {
  6346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6348. }
  6349. var respJSON map[string]interface{}
  6350. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6353. }
  6354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6355. fmt.Println(respJSON)
  6356. result, _ := json.Marshal(respJSON)
  6357. fmt.Println(result)
  6358. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6359. utils.ErrorLog("解析失败:%v", err)
  6360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6361. }
  6362. if result3265.Infcode != "0" {
  6363. c.ServeSuccessJSON(map[string]interface{}{
  6364. "failed_code": -10,
  6365. "msg": result3265.ErrMsg,
  6366. })
  6367. return
  6368. } else {
  6369. c.ServeSuccessJSON(map[string]interface{}{
  6370. "info": result3265.Output,
  6371. })
  6372. return
  6373. }
  6374. }
  6375. func (c *HisApiController) Get3266() {
  6376. admin_user_id, _ := c.GetInt64("admin_user_id")
  6377. startTime := c.GetString("start_time")
  6378. //endTime, _ := c.GetString("end_time")
  6379. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6380. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6381. times := strings.Split(startTime, "-")
  6382. stmt_mon := times[0] + times[1]
  6383. var upld_btch string
  6384. //var empty models.JSResultEmpty
  6385. var result3265 models.JSResult3264
  6386. data := make(map[string]interface{})
  6387. data["org_name"] = miConfig.OrgName
  6388. data["doctor"] = curRoles.UserName
  6389. data["doctor_name"] = curRoles.UserName
  6390. data["fixmedins_code"] = miConfig.Code
  6391. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6392. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6393. data["secret_key"] = miConfig.SecretKey
  6394. data["url"] = miConfig.Url
  6395. data["ak"] = miConfig.AccessKey
  6396. data["cainfo"] = miConfig.Cainfo
  6397. data["setl_mon"] = stmt_mon
  6398. month := time.Unix(1557042972, 0).Format("1")
  6399. year := time.Now().Format("2006")
  6400. month = time.Now().Format("01")
  6401. day := time.Now().Format("02")
  6402. hour := time.Now().Format("15")
  6403. min := time.Now().Format("04")
  6404. sec := time.Now().Format("05")
  6405. fix_fill_date := year + month + day + hour + min + sec
  6406. data["fix_fill_dept"] = miConfig.OrgName
  6407. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6408. data["fix_fill_psn"] = curRoles.UserName
  6409. data["fix_fill_date"] = fix_fill_date
  6410. data["stmt_loc"] = "2"
  6411. upld_btch = "0"
  6412. data["upld_btch"] = upld_btch
  6413. client := &http.Client{}
  6414. bytesData, _ := json.Marshal(data)
  6415. var req *http.Request
  6416. if miConfig.MdtrtareaAdmvs == "320921" {
  6417. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6418. } else {
  6419. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6420. }
  6421. resp, _ := client.Do(req)
  6422. defer resp.Body.Close()
  6423. body, ioErr := ioutil.ReadAll(resp.Body)
  6424. if ioErr != nil {
  6425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. }
  6428. var respJSON map[string]interface{}
  6429. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6432. }
  6433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6434. fmt.Println(respJSON)
  6435. result, _ := json.Marshal(respJSON)
  6436. fmt.Println(result)
  6437. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6438. utils.ErrorLog("解析失败:%v", err)
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6440. }
  6441. if result3265.Infcode != "0" {
  6442. c.ServeSuccessJSON(map[string]interface{}{
  6443. "failed_code": -10,
  6444. "msg": result3265.ErrMsg,
  6445. })
  6446. return
  6447. } else {
  6448. c.ServeSuccessJSON(map[string]interface{}{
  6449. "info": result3265.Output,
  6450. })
  6451. return
  6452. }
  6453. }
  6454. func (c *HisApiController) Get3267() {
  6455. admin_user_id, _ := c.GetInt64("admin_user_id")
  6456. startTime := c.GetString("start_time")
  6457. //endTime, _ := c.GetString("end_time")
  6458. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6459. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6460. times := strings.Split(startTime, "-")
  6461. setl_mon := times[0] + times[1]
  6462. var upld_btch string
  6463. //var empty models.JSResultEmpty
  6464. var result3265 models.JSResult3264
  6465. upld_btch = "0"
  6466. data := make(map[string]interface{})
  6467. data["org_name"] = miConfig.OrgName
  6468. data["doctor"] = curRoles.UserName
  6469. data["doctor_name"] = curRoles.UserName
  6470. data["fixmedins_code"] = miConfig.Code
  6471. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6472. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6473. data["secret_key"] = miConfig.SecretKey
  6474. data["url"] = miConfig.Url
  6475. data["ak"] = miConfig.AccessKey
  6476. data["cainfo"] = miConfig.Cainfo
  6477. data["setl_mon"] = setl_mon
  6478. data["stmt_loc"] = "2"
  6479. data["upld_btch"] = upld_btch
  6480. client := &http.Client{}
  6481. bytesData, _ := json.Marshal(data)
  6482. var req *http.Request
  6483. if miConfig.MdtrtareaAdmvs == "320921" {
  6484. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6485. } else {
  6486. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6487. }
  6488. resp, _ := client.Do(req)
  6489. defer resp.Body.Close()
  6490. body, ioErr := ioutil.ReadAll(resp.Body)
  6491. if ioErr != nil {
  6492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6494. }
  6495. var respJSON map[string]interface{}
  6496. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6499. }
  6500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6501. fmt.Println(respJSON)
  6502. result, _ := json.Marshal(respJSON)
  6503. fmt.Println(result)
  6504. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6505. utils.ErrorLog("解析失败:%v", err)
  6506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6507. }
  6508. if result3265.Infcode != "0" {
  6509. c.ServeSuccessJSON(map[string]interface{}{
  6510. "failed_code": -10,
  6511. "msg": result3265.ErrMsg,
  6512. })
  6513. return
  6514. } else {
  6515. c.ServeSuccessJSON(map[string]interface{}{
  6516. "info": result3265.Output.Data,
  6517. })
  6518. return
  6519. }
  6520. }
  6521. func (c *HisApiController) Get3268() {
  6522. admin_user_id, _ := c.GetInt64("admin_user_id")
  6523. startTime := c.GetString("start_time")
  6524. endTime := c.GetString("end_time")
  6525. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6526. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6527. times := strings.Split(startTime, "-")
  6528. setl_mon := times[0] + times[1]
  6529. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6530. var twos []models.FixMonRecDetailFileInTwo
  6531. var funs []models.FundDetail
  6532. for _, item := range datas {
  6533. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6534. funs = append(funs, fun...)
  6535. }
  6536. var funInfos []models.Fund
  6537. //for _, item := range funs {
  6538. // var rf []models.FundInfo
  6539. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6540. // for _, subitem := range rf {
  6541. // var fund models.Fund
  6542. // fund.FundCode = subitem.FundPayType
  6543. // fund.FundName = subitem.FundPayTypeName
  6544. // fund.FundAmt = subitem.FundPayAmt
  6545. // fund.FundKey = item.FundKey
  6546. // fund.InsuAdmdvs = "555555"
  6547. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6548. // funInfos = append(funInfos, fund)
  6549. // }
  6550. //}
  6551. for _, team := range datas {
  6552. var two models.FixMonRecDetailFileInTwo
  6553. two.SetlDate = time.Now().Format("2006-01-02")
  6554. two.MedType = team.MedType
  6555. two.Insutype = team.Insutype
  6556. two.PsnType = team.PsnType
  6557. two.MedType = team.MedType
  6558. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6559. two.InsuAdmdvs = team.InsuAdmdvs
  6560. two.PsnTime = team.PsnTime
  6561. two.PsnCnt = team.PsnCnt
  6562. two.FundKey = team.FundKey
  6563. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6564. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6565. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6566. two.MedfeeSumAmt = ms
  6567. two.InscpAmt = ia
  6568. two.FundPaySumAmt = fps
  6569. twos = append(twos, two)
  6570. }
  6571. var upld_btch string
  6572. upld_btch = "0"
  6573. var empty models.JSResultEmpty
  6574. data := make(map[string]interface{})
  6575. data["org_name"] = miConfig.OrgName
  6576. data["doctor"] = curRoles.UserName
  6577. data["doctor_name"] = curRoles.UserName
  6578. data["fixmedins_code"] = miConfig.Code
  6579. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6580. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6581. data["secret_key"] = miConfig.SecretKey
  6582. data["url"] = miConfig.Url
  6583. data["ak"] = miConfig.AccessKey
  6584. data["cainfo"] = miConfig.Cainfo
  6585. data["datas"] = twos
  6586. data["fund"] = funInfos
  6587. data["setl_mon"] = setl_mon
  6588. month := time.Unix(1557042972, 0).Format("1")
  6589. year := time.Now().Format("2006")
  6590. month = time.Now().Format("01")
  6591. day := time.Now().Format("02")
  6592. hour := time.Now().Format("15")
  6593. min := time.Now().Format("04")
  6594. sec := time.Now().Format("05")
  6595. fix_fill_date := year + month + day + hour + min + sec
  6596. data["fix_fill_dept"] = miConfig.OrgName
  6597. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6598. data["fix_fill_psn"] = curRoles.UserName
  6599. data["fix_fill_date"] = fix_fill_date
  6600. data["stmt_loc"] = "2"
  6601. data["upld_btch"] = upld_btch
  6602. client := &http.Client{}
  6603. bytesData, _ := json.Marshal(data)
  6604. var req *http.Request
  6605. if miConfig.MdtrtareaAdmvs == "320921" {
  6606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6607. } else {
  6608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6609. }
  6610. resp, _ := client.Do(req)
  6611. defer resp.Body.Close()
  6612. body, ioErr := ioutil.ReadAll(resp.Body)
  6613. if ioErr != nil {
  6614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. }
  6617. var respJSON map[string]interface{}
  6618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6621. }
  6622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6623. fmt.Println(respJSON)
  6624. result, _ := json.Marshal(respJSON)
  6625. fmt.Println(result)
  6626. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6627. utils.ErrorLog("解析失败:%v", err)
  6628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6629. }
  6630. if empty.Infcode != "0" {
  6631. c.ServeSuccessJSON(map[string]interface{}{
  6632. "failed_code": -10,
  6633. "msg": empty.ErrMsg,
  6634. })
  6635. return
  6636. } else {
  6637. c.ServeSuccessJSON(map[string]interface{}{
  6638. "msg": "上传成功",
  6639. })
  6640. return
  6641. }
  6642. }
  6643. func (c *HisApiController) Get3269() {
  6644. admin_user_id, _ := c.GetInt64("admin_user_id")
  6645. startTime := c.GetString("start_time")
  6646. //endTime, _ := c.GetString("end_time")
  6647. times := strings.Split(startTime, "-")
  6648. setl_mon := times[0] + times[1]
  6649. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6651. var result3263 models.JSResult3263
  6652. data := make(map[string]interface{})
  6653. data["org_name"] = miConfig.OrgName
  6654. data["doctor"] = curRoles.UserName
  6655. data["doctor_name"] = curRoles.UserName
  6656. data["fixmedins_code"] = miConfig.Code
  6657. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6658. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6659. data["secret_key"] = miConfig.SecretKey
  6660. data["url"] = miConfig.Url
  6661. data["ak"] = miConfig.AccessKey
  6662. data["cainfo"] = miConfig.Cainfo
  6663. data["setl_mon"] = setl_mon
  6664. data["stmt_loc"] = "2"
  6665. client := &http.Client{}
  6666. bytesData, _ := json.Marshal(data)
  6667. var req *http.Request
  6668. if miConfig.MdtrtareaAdmvs == "320921" {
  6669. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6670. } else {
  6671. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6672. }
  6673. resp, _ := client.Do(req)
  6674. defer resp.Body.Close()
  6675. body, ioErr := ioutil.ReadAll(resp.Body)
  6676. if ioErr != nil {
  6677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. }
  6680. var respJSON map[string]interface{}
  6681. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6684. }
  6685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6686. fmt.Println(respJSON)
  6687. result, _ := json.Marshal(respJSON)
  6688. fmt.Println(result)
  6689. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6690. utils.ErrorLog("解析失败:%v", err)
  6691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6692. }
  6693. if result3263.Infcode != "0" {
  6694. c.ServeSuccessJSON(map[string]interface{}{
  6695. "failed_code": -10,
  6696. "msg": result3263.ErrMsg,
  6697. })
  6698. return
  6699. } else {
  6700. c.ServeSuccessJSON(map[string]interface{}{
  6701. "msg": "上传成功",
  6702. })
  6703. return
  6704. }
  6705. }
  6706. func (c *HisApiController) Get3270() {
  6707. admin_user_id, _ := c.GetInt64("admin_user_id")
  6708. startTime := c.GetString("start_time")
  6709. //endTime, _ := c.GetString("end_time")
  6710. times := strings.Split(startTime, "-")
  6711. setl_mon := times[0] + times[1]
  6712. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6713. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6714. var result3263 models.JSResult3263
  6715. data2 := make(map[string]interface{})
  6716. data2["org_name"] = miConfig.OrgName
  6717. data2["doctor"] = curRoles.UserName
  6718. data2["doctor_name"] = curRoles.UserName
  6719. data2["fixmedins_code"] = miConfig.Code
  6720. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6721. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6722. data2["secret_key"] = miConfig.SecretKey
  6723. data2["url"] = miConfig.Url
  6724. data2["ak"] = miConfig.AccessKey
  6725. data2["cainfo"] = miConfig.Cainfo
  6726. data2["setl_mon"] = setl_mon
  6727. data2["stmt_loc"] = "2"
  6728. client2 := &http.Client{}
  6729. bytesData2, _ := json.Marshal(data2)
  6730. var req3263 *http.Request
  6731. if miConfig.MdtrtareaAdmvs == "320921" {
  6732. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6733. } else {
  6734. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6735. }
  6736. resp2, _ := client2.Do(req3263)
  6737. defer resp2.Body.Close()
  6738. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6739. if ioErr2 != nil {
  6740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6742. }
  6743. var respJSON3263 map[string]interface{}
  6744. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6747. }
  6748. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6749. fmt.Println(respJSON3263)
  6750. result2, _ := json.Marshal(respJSON3263)
  6751. fmt.Println(result2)
  6752. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6753. utils.ErrorLog("解析失败:%v", err)
  6754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6755. }
  6756. var ids []string
  6757. for _, item := range result3263.Output {
  6758. ids = append(ids, item.SolidifyID)
  6759. }
  6760. var result3264 models.JSResult3264
  6761. data := make(map[string]interface{})
  6762. data["org_name"] = miConfig.OrgName
  6763. data["doctor"] = curRoles.UserName
  6764. data["doctor_name"] = curRoles.UserName
  6765. data["fixmedins_code"] = miConfig.Code
  6766. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6767. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6768. data["secret_key"] = miConfig.SecretKey
  6769. data["url"] = miConfig.Url
  6770. data["ak"] = miConfig.AccessKey
  6771. data["cainfo"] = miConfig.Cainfo
  6772. data["setl_mon"] = setl_mon
  6773. data["stmt_loc"] = "2"
  6774. data["solidify_id"] = ids
  6775. client := &http.Client{}
  6776. bytesData, _ := json.Marshal(data)
  6777. var req *http.Request
  6778. if miConfig.MdtrtareaAdmvs == "320921" {
  6779. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6780. } else {
  6781. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6782. }
  6783. resp, _ := client.Do(req)
  6784. defer resp.Body.Close()
  6785. body, ioErr := ioutil.ReadAll(resp.Body)
  6786. if ioErr != nil {
  6787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6789. }
  6790. var respJSON map[string]interface{}
  6791. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6794. }
  6795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6796. fmt.Println(respJSON)
  6797. result, _ := json.Marshal(respJSON)
  6798. fmt.Println(result)
  6799. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6800. utils.ErrorLog("解析失败:%v", err)
  6801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6802. }
  6803. if result3264.Infcode != "0" {
  6804. c.ServeSuccessJSON(map[string]interface{}{
  6805. "failed_code": -10,
  6806. "msg": result3264.ErrMsg,
  6807. })
  6808. return
  6809. } else {
  6810. c.ServeSuccessJSON(map[string]interface{}{
  6811. "info": result3264.Output,
  6812. })
  6813. return
  6814. }
  6815. }
  6816. func (c *HisApiController) Get3271() {
  6817. admin_user_id, _ := c.GetInt64("admin_user_id")
  6818. startTime := c.GetString("start_time")
  6819. //endTime, _ := c.GetString("end_time")
  6820. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6821. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6822. times := strings.Split(startTime, "-")
  6823. setl_mon := times[0] + times[1]
  6824. //var empty models.JSResultEmpty
  6825. var result3265 models.JSResult3264
  6826. var result3263 models.JSResult3263
  6827. data2 := make(map[string]interface{})
  6828. data2["org_name"] = miConfig.OrgName
  6829. data2["doctor"] = curRoles.UserName
  6830. data2["doctor_name"] = curRoles.UserName
  6831. data2["fixmedins_code"] = miConfig.Code
  6832. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6833. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6834. data2["secret_key"] = miConfig.SecretKey
  6835. data2["url"] = miConfig.Url
  6836. data2["ak"] = miConfig.AccessKey
  6837. data2["cainfo"] = miConfig.Cainfo
  6838. data2["setl_mon"] = setl_mon
  6839. data2["stmt_loc"] = "2"
  6840. client2 := &http.Client{}
  6841. bytesData2, _ := json.Marshal(data2)
  6842. var req3263 *http.Request
  6843. if miConfig.MdtrtareaAdmvs == "320921" {
  6844. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6845. } else {
  6846. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6847. }
  6848. resp2, _ := client2.Do(req3263)
  6849. defer resp2.Body.Close()
  6850. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6851. if ioErr2 != nil {
  6852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. }
  6855. var respJSON3263 map[string]interface{}
  6856. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6859. }
  6860. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6861. fmt.Println(respJSON3263)
  6862. result2, _ := json.Marshal(respJSON3263)
  6863. fmt.Println(result2)
  6864. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6865. utils.ErrorLog("解析失败:%v", err)
  6866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6867. }
  6868. var ids []string
  6869. for _, item := range result3263.Output {
  6870. ids = append(ids, item.SolidifyID)
  6871. }
  6872. data := make(map[string]interface{})
  6873. data["org_name"] = miConfig.OrgName
  6874. data["doctor"] = curRoles.UserName
  6875. data["doctor_name"] = curRoles.UserName
  6876. data["fixmedins_code"] = miConfig.Code
  6877. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6878. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6879. data["secret_key"] = miConfig.SecretKey
  6880. data["url"] = miConfig.Url
  6881. data["ak"] = miConfig.AccessKey
  6882. data["cainfo"] = miConfig.Cainfo
  6883. data["setl_mon"] = setl_mon
  6884. data["solidify_id"] = ids
  6885. month := time.Unix(1557042972, 0).Format("1")
  6886. year := time.Now().Format("2006")
  6887. month = time.Now().Format("01")
  6888. day := time.Now().Format("02")
  6889. hour := time.Now().Format("15")
  6890. min := time.Now().Format("04")
  6891. sec := time.Now().Format("05")
  6892. fix_fill_date := year + month + day + hour + min + sec
  6893. data["fix_fill_dept"] = miConfig.OrgName
  6894. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6895. data["fix_fill_psn"] = curRoles.UserName
  6896. data["fix_fill_date"] = fix_fill_date
  6897. data["stmt_loc"] = "2"
  6898. client := &http.Client{}
  6899. bytesData, _ := json.Marshal(data)
  6900. var req *http.Request
  6901. if miConfig.MdtrtareaAdmvs == "320921" {
  6902. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6903. } else {
  6904. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6905. }
  6906. resp, _ := client.Do(req)
  6907. defer resp.Body.Close()
  6908. body, ioErr := ioutil.ReadAll(resp.Body)
  6909. if ioErr != nil {
  6910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6912. }
  6913. var respJSON map[string]interface{}
  6914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. }
  6918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6919. fmt.Println(respJSON)
  6920. result, _ := json.Marshal(respJSON)
  6921. fmt.Println(result)
  6922. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6923. utils.ErrorLog("解析失败:%v", err)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. }
  6926. if result3265.Infcode != "0" {
  6927. c.ServeSuccessJSON(map[string]interface{}{
  6928. "failed_code": -10,
  6929. "msg": result3265.ErrMsg,
  6930. })
  6931. return
  6932. } else {
  6933. c.ServeSuccessJSON(map[string]interface{}{
  6934. "info": result3265.Output.Data,
  6935. })
  6936. return
  6937. }
  6938. }
  6939. func (c *HisApiController) Get3272() {
  6940. admin_user_id, _ := c.GetInt64("admin_user_id")
  6941. startTime := c.GetString("start_time")
  6942. //endTime, _ := c.GetString("end_time")
  6943. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6944. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6945. times := strings.Split(startTime, "-")
  6946. setl_mon := times[0] + times[1]
  6947. var upld_btch string
  6948. //var empty models.JSResultEmpty
  6949. var result3265 models.JSResult3264
  6950. data := make(map[string]interface{})
  6951. data["org_name"] = miConfig.OrgName
  6952. data["doctor"] = curRoles.UserName
  6953. data["doctor_name"] = curRoles.UserName
  6954. data["fixmedins_code"] = miConfig.Code
  6955. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6956. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6957. data["secret_key"] = miConfig.SecretKey
  6958. data["url"] = miConfig.Url
  6959. data["ak"] = miConfig.AccessKey
  6960. data["cainfo"] = miConfig.Cainfo
  6961. data["setl_mon"] = setl_mon
  6962. month := time.Unix(1557042972, 0).Format("1")
  6963. year := time.Now().Format("2006")
  6964. month = time.Now().Format("01")
  6965. day := time.Now().Format("02")
  6966. hour := time.Now().Format("15")
  6967. min := time.Now().Format("04")
  6968. sec := time.Now().Format("05")
  6969. fix_fill_date := year + month + day + hour + min + sec
  6970. data["fix_fill_dept"] = miConfig.OrgName
  6971. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6972. data["fix_fill_psn"] = curRoles.UserName
  6973. data["fix_fill_date"] = fix_fill_date
  6974. data["stmt_loc"] = "2"
  6975. data["upld_btch"] = upld_btch
  6976. client := &http.Client{}
  6977. bytesData, _ := json.Marshal(data)
  6978. var req *http.Request
  6979. if miConfig.MdtrtareaAdmvs == "320921" {
  6980. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6981. } else {
  6982. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6983. }
  6984. resp, _ := client.Do(req)
  6985. defer resp.Body.Close()
  6986. body, ioErr := ioutil.ReadAll(resp.Body)
  6987. if ioErr != nil {
  6988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. }
  6991. var respJSON map[string]interface{}
  6992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. }
  6996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6997. fmt.Println(respJSON)
  6998. result, _ := json.Marshal(respJSON)
  6999. fmt.Println(result)
  7000. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7001. utils.ErrorLog("解析失败:%v", err)
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7003. }
  7004. if result3265.Infcode != "0" {
  7005. c.ServeSuccessJSON(map[string]interface{}{
  7006. "failed_code": -10,
  7007. "msg": result3265.ErrMsg,
  7008. })
  7009. return
  7010. } else {
  7011. c.ServeSuccessJSON(map[string]interface{}{
  7012. "info": result3265.Output,
  7013. })
  7014. return
  7015. }
  7016. }
  7017. func (c *HisApiController) Get3273() {
  7018. admin_user_id, _ := c.GetInt64("admin_user_id")
  7019. startTime := c.GetString("start_time")
  7020. //endTime, _ := c.GetString("end_time")
  7021. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7022. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7023. times := strings.Split(startTime, "-")
  7024. setl_mon := times[0] + times[1]
  7025. var result3265 models.JSResult3264
  7026. data := make(map[string]interface{})
  7027. data["org_name"] = miConfig.OrgName
  7028. data["doctor"] = curRoles.UserName
  7029. data["doctor_name"] = curRoles.UserName
  7030. data["fixmedins_code"] = miConfig.Code
  7031. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7032. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7033. data["secret_key"] = miConfig.SecretKey
  7034. data["url"] = miConfig.Url
  7035. data["ak"] = miConfig.AccessKey
  7036. data["cainfo"] = miConfig.Cainfo
  7037. data["setl_mon"] = setl_mon
  7038. data["stmt_loc"] = "2"
  7039. client := &http.Client{}
  7040. bytesData, _ := json.Marshal(data)
  7041. var req *http.Request
  7042. if miConfig.MdtrtareaAdmvs == "320921" {
  7043. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7044. } else {
  7045. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7046. }
  7047. resp, _ := client.Do(req)
  7048. defer resp.Body.Close()
  7049. body, ioErr := ioutil.ReadAll(resp.Body)
  7050. if ioErr != nil {
  7051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7053. }
  7054. var respJSON map[string]interface{}
  7055. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7058. }
  7059. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7060. fmt.Println(respJSON)
  7061. result, _ := json.Marshal(respJSON)
  7062. fmt.Println(result)
  7063. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7064. utils.ErrorLog("解析失败:%v", err)
  7065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7066. }
  7067. if result3265.Infcode != "0" {
  7068. c.ServeSuccessJSON(map[string]interface{}{
  7069. "failed_code": -10,
  7070. "msg": result3265.ErrMsg,
  7071. })
  7072. return
  7073. } else {
  7074. c.ServeSuccessJSON(map[string]interface{}{
  7075. "info": result3265.Output.Data,
  7076. })
  7077. return
  7078. }
  7079. }
  7080. func (c *HisApiController) Get3274() {
  7081. //if miConfig.MdtrtareaAdmvs == "320921" {
  7082. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7083. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7084. // "&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
  7085. //
  7086. //} else {
  7087. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7088. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7089. // "&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
  7090. //
  7091. //}
  7092. }
  7093. func (c *HisApiController) Get3275() {
  7094. //if miConfig.MdtrtareaAdmvs == "320921" {
  7095. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7096. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7097. // "&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
  7098. //
  7099. //} else {
  7100. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7101. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7102. // "&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
  7103. //
  7104. //}
  7105. }
  7106. func (c *HisApiController) Get3276() {
  7107. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7108. //month := c.GetString("month")
  7109. //
  7110. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7111. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7112. //var api string
  7113. //var res Result5301
  7114. //
  7115. //if miConfig.MdtrtareaAdmvs == "320921" {
  7116. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7117. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7118. //} else {
  7119. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7120. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7121. //}
  7122. //
  7123. //resp, requestErr := http.Get(api)
  7124. //if requestErr != nil {
  7125. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7126. // return
  7127. //}
  7128. //
  7129. //body, ioErr := ioutil.ReadAll(resp.Body)
  7130. //if ioErr != nil {
  7131. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7133. // return
  7134. //}
  7135. //var respJSON map[string]interface{}
  7136. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7137. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7139. // return
  7140. //}
  7141. //
  7142. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7143. //result, _ := json.Marshal(respJSON)
  7144. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7145. // utils.ErrorLog("解析失败:%v", err)
  7146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7147. // return
  7148. //}
  7149. }
  7150. func (c *HisApiController) Get3277() {
  7151. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7152. //month := c.GetString("month")
  7153. //
  7154. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7155. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7156. //var api string
  7157. //var res Result5301
  7158. //
  7159. //if miConfig.MdtrtareaAdmvs == "320921" {
  7160. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7161. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7162. //} else {
  7163. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7164. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7165. //}
  7166. //
  7167. //resp, requestErr := http.Get(api)
  7168. //if requestErr != nil {
  7169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7170. // return
  7171. //}
  7172. //
  7173. //body, ioErr := ioutil.ReadAll(resp.Body)
  7174. //if ioErr != nil {
  7175. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7177. // return
  7178. //}
  7179. //var respJSON map[string]interface{}
  7180. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7181. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. // return
  7184. //}
  7185. //
  7186. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7187. //result, _ := json.Marshal(respJSON)
  7188. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7189. // utils.ErrorLog("解析失败:%v", err)
  7190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. // return
  7192. //}
  7193. }
  7194. func (c *HisApiController) GetCFYLJG001() {
  7195. admin_user_id, _ := c.GetInt64("admin_user_id")
  7196. patient_id, _ := c.GetInt64("patient_id")
  7197. his_patient_id, _ := c.GetInt64("his_patient_id")
  7198. record_time := c.GetString("record_time")
  7199. admin_user_id = 3626
  7200. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7201. psn, _ := service.GetPsnByPatientId(patient_id)
  7202. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7203. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7204. var cFYLJG001 models.CFYLJG001
  7205. timeLayout := "2006-01-02"
  7206. loc, _ := time.LoadLocation("Local")
  7207. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7208. if err != nil {
  7209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7210. return
  7211. }
  7212. recordDateTime := theTime.Unix()
  7213. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7214. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7215. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7216. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7217. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7218. for _, item := range prescriptions {
  7219. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7220. if his.IdCardType == 1 {
  7221. bas := strings.Split(psn.CardInfo, "|")
  7222. basNumber := bas[1]
  7223. fmt.Println(basNumber)
  7224. card_sn := bas[3]
  7225. card_no := bas[2]
  7226. cFYLJG001.MdtrtCertType = "03"
  7227. cFYLJG001.CardSn = card_sn
  7228. cFYLJG001.MdtrtCertNo = card_no
  7229. cFYLJG001.EcToken = ""
  7230. cFYLJG001.AuthNo = ""
  7231. } else if his.IdCardType == 2 {
  7232. cFYLJG001.MdtrtCertType = "02"
  7233. cFYLJG001.CardSn = ""
  7234. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7235. cFYLJG001.EcToken = ""
  7236. cFYLJG001.AuthNo = ""
  7237. } else if his.IdCardType == 4 {
  7238. cFYLJG001.MdtrtCertType = "01"
  7239. cFYLJG001.CardSn = ""
  7240. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7241. cFYLJG001.EcToken = psn.VerifyNumber
  7242. cFYLJG001.AuthNo = ""
  7243. }
  7244. cFYLJG001.BizTypeCode = "01"
  7245. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7246. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7247. cFYLJG001.RxTypeCode = "1"
  7248. tempTime := time.Unix(item.PreTime, 0)
  7249. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7250. cFYLJG001.PrscTime = timeFormatOne
  7251. var count float64
  7252. if item.Type == 1 {
  7253. for _, sumItem := range item.HisDoctorAdviceInfo {
  7254. count = count + sumItem.PrescribingNumber
  7255. }
  7256. }
  7257. cFYLJG001.RxDrugCnt = count
  7258. cFYLJG001.ValiDays = "5"
  7259. ts := time.Unix(item.PreTime, 0)
  7260. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7261. tempTime3 := time.Unix(record_time2, 0)
  7262. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7263. cFYLJG001.ValiEndTime = timeFormat3
  7264. cFYLJG001.RxCotnFlag = "0"
  7265. for _, subItem := range item.HisDoctorAdviceInfo {
  7266. var drug models.RxDrug
  7267. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7268. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7269. drug.RxItemTypeCode = "11"
  7270. drug.DrugDosform = "乳膏剂" //TODO
  7271. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7272. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7273. }
  7274. drug.MedcWayDscr = subItem.DeliveryWay
  7275. tempTime2 := time.Unix(subItem.StartTime, 0)
  7276. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7277. drug.MedcBegntime = timeFormatTwo
  7278. if subItem.Day > 0 {
  7279. ts := time.Unix(subItem.StartTime, 0)
  7280. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7281. tempTime4 := time.Unix(record_time, 0)
  7282. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7283. drug.MedcEndtime = timeFormat5
  7284. } else {
  7285. tempTime2 := time.Unix(subItem.StartTime, 0)
  7286. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7287. drug.MedcEndtime = timeFormatTwo
  7288. }
  7289. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7290. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7291. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7292. drug.DrugCnt = subItem.PrescribingNumber
  7293. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7294. drug.DrugGenname = subItem.AdviceName
  7295. drug.MedcWayCodg = subItem.DeliveryWay
  7296. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7297. drug.SinDoscnt = subItem.SingleDose
  7298. drug.SinDosunt = subItem.SingleDoseUnit
  7299. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7300. drug.UsedFrquName = subItem.ExecutionFrequency
  7301. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7302. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7303. drug.HospApprFlag = "1"
  7304. cFYLJG001.List = append(cFYLJG001.List, drug)
  7305. }
  7306. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7307. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7308. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7309. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7310. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7311. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7312. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7313. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7314. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7315. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7316. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7317. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7318. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7319. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7320. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7321. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7322. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7323. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7324. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7325. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7326. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7327. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7328. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7329. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7330. tempTime2 := time.Now().Unix()
  7331. tempTime6 := time.Unix(tempTime2, 0)
  7332. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7333. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7334. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7335. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7336. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7337. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7338. //memo := make(map[string]interface{})
  7339. //inputData := make(map[string]interface{}, 0)
  7340. //type MyData struct {
  7341. // Insutype string `json:"insutype"`
  7342. //}
  7343. //
  7344. // data := MyData{
  7345. // Insutype: his.Insutype,
  7346. //}
  7347. //
  7348. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7349. var config []*models.HisXtDiagnoseConfig
  7350. for _, item := range diagnosis_ids {
  7351. id, _ := strconv.ParseInt(item, 10, 64)
  7352. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7353. config = append(config, &diagnosisConfig)
  7354. }
  7355. for index, subitem := range config {
  7356. if index == 0 {
  7357. var dia models.DiseInfo
  7358. dia.DiagType = "1"
  7359. dia.MaindiagFlag = "1"
  7360. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7361. dia.DiagCode = subitem.CountryCode
  7362. dia.DiagName = subitem.ClassName
  7363. dia.DiagDept = "肾内科"
  7364. dia.DiagDrNo = doctor.DoctorNumber
  7365. dia.DiagDrName = doctor.UserName
  7366. tempTime3 := time.Unix(item.PreTime, 0)
  7367. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7368. dia.DiagTime = timeFormatTwo
  7369. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7370. } else {
  7371. var dia models.DiseInfo
  7372. dia.DiagType = "1"
  7373. dia.MaindiagFlag = "0"
  7374. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7375. dia.DiagCode = subitem.CountryCode
  7376. dia.DiagName = subitem.ClassName
  7377. dia.DiagDept = "肾内科"
  7378. dia.DiagDrNo = doctor.DoctorNumber
  7379. dia.DiagDrName = doctor.UserName
  7380. tempTime3 := time.Unix(item.PreTime, 0)
  7381. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7382. dia.DiagTime = timeFormatTwo
  7383. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7384. }
  7385. }
  7386. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7387. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7388. var res ResultCFYLJG001
  7389. var respJSON2 map[string]interface{}
  7390. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. return
  7394. }
  7395. userJSONBytes2, _ := json.Marshal(respJSON2)
  7396. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7397. utils.ErrorLog("解析失败:%v", err)
  7398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7399. return
  7400. }
  7401. if res.Infcode == -1 {
  7402. c.ServeSuccessJSON(map[string]interface{}{
  7403. "failed_code": -10,
  7404. "msg": res.ErrMsg,
  7405. })
  7406. return
  7407. } else {
  7408. var flow models.HisPrescriptionFlow
  7409. flow.Ctime = time.Now().Unix()
  7410. flow.SignDigest = ""
  7411. flow.RxTraceCode = res.Output.RxTraceCode
  7412. flow.HiRxno = res.Output.HiRxno
  7413. flow.MID = his.Number
  7414. flow.Status = 1
  7415. flow.DCode = doctor_info.DoctorNumber
  7416. flow.OriginalRxFile = ""
  7417. flow.OriginalValue = ""
  7418. flow.SignCertDn = ""
  7419. flow.UserOrgId = 10454
  7420. flow.SignCertSn = ""
  7421. flow.Mtime = time.Now().Unix()
  7422. service.Createflow(&flow)
  7423. c.ServeSuccessJSON(map[string]interface{}{
  7424. "msg": "上传成功",
  7425. })
  7426. }
  7427. }
  7428. }
  7429. func (c *HisApiController) GetCFYLJG002() {
  7430. admin_user_id, _ := c.GetInt64("admin_user_id")
  7431. his_patient_id, _ := c.GetInt64("his_patient_id")
  7432. record_time := c.GetString("record_time")
  7433. admin_user_id = 3626
  7434. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7435. //id, _ := c.GetInt64("id")
  7436. admin_user_id = 3626
  7437. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7438. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7439. flow, _ := service.Getflowtwo(his.Number)
  7440. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7441. //record_time := c.GetString("record_time")
  7442. patient_id, _ := c.GetInt64("patient_id")
  7443. //patient_id = 23834
  7444. //record_time = "2023-09-18"
  7445. timeLayout := "2006-01-02"
  7446. loc, _ := time.LoadLocation("Local")
  7447. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7448. if err != nil {
  7449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7450. return
  7451. }
  7452. recordDateTime := theTime.Unix()
  7453. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7454. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7455. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7456. dept, _ := service.GetDepartMentDetail(info.Departments)
  7457. inputData := make(map[string]interface{})
  7458. inputData["rxTraceCode"] = flow.RxTraceCode
  7459. inputData["hiRxno"] = flow.HiRxno
  7460. inputData["mdtrtId"] = flow.MID
  7461. inputData["patnName"] = his.PsnName
  7462. inputData["psnCertType"] = his.PsnCertType
  7463. inputData["certno"] = his.Certno
  7464. inputData["fixmedinsName"] = miConfig.OrgName
  7465. inputData["fixmedinsCode"] = miConfig.Code
  7466. inputData["drCode"] = doctor_info.DoctorNumber
  7467. inputData["prscDrName"] = doctor_info.UserName
  7468. inputData["pharDeptName"] = dept.Name
  7469. inputData["pharDeptCode"] = dept.Number
  7470. inputData["pharProfttlCodg"] = dept.Name
  7471. inputData["pharProfttlName"] = ""
  7472. inputData["pharCode"] = "HY440309002107"
  7473. inputData["pharCertType"] = "01"
  7474. inputData["pharCertno"] = "430482199408260023"
  7475. inputData["pharName"] = "彭斯遥"
  7476. inputData["pharPracCertNo"] = ""
  7477. tempTime2 := time.Unix(info.Ctime, 0)
  7478. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7479. inputData["pharChkTime"] = timeFormatTwo
  7480. bytesData, _ := json.Marshal(inputData)
  7481. fmt.Println(string(bytesData))
  7482. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7483. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7484. if err != nil {
  7485. fmt.Println("Error reading PDF file:", err)
  7486. return
  7487. }
  7488. // 将 PDF 文件内容进行 Base64 编码
  7489. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7490. fmt.Println(err)
  7491. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7492. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7493. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7494. var res2 Result002
  7495. var respJSON2 map[string]interface{}
  7496. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7499. return
  7500. }
  7501. userJSONBytes2, _ := json.Marshal(respJSON2)
  7502. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7503. utils.ErrorLog("解析失败:%v", err)
  7504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7505. return
  7506. }
  7507. if res2.Infcode == 0 {
  7508. flow.Ctime = time.Now().Unix()
  7509. flow.SignDigest = res2.Output.SignDigest
  7510. flow.RxFile = res2.Output.RxFile
  7511. flow.MID = his.Number
  7512. flow.Status = 1
  7513. flow.DCode = doctor_info.DoctorNumber
  7514. flow.OriginalRxFile = rx_encoded
  7515. flow.OriginalValue = encoded
  7516. flow.SignCertDn = res2.Output.SignCertDn
  7517. flow.SignCertSn = res2.Output.SignCertSn
  7518. flow.Mtime = time.Now().Unix()
  7519. service.Saveflow(flow)
  7520. c.ServeSuccessJSON(map[string]interface{}{
  7521. "msg": "预签名成功",
  7522. })
  7523. } else {
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. return
  7526. }
  7527. }
  7528. func (c *HisApiController) GetCFYLJG003() {
  7529. admin_user_id, _ := c.GetInt64("admin_user_id")
  7530. his_patient_id, _ := c.GetInt64("his_patient_id")
  7531. record_time := c.GetString("record_time")
  7532. admin_user_id = 3626
  7533. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7534. //id, _ := c.GetInt64("id")
  7535. admin_user_id = 3626
  7536. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7538. flow, _ := service.Getflowtwo(his.Number)
  7539. //id = 3
  7540. patient_id, _ := c.GetInt64("patient_id")
  7541. //patient_id = 23834
  7542. //record_time = "2023-09-18"
  7543. timeLayout := "2006-01-02"
  7544. loc, _ := time.LoadLocation("Local")
  7545. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7546. if err != nil {
  7547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7548. return
  7549. }
  7550. recordDateTime := theTime.Unix()
  7551. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7552. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7553. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7554. dept, _ := service.GetDepartMentDetail(info.Departments)
  7555. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7556. var cFYLJG003 models.CFYLJG003
  7557. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7558. cFYLJG003.HiRxno = flow.HiRxno
  7559. cFYLJG003.MdtrtID = flow.MID
  7560. cFYLJG003.PatnName = his.Name
  7561. cFYLJG003.Certno = his.Certno
  7562. cFYLJG003.FixmedinsName = miConfig.OrgName
  7563. cFYLJG003.FixmedinsCode = miConfig.Code
  7564. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7565. cFYLJG003.PrscDrName = doctor_info.UserName
  7566. cFYLJG003.PharDeptName = dept.Name
  7567. cFYLJG003.PharDeptCode = dept.Number
  7568. cFYLJG003.PharCode = "HY440309002107"
  7569. cFYLJG003.PharCertType = "01"
  7570. cFYLJG003.PharCertno = "430482199408260023"
  7571. cFYLJG003.PharName = "彭斯遥"
  7572. cFYLJG003.PsnCertType = "01"
  7573. cFYLJG003.RxFile = flow.RxFile
  7574. cFYLJG003.SignDigest = flow.SignDigest
  7575. cFYLJG003.FixmedinsCode = miConfig.Code
  7576. cFYLJG003.PsnCertType = "01"
  7577. cFYLJG003.PharProfttlCodg = dept.Name
  7578. //inputData["pharProfttlCodg"] =dept.Name
  7579. tempTime2 := time.Unix(info.Ctime, 0)
  7580. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7581. cFYLJG003.PharChkTime = timeFormatTwo
  7582. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7583. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7584. var res ResultCFYLJG003
  7585. var respJSON2 map[string]interface{}
  7586. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7589. return
  7590. }
  7591. userJSONBytes2, _ := json.Marshal(respJSON2)
  7592. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7593. utils.ErrorLog("解析失败:%v", err)
  7594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7595. return
  7596. }
  7597. if res.Infcode == -1 {
  7598. c.ServeSuccessJSON(map[string]interface{}{
  7599. "failed_code": -10,
  7600. "msg": res.ErrMsg,
  7601. })
  7602. return
  7603. } else {
  7604. c.ServeSuccessJSON(map[string]interface{}{
  7605. "info": res.Output,
  7606. })
  7607. }
  7608. }
  7609. func (c *HisApiController) GetCFYLJG004() {
  7610. admin_user_id, _ := c.GetInt64("admin_user_id")
  7611. his_patient_id, _ := c.GetInt64("his_patient_id")
  7612. record_time := c.GetString("record_time")
  7613. admin_user_id = 3626
  7614. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7615. //id, _ := c.GetInt64("id")
  7616. admin_user_id = 3626
  7617. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7618. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7619. flow, _ := service.Getflowtwo(his.Number)
  7620. //id = 3
  7621. patient_id, _ := c.GetInt64("patient_id")
  7622. //patient_id = 23834
  7623. //record_time = "2023-09-18"
  7624. timeLayout := "2006-01-02"
  7625. loc, _ := time.LoadLocation("Local")
  7626. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7627. if err != nil {
  7628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7629. return
  7630. }
  7631. recordDateTime := theTime.Unix()
  7632. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7633. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7634. var cFYLJG004 models.CFYLJG004
  7635. cFYLJG004.HiRxno = flow.HiRxno
  7636. cFYLJG004.FixmedinsCode = miConfig.Code
  7637. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7638. cFYLJG004.UndoDrCertType = "01"
  7639. cFYLJG004.UndoRea = "撤销处方"
  7640. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7641. cFYLJG004.UndoDrName = doctor_info.UserName
  7642. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7643. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7644. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7645. var res ResultCFYLJG004
  7646. var respJSON2 map[string]interface{}
  7647. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7650. return
  7651. }
  7652. userJSONBytes2, _ := json.Marshal(respJSON2)
  7653. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7654. utils.ErrorLog("解析失败:%v", err)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. if res.Infcode == -1 {
  7659. c.ServeSuccessJSON(map[string]interface{}{
  7660. "failed_code": -10,
  7661. "msg": res.ErrMsg,
  7662. })
  7663. return
  7664. } else {
  7665. flow.Status = 0
  7666. service.Saveflow(flow)
  7667. c.ServeSuccessJSON(map[string]interface{}{
  7668. "msg": "撤销成功",
  7669. })
  7670. return
  7671. }
  7672. }
  7673. func (c *HisApiController) GetCFYLJG005() {
  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. flow, _ := service.Getflowtwo(his.Number)
  7684. //id = 3
  7685. var cFYLJG005 models.CFYLJG005
  7686. //patient_id, _ := c.GetInt64("patient_id")
  7687. cFYLJG005.HiRxno = flow.HiRxno
  7688. cFYLJG005.MdtrtID = flow.MID
  7689. cFYLJG005.EcToken = ""
  7690. cFYLJG005.PsnName = his.Name
  7691. cFYLJG005.PsnCertType = "01"
  7692. cFYLJG005.Certno = his.IdCardNo
  7693. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7694. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7695. var res ResultCFYLJG005
  7696. var respJSON2 map[string]interface{}
  7697. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. userJSONBytes2, _ := json.Marshal(respJSON2)
  7703. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7704. utils.ErrorLog("解析失败:%v", err)
  7705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7706. return
  7707. }
  7708. if res.Infcode == -1 {
  7709. c.ServeSuccessJSON(map[string]interface{}{
  7710. "failed_code": -10,
  7711. "msg": res.ErrMsg,
  7712. })
  7713. return
  7714. } else {
  7715. c.ServeSuccessJSON(map[string]interface{}{
  7716. "info": res.Output,
  7717. })
  7718. return
  7719. }
  7720. }
  7721. func (c *HisApiController) GetCFYLJG006() {
  7722. admin_user_id, _ := c.GetInt64("admin_user_id")
  7723. his_patient_id, _ := c.GetInt64("his_patient_id")
  7724. admin_user_id = 3626
  7725. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7726. //id, _ := c.GetInt64("id")
  7727. admin_user_id = 3626
  7728. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7729. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7730. flow, _ := service.Getflowtwo(his.Number)
  7731. //id = 3
  7732. patient_id, _ := c.GetInt64("patient_id")
  7733. var cFYLJG006 models.CFYLJG006
  7734. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7735. cFYLJG006.HiRxno = flow.HiRxno
  7736. cFYLJG006.MdtrtID = flow.MID
  7737. cFYLJG006.PsnName = patient.Name
  7738. cFYLJG006.PsnCertType = "01"
  7739. cFYLJG006.Certno = patient.IdCardNo
  7740. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7741. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7742. var res ResultCFYLJG006
  7743. var respJSON2 map[string]interface{}
  7744. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7747. return
  7748. }
  7749. userJSONBytes2, _ := json.Marshal(respJSON2)
  7750. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7751. utils.ErrorLog("解析失败:%v", err)
  7752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7753. return
  7754. }
  7755. if res.Infcode == -1 {
  7756. c.ServeSuccessJSON(map[string]interface{}{
  7757. "failed_code": -10,
  7758. "msg": res.ErrMsg,
  7759. })
  7760. return
  7761. } else {
  7762. c.ServeSuccessJSON(map[string]interface{}{
  7763. "info": res.Output,
  7764. })
  7765. return
  7766. }
  7767. }
  7768. func (c *HisApiController) GetCFYLJG007() {
  7769. admin_user_id, _ := c.GetInt64("admin_user_id")
  7770. his_patient_id, _ := c.GetInt64("his_patient_id")
  7771. admin_user_id = 3626
  7772. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7773. //id, _ := c.GetInt64("id")
  7774. admin_user_id = 3626
  7775. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7776. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7777. flow, _ := service.Getflowtwo(his.Number)
  7778. //id = 3
  7779. patient_id, _ := c.GetInt64("patient_id")
  7780. var cFYLJG007 models.CFYLJG007
  7781. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7782. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7783. cFYLJG007.HiRxno = flow.HiRxno
  7784. cFYLJG007.MdtrtID = flow.MID
  7785. cFYLJG007.PsnNo = his.PsnNo
  7786. cFYLJG007.PsnCertType = "01"
  7787. cFYLJG007.Certno = patient.IdCardNo
  7788. cFYLJG007.PsnName = patient.Name
  7789. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7790. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7791. var res ResultCFYLJG007
  7792. var respJSON2 map[string]interface{}
  7793. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7796. return
  7797. }
  7798. userJSONBytes2, _ := json.Marshal(respJSON2)
  7799. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7800. utils.ErrorLog("解析失败:%v", err)
  7801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7802. return
  7803. }
  7804. if res.Infcode == -1 {
  7805. c.ServeSuccessJSON(map[string]interface{}{
  7806. "failed_code": -10,
  7807. "msg": res.ErrMsg,
  7808. })
  7809. return
  7810. } else {
  7811. c.ServeSuccessJSON(map[string]interface{}{
  7812. "info": res,
  7813. })
  7814. return
  7815. }
  7816. }
  7817. func (c *HisApiController) GetCFYLJG008() {
  7818. admin_user_id, _ := c.GetInt64("admin_user_id")
  7819. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7820. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7821. var cFYLJG008 models.CFYLJG008
  7822. //id, _ := c.GetInt64("id")
  7823. patient_id, _ := c.GetInt64("patient_id")
  7824. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7825. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7826. //id = 3
  7827. //flow, _ := service.Getflow(id)
  7828. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7829. //
  7830. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7831. //patient_id, _ := c.GetInt64("patient_id")
  7832. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7833. record_time := c.GetString("record_time")
  7834. admin_user_id = 3626
  7835. patient_id = 19424
  7836. //his_patient_id = 263947
  7837. record_time = "2023-08-29"
  7838. timeLayout := "2006-01-02"
  7839. loc, _ := time.LoadLocation("Local")
  7840. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7841. if err != nil {
  7842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7843. return
  7844. }
  7845. recordDateTime := theTime.Unix()
  7846. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7847. cFYLJG008.FixmedinsName = ""
  7848. cFYLJG008.Lat = ""
  7849. cFYLJG008.Lng = ""
  7850. cFYLJG008.OrderType = "1"
  7851. cFYLJG008.PoolareaNo = ""
  7852. cFYLJG008.Lng = ""
  7853. cFYLJG008.PageNum = 1
  7854. cFYLJG008.PageSize = 10
  7855. var MPI models.MedinsProdInvChgDDTO
  7856. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7857. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7858. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7859. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7860. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7861. var res ResultCFYLJG008
  7862. var respJSON2 map[string]interface{}
  7863. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7866. return
  7867. }
  7868. userJSONBytes2, _ := json.Marshal(respJSON2)
  7869. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7870. utils.ErrorLog("解析失败:%v", err)
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. if res.Infcode == -1 {
  7875. c.ServeSuccessJSON(map[string]interface{}{
  7876. "failed_code": -10,
  7877. "msg": res.ErrMsg,
  7878. })
  7879. return
  7880. } else {
  7881. c.ServeSuccessJSON(map[string]interface{}{
  7882. "info": res.Output,
  7883. })
  7884. return
  7885. }
  7886. }
  7887. func (c *HisApiController) GetBL4201A() {
  7888. order_id, _ := c.GetInt64("order_id")
  7889. admin_user_id, _ := c.GetInt64("admin_user_id")
  7890. order, _ := service.GetHisOrderByIDTwo(order_id)
  7891. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7892. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7893. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7894. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7895. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7896. department, _ := service.GetDepartMentDetail(his.Departments)
  7897. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7898. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7899. if order.ID == 0 {
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7901. return
  7902. }
  7903. var struct4201A models.Struct4201A
  7904. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7905. for _, items := range order_info {
  7906. memo := make(map[string]interface{})
  7907. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7908. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7909. fsiOPFLD.MedType = "14"
  7910. fsiOPFLD.BkkpSn = items.FeedetlSn
  7911. fsiOPFLD.FixmedinsCode = miConfig.Code
  7912. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7913. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7914. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7915. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7916. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7917. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7918. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7919. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7920. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7921. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7922. fsiOPFLD.BilgDeptName = department.Name
  7923. fsiOPFLD.BilgDeptCodg = department.Number
  7924. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7925. fsiOPFLD.BilgDrName = doctor.UserName
  7926. fsiOPFLD.MedChrgitmType = "09"
  7927. memo["hosp_appr_flag"] = "1"
  7928. memo["invoice_no"] = order.MdtrtId
  7929. memo["memo"] = "自费"
  7930. bytesData, _ := json.Marshal(memo)
  7931. fsiOPFLD.Memo = string(bytesData)
  7932. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7933. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7934. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7935. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7936. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7937. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7938. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7939. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7940. fsiOPFLD.BilgDeptName = department.Name
  7941. fsiOPFLD.BilgDeptCodg = department.Number
  7942. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7943. fsiOPFLD.BilgDrName = doctor.UserName
  7944. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7945. case 0:
  7946. break
  7947. case 1:
  7948. fsiOPFLD.MedChrgitmType = "14"
  7949. break
  7950. case 2:
  7951. fsiOPFLD.MedChrgitmType = "05"
  7952. break
  7953. case 3:
  7954. fsiOPFLD.MedChrgitmType = "03"
  7955. break
  7956. case 4:
  7957. fsiOPFLD.MedChrgitmType = "03"
  7958. break
  7959. case 5:
  7960. fsiOPFLD.MedChrgitmType = "08"
  7961. break
  7962. case 6:
  7963. fsiOPFLD.MedChrgitmType = "14"
  7964. break
  7965. case 7:
  7966. fsiOPFLD.MedChrgitmType = "14"
  7967. break
  7968. case 8:
  7969. fsiOPFLD.MedChrgitmType = "03"
  7970. break
  7971. case 9:
  7972. fsiOPFLD.MedChrgitmType = "14"
  7973. break
  7974. case 10:
  7975. fsiOPFLD.MedChrgitmType = "14"
  7976. break
  7977. case 11:
  7978. fsiOPFLD.MedChrgitmType = "06"
  7979. break
  7980. case 12:
  7981. fsiOPFLD.MedChrgitmType = "12"
  7982. break
  7983. case 13:
  7984. fsiOPFLD.MedChrgitmType = "01"
  7985. break
  7986. case 14:
  7987. fsiOPFLD.MedChrgitmType = "04"
  7988. break
  7989. case 15:
  7990. fsiOPFLD.MedChrgitmType = "14"
  7991. break
  7992. }
  7993. memo["hosp_appr_flag"] = "1"
  7994. memo["invoice_no"] = order.MdtrtId
  7995. memo["memo"] = "自费"
  7996. bytesData, _ := json.Marshal(memo)
  7997. fsiOPFLD.Memo = string(bytesData)
  7998. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7999. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8000. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8001. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8002. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8003. fsiOPFLD.BilgDeptName = department.Name
  8004. fsiOPFLD.BilgDeptCodg = department.Number
  8005. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8006. fsiOPFLD.BilgDrName = doctor.UserName
  8007. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8008. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8009. fsiOPFLD.MedChrgitmType = "08"
  8010. memo["hosp_appr_flag"] = "1"
  8011. memo["invoice_no"] = order.MdtrtId
  8012. memo["memo"] = "自费"
  8013. bytesData, _ := json.Marshal(memo)
  8014. fsiOPFLD.Memo = string(bytesData)
  8015. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8016. }
  8017. }
  8018. }
  8019. for _, items := range order_info_two {
  8020. memo := make(map[string]interface{})
  8021. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8022. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8023. fsiOPFLD.MedType = "14"
  8024. fsiOPFLD.BkkpSn = items.FeedetlSn
  8025. fsiOPFLD.FixmedinsCode = miConfig.Code
  8026. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8027. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8028. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8029. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8030. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8031. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8032. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8033. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8034. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8035. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8036. fsiOPFLD.BilgDeptName = department.Name
  8037. fsiOPFLD.BilgDeptCodg = department.Number
  8038. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8039. fsiOPFLD.BilgDrName = doctor.UserName
  8040. fsiOPFLD.MedChrgitmType = "09"
  8041. memo["hosp_appr_flag"] = "1"
  8042. memo["invoice_no"] = order.MdtrtId
  8043. memo["memo"] = "自费"
  8044. bytesData, _ := json.Marshal(memo)
  8045. fsiOPFLD.Memo = string(bytesData)
  8046. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8047. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8048. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8049. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8050. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8051. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8052. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8053. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8054. fsiOPFLD.BilgDeptName = department.Name
  8055. fsiOPFLD.BilgDeptCodg = department.Number
  8056. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8057. fsiOPFLD.BilgDrName = doctor.UserName
  8058. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8059. case 0:
  8060. break
  8061. case 1:
  8062. fsiOPFLD.MedChrgitmType = "14"
  8063. break
  8064. case 2:
  8065. fsiOPFLD.MedChrgitmType = "05"
  8066. break
  8067. case 3:
  8068. fsiOPFLD.MedChrgitmType = "03"
  8069. break
  8070. case 4:
  8071. fsiOPFLD.MedChrgitmType = "03"
  8072. break
  8073. case 5:
  8074. fsiOPFLD.MedChrgitmType = "08"
  8075. break
  8076. case 6:
  8077. fsiOPFLD.MedChrgitmType = "14"
  8078. break
  8079. case 7:
  8080. fsiOPFLD.MedChrgitmType = "14"
  8081. break
  8082. case 8:
  8083. fsiOPFLD.MedChrgitmType = "03"
  8084. break
  8085. case 9:
  8086. fsiOPFLD.MedChrgitmType = "14"
  8087. break
  8088. case 10:
  8089. fsiOPFLD.MedChrgitmType = "14"
  8090. break
  8091. case 11:
  8092. fsiOPFLD.MedChrgitmType = "06"
  8093. break
  8094. case 12:
  8095. fsiOPFLD.MedChrgitmType = "12"
  8096. break
  8097. case 13:
  8098. fsiOPFLD.MedChrgitmType = "01"
  8099. break
  8100. case 14:
  8101. fsiOPFLD.MedChrgitmType = "04"
  8102. break
  8103. case 15:
  8104. fsiOPFLD.MedChrgitmType = "14"
  8105. break
  8106. }
  8107. memo["hosp_appr_flag"] = "1"
  8108. memo["invoice_no"] = order.MdtrtId
  8109. memo["memo"] = "自费"
  8110. bytesData, _ := json.Marshal(memo)
  8111. fsiOPFLD.Memo = string(bytesData)
  8112. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8113. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8114. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8115. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8116. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8117. fsiOPFLD.BilgDeptName = department.Name
  8118. fsiOPFLD.BilgDeptCodg = department.Number
  8119. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8120. fsiOPFLD.BilgDrName = doctor.UserName
  8121. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8122. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8123. fsiOPFLD.MedChrgitmType = "08"
  8124. memo["hosp_appr_flag"] = "1"
  8125. memo["invoice_no"] = order.MdtrtId
  8126. memo["memo"] = "自费"
  8127. bytesData, _ := json.Marshal(memo)
  8128. fsiOPFLD.Memo = string(bytesData)
  8129. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8130. }
  8131. }
  8132. }
  8133. fmt.Println(fsiOPFLDs)
  8134. struct4201A.Fopfd = fsiOPFLDs
  8135. fmt.Println(struct4201A.Fopfd)
  8136. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8137. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8138. var res2 ResultSix
  8139. var respJSON2 map[string]interface{}
  8140. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8143. return
  8144. }
  8145. userJSONBytes2, _ := json.Marshal(respJSON2)
  8146. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8147. utils.ErrorLog("解析失败:%v", err)
  8148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8149. return
  8150. }
  8151. if res2.Infcode != 0 {
  8152. c.ServeSuccessJSON(map[string]interface{}{
  8153. "failed_code": -10,
  8154. "msg": res2.ErrMsg,
  8155. })
  8156. return
  8157. } else {
  8158. order.IsUploadOrderInfo = 1
  8159. service.UpdateOrder(order)
  8160. c.ServeSuccessJSON(map[string]interface{}{
  8161. "msg": "上传成功",
  8162. })
  8163. }
  8164. }
  8165. func (c *HisApiController) Get2505() {
  8166. admin_user_id, _ := c.GetInt64("admin_user_id")
  8167. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8168. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8169. 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)
  8170. }
  8171. func (c *HisApiController) Get4201A() {
  8172. order_id, _ := c.GetInt64("order_id")
  8173. admin_user_id, _ := c.GetInt64("admin_user_id")
  8174. order, _ := service.GetHisOrderByIDTwo(order_id)
  8175. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8176. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8177. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8178. //order_info = append(order_info, order_info_two...)
  8179. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8180. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8181. department, _ := service.GetDepartMentDetail(his.Departments)
  8182. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8183. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8184. if order.ID == 0 {
  8185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8186. return
  8187. }
  8188. var struct4201A models.Struct4201A
  8189. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8190. for _, items := range order_info {
  8191. memo := make(map[string]interface{})
  8192. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8193. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8194. fsiOPFLD.MedType = "14"
  8195. fsiOPFLD.BkkpSn = items.FeedetlSn
  8196. fsiOPFLD.FixmedinsCode = miConfig.Code
  8197. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8198. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8199. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8200. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8201. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8202. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8203. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8204. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8205. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8206. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8207. fsiOPFLD.BilgDeptName = department.Name
  8208. fsiOPFLD.BilgDeptCodg = department.Number
  8209. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8210. fsiOPFLD.BilgDrName = doctor.UserName
  8211. fsiOPFLD.MedChrgitmType = "09"
  8212. memo["hosp_appr_flag"] = "1"
  8213. memo["invoice_no"] = order.MdtrtId
  8214. memo["memo"] = "自费"
  8215. bytesData, _ := json.Marshal(memo)
  8216. fsiOPFLD.Memo = string(bytesData)
  8217. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8218. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8219. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8220. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8221. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8222. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8223. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8224. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8225. fsiOPFLD.BilgDeptName = department.Name
  8226. fsiOPFLD.BilgDeptCodg = department.Number
  8227. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8228. fsiOPFLD.BilgDrName = doctor.UserName
  8229. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8230. case 0:
  8231. break
  8232. case 1:
  8233. fsiOPFLD.MedChrgitmType = "14"
  8234. break
  8235. case 2:
  8236. fsiOPFLD.MedChrgitmType = "05"
  8237. break
  8238. case 3:
  8239. fsiOPFLD.MedChrgitmType = "03"
  8240. break
  8241. case 4:
  8242. fsiOPFLD.MedChrgitmType = "03"
  8243. break
  8244. case 5:
  8245. fsiOPFLD.MedChrgitmType = "08"
  8246. break
  8247. case 6:
  8248. fsiOPFLD.MedChrgitmType = "14"
  8249. break
  8250. case 7:
  8251. fsiOPFLD.MedChrgitmType = "14"
  8252. break
  8253. case 8:
  8254. fsiOPFLD.MedChrgitmType = "03"
  8255. break
  8256. case 9:
  8257. fsiOPFLD.MedChrgitmType = "14"
  8258. break
  8259. case 10:
  8260. fsiOPFLD.MedChrgitmType = "14"
  8261. break
  8262. case 11:
  8263. fsiOPFLD.MedChrgitmType = "06"
  8264. break
  8265. case 12:
  8266. fsiOPFLD.MedChrgitmType = "12"
  8267. break
  8268. case 13:
  8269. fsiOPFLD.MedChrgitmType = "01"
  8270. break
  8271. case 14:
  8272. fsiOPFLD.MedChrgitmType = "04"
  8273. break
  8274. case 15:
  8275. fsiOPFLD.MedChrgitmType = "14"
  8276. break
  8277. }
  8278. memo["hosp_appr_flag"] = "1"
  8279. memo["invoice_no"] = order.MdtrtId
  8280. memo["memo"] = "自费"
  8281. bytesData, _ := json.Marshal(memo)
  8282. fsiOPFLD.Memo = string(bytesData)
  8283. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8284. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8285. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8286. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8287. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8288. fsiOPFLD.BilgDeptName = department.Name
  8289. fsiOPFLD.BilgDeptCodg = department.Number
  8290. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8291. fsiOPFLD.BilgDrName = doctor.UserName
  8292. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8293. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8294. fsiOPFLD.MedChrgitmType = "08"
  8295. memo["hosp_appr_flag"] = "1"
  8296. memo["invoice_no"] = order.MdtrtId
  8297. memo["memo"] = "自费"
  8298. bytesData, _ := json.Marshal(memo)
  8299. fsiOPFLD.Memo = string(bytesData)
  8300. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8301. }
  8302. }
  8303. }
  8304. for _, items := range order_info_two {
  8305. memo := make(map[string]interface{})
  8306. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8307. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8308. fsiOPFLD.MedType = "14"
  8309. fsiOPFLD.BkkpSn = items.FeedetlSn
  8310. fsiOPFLD.FixmedinsCode = miConfig.Code
  8311. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8312. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8313. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8314. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8315. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8316. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8317. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8318. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8319. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8320. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8321. fsiOPFLD.BilgDeptName = department.Name
  8322. fsiOPFLD.BilgDeptCodg = department.Number
  8323. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8324. fsiOPFLD.BilgDrName = doctor.UserName
  8325. fsiOPFLD.MedChrgitmType = "09"
  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.AdviceId == 0 && items.ProjectId > 0 {
  8333. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8334. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8335. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8336. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8337. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8338. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8339. fsiOPFLD.BilgDeptName = department.Name
  8340. fsiOPFLD.BilgDeptCodg = department.Number
  8341. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8342. fsiOPFLD.BilgDrName = doctor.UserName
  8343. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8344. case 0:
  8345. break
  8346. case 1:
  8347. fsiOPFLD.MedChrgitmType = "14"
  8348. break
  8349. case 2:
  8350. fsiOPFLD.MedChrgitmType = "05"
  8351. break
  8352. case 3:
  8353. fsiOPFLD.MedChrgitmType = "03"
  8354. break
  8355. case 4:
  8356. fsiOPFLD.MedChrgitmType = "03"
  8357. break
  8358. case 5:
  8359. fsiOPFLD.MedChrgitmType = "08"
  8360. break
  8361. case 6:
  8362. fsiOPFLD.MedChrgitmType = "14"
  8363. break
  8364. case 7:
  8365. fsiOPFLD.MedChrgitmType = "14"
  8366. break
  8367. case 8:
  8368. fsiOPFLD.MedChrgitmType = "03"
  8369. break
  8370. case 9:
  8371. fsiOPFLD.MedChrgitmType = "14"
  8372. break
  8373. case 10:
  8374. fsiOPFLD.MedChrgitmType = "14"
  8375. break
  8376. case 11:
  8377. fsiOPFLD.MedChrgitmType = "06"
  8378. break
  8379. case 12:
  8380. fsiOPFLD.MedChrgitmType = "12"
  8381. break
  8382. case 13:
  8383. fsiOPFLD.MedChrgitmType = "01"
  8384. break
  8385. case 14:
  8386. fsiOPFLD.MedChrgitmType = "04"
  8387. break
  8388. case 15:
  8389. fsiOPFLD.MedChrgitmType = "14"
  8390. break
  8391. }
  8392. memo["hosp_appr_flag"] = "1"
  8393. memo["invoice_no"] = order.MdtrtId
  8394. memo["memo"] = "自费"
  8395. bytesData, _ := json.Marshal(memo)
  8396. fsiOPFLD.Memo = string(bytesData)
  8397. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8398. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8399. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8400. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8401. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8402. fsiOPFLD.BilgDeptName = department.Name
  8403. fsiOPFLD.BilgDeptCodg = department.Number
  8404. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8405. fsiOPFLD.BilgDrName = doctor.UserName
  8406. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8407. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8408. fsiOPFLD.MedChrgitmType = "08"
  8409. memo["hosp_appr_flag"] = "1"
  8410. memo["invoice_no"] = order.MdtrtId
  8411. memo["memo"] = "自费"
  8412. bytesData, _ := json.Marshal(memo)
  8413. fsiOPFLD.Memo = string(bytesData)
  8414. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8415. }
  8416. }
  8417. }
  8418. fmt.Println(fsiOPFLDs)
  8419. struct4201A.Fopfd = fsiOPFLDs
  8420. fmt.Println(struct4201A.Fopfd)
  8421. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8422. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8423. var res2 ResultSix
  8424. var respJSON2 map[string]interface{}
  8425. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8428. return
  8429. }
  8430. userJSONBytes2, _ := json.Marshal(respJSON2)
  8431. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8432. utils.ErrorLog("解析失败:%v", err)
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. if res2.Infcode != 0 {
  8437. c.ServeSuccessJSON(map[string]interface{}{
  8438. "failed_code": -10,
  8439. "msg": res2.ErrMsg,
  8440. })
  8441. return
  8442. } else {
  8443. order.IsUploadOrderInfo = 1
  8444. service.UpdateOrder(order)
  8445. c.ServeSuccessJSON(map[string]interface{}{
  8446. "msg": "上传成功",
  8447. })
  8448. }
  8449. }
  8450. func (c *HisApiController) Get4202() {
  8451. order_id, _ := c.GetInt64("order_id")
  8452. admin_user_id, _ := c.GetInt64("admin_user_id")
  8453. order, _ := service.GetHisOrderByIDTwo(order_id)
  8454. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8455. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8456. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8457. if order.ID == 0 {
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8459. return
  8460. }
  8461. var struct4202 models.Struct4202
  8462. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8463. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8464. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8465. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8466. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8467. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8468. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8469. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8470. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8471. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8472. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8473. var config []*models.HisXtDiagnoseConfig
  8474. for _, item := range diagnosis_ids {
  8475. id, _ := strconv.ParseInt(item, 10, 64)
  8476. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8477. config = append(config, &diagnosisConfig)
  8478. }
  8479. var tempDiaginfos []models.OwnPayPatnDiagListD
  8480. for index, item := range config {
  8481. if index == 0 {
  8482. var tempDiaginfo models.OwnPayPatnDiagListD
  8483. tempDiaginfo.InoutDiagType = "1"
  8484. tempDiaginfo.DiagCode = item.CountryCode
  8485. tempDiaginfo.DiagName = item.CountryContentName
  8486. tempDiaginfo.DiagType = "1"
  8487. tempDiaginfo.DiagSrtNo = "1"
  8488. tempDiaginfo.MaindiagFlag = "1"
  8489. tempDiaginfo.ValiFlag = "1"
  8490. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8491. } else {
  8492. var tempDiaginfo models.OwnPayPatnDiagListD
  8493. tempDiaginfo.DiagCode = item.CountryCode
  8494. tempDiaginfo.DiagName = item.CountryContentName
  8495. tempDiaginfo.DiagType = "2"
  8496. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8497. tempDiaginfo.MaindiagFlag = "0"
  8498. tempDiaginfo.ValiFlag = "1"
  8499. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8500. }
  8501. }
  8502. struct4202.ODiagListD = tempDiaginfos
  8503. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8504. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8505. var res2 ResultSix
  8506. var respJSON2 map[string]interface{}
  8507. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8510. return
  8511. }
  8512. userJSONBytes2, _ := json.Marshal(respJSON2)
  8513. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8514. utils.ErrorLog("解析失败:%v", err)
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. if res2.Infcode != 0 {
  8519. c.ServeSuccessJSON(map[string]interface{}{
  8520. "failed_code": -10,
  8521. "msg": res2.ErrMsg,
  8522. })
  8523. return
  8524. } else {
  8525. order.IsUploadDiagnose = 1
  8526. service.UpdateOrder(order)
  8527. c.ServeSuccessJSON(map[string]interface{}{
  8528. "msg": "上传成功",
  8529. })
  8530. }
  8531. }
  8532. func (c *HisApiController) Get4203() {
  8533. admin_user_id, _ := c.GetInt64("admin_user_id")
  8534. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8535. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8536. order_id, _ := c.GetInt64("order_id")
  8537. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8538. number := ""
  8539. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8540. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8541. if his.ID == 0 {
  8542. number = hospital.Number
  8543. } else {
  8544. number = his.Number
  8545. }
  8546. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8547. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8548. var res2 ResultSix
  8549. var respJSON2 map[string]interface{}
  8550. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8553. return
  8554. }
  8555. userJSONBytes2, _ := json.Marshal(respJSON2)
  8556. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8557. utils.ErrorLog("解析失败:%v", err)
  8558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8559. return
  8560. }
  8561. if res2.Infcode != 0 {
  8562. c.ServeSuccessJSON(map[string]interface{}{
  8563. "failed_code": -10,
  8564. "msg": res2.ErrMsg,
  8565. })
  8566. return
  8567. } else {
  8568. order.IsUploadSuccess = 1
  8569. service.UpdateOrderTwo(order)
  8570. c.ServeSuccessJSON(map[string]interface{}{
  8571. "msg": "上传成功",
  8572. })
  8573. }
  8574. }
  8575. func (c *HisApiController) Get4205() {
  8576. order_id, _ := c.GetInt64("order_id")
  8577. admin_user_id, _ := c.GetInt64("admin_user_id")
  8578. fapiao_code := c.GetString("fapiao_code")
  8579. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8580. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8581. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8582. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8583. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8584. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8585. //order_info = append(order_info, order_info_two...)
  8586. department, _ := service.GetDepartMentDetail(his.Departments)
  8587. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8588. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8589. if order.ID == 0 {
  8590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8591. return
  8592. }
  8593. var struct4201A models.Struct4201A
  8594. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8595. for _, items := range order_info {
  8596. memo := make(map[string]interface{})
  8597. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8598. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8599. fsiOPFLD.MedType = pre.MedType
  8600. fsiOPFLD.FixmedinsCode = miConfig.Code
  8601. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8602. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8603. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8604. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8605. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8606. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8607. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8608. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8609. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8610. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8611. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8612. fsiOPFLD.BilgDeptName = department.Name
  8613. fsiOPFLD.BilgDeptCodg = department.Number
  8614. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8615. fsiOPFLD.BilgDrName = doctor.UserName
  8616. fsiOPFLD.MedChrgitmType = "09"
  8617. memo["hosp_appr_flag"] = "1"
  8618. memo["invoice_no"] = fapiao_code
  8619. memo["memo"] = "自费"
  8620. bytesData, _ := json.Marshal(memo)
  8621. fsiOPFLD.Memo = string(bytesData)
  8622. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8623. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8624. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8625. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8626. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8627. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8628. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8629. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8630. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8631. fsiOPFLD.BilgDeptName = department.Name
  8632. fsiOPFLD.BilgDeptCodg = department.Number
  8633. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8634. fsiOPFLD.BilgDrName = doctor.UserName
  8635. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8636. case 0:
  8637. break
  8638. case 1:
  8639. fsiOPFLD.MedChrgitmType = "14"
  8640. break
  8641. case 2:
  8642. fsiOPFLD.MedChrgitmType = "05"
  8643. break
  8644. case 3:
  8645. fsiOPFLD.MedChrgitmType = "03"
  8646. break
  8647. case 4:
  8648. fsiOPFLD.MedChrgitmType = "03"
  8649. break
  8650. case 5:
  8651. fsiOPFLD.MedChrgitmType = "08"
  8652. break
  8653. case 6:
  8654. fsiOPFLD.MedChrgitmType = "14"
  8655. break
  8656. case 7:
  8657. fsiOPFLD.MedChrgitmType = "14"
  8658. break
  8659. case 8:
  8660. fsiOPFLD.MedChrgitmType = "03"
  8661. break
  8662. case 9:
  8663. fsiOPFLD.MedChrgitmType = "14"
  8664. break
  8665. case 10:
  8666. fsiOPFLD.MedChrgitmType = "14"
  8667. break
  8668. case 11:
  8669. fsiOPFLD.MedChrgitmType = "06"
  8670. break
  8671. case 12:
  8672. fsiOPFLD.MedChrgitmType = "12"
  8673. break
  8674. case 13:
  8675. fsiOPFLD.MedChrgitmType = "01"
  8676. break
  8677. case 14:
  8678. fsiOPFLD.MedChrgitmType = "04"
  8679. break
  8680. case 15:
  8681. fsiOPFLD.MedChrgitmType = "14"
  8682. break
  8683. }
  8684. memo["hosp_appr_flag"] = "1"
  8685. memo["invoice_no"] = fapiao_code
  8686. memo["memo"] = "自费"
  8687. bytesData, _ := json.Marshal(memo)
  8688. fsiOPFLD.Memo = string(bytesData)
  8689. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8690. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8691. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8692. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8693. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8694. fsiOPFLD.BilgDeptName = department.Name
  8695. fsiOPFLD.BilgDeptCodg = department.Number
  8696. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8697. fsiOPFLD.BilgDrName = doctor.UserName
  8698. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8699. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8700. fsiOPFLD.MedChrgitmType = "08"
  8701. memo["hosp_appr_flag"] = "1"
  8702. memo["invoice_no"] = fapiao_code
  8703. memo["memo"] = "自费"
  8704. bytesData, _ := json.Marshal(memo)
  8705. fsiOPFLD.Memo = string(bytesData)
  8706. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8707. }
  8708. }
  8709. }
  8710. for _, items := range order_info_two {
  8711. memo := make(map[string]interface{})
  8712. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8713. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8714. fsiOPFLD.MedType = pre.MedType
  8715. fsiOPFLD.BkkpSn = items.FeedetlSn
  8716. fsiOPFLD.FixmedinsCode = miConfig.Code
  8717. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8718. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8719. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8720. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8721. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8722. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8723. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8724. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8725. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8726. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8727. fsiOPFLD.BilgDeptName = department.Name
  8728. fsiOPFLD.BilgDeptCodg = department.Number
  8729. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8730. fsiOPFLD.BilgDrName = doctor.UserName
  8731. fsiOPFLD.MedChrgitmType = "09"
  8732. memo["hosp_appr_flag"] = "1"
  8733. memo["invoice_no"] = fapiao_code
  8734. memo["memo"] = "自费"
  8735. bytesData, _ := json.Marshal(memo)
  8736. fsiOPFLD.Memo = string(bytesData)
  8737. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8738. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8739. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8740. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8741. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8742. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8743. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8744. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8745. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8746. fsiOPFLD.BilgDeptName = department.Name
  8747. fsiOPFLD.BilgDeptCodg = department.Number
  8748. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8749. fsiOPFLD.BilgDrName = doctor.UserName
  8750. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8751. case 0:
  8752. break
  8753. case 1:
  8754. fsiOPFLD.MedChrgitmType = "14"
  8755. break
  8756. case 2:
  8757. fsiOPFLD.MedChrgitmType = "05"
  8758. break
  8759. case 3:
  8760. fsiOPFLD.MedChrgitmType = "03"
  8761. break
  8762. case 4:
  8763. fsiOPFLD.MedChrgitmType = "03"
  8764. break
  8765. case 5:
  8766. fsiOPFLD.MedChrgitmType = "08"
  8767. break
  8768. case 6:
  8769. fsiOPFLD.MedChrgitmType = "14"
  8770. break
  8771. case 7:
  8772. fsiOPFLD.MedChrgitmType = "14"
  8773. break
  8774. case 8:
  8775. fsiOPFLD.MedChrgitmType = "03"
  8776. break
  8777. case 9:
  8778. fsiOPFLD.MedChrgitmType = "14"
  8779. break
  8780. case 10:
  8781. fsiOPFLD.MedChrgitmType = "14"
  8782. break
  8783. case 11:
  8784. fsiOPFLD.MedChrgitmType = "06"
  8785. break
  8786. case 12:
  8787. fsiOPFLD.MedChrgitmType = "12"
  8788. break
  8789. case 13:
  8790. fsiOPFLD.MedChrgitmType = "01"
  8791. break
  8792. case 14:
  8793. fsiOPFLD.MedChrgitmType = "04"
  8794. break
  8795. case 15:
  8796. fsiOPFLD.MedChrgitmType = "14"
  8797. break
  8798. }
  8799. memo["hosp_appr_flag"] = "1"
  8800. memo["invoice_no"] = fapiao_code
  8801. memo["memo"] = "自费"
  8802. bytesData, _ := json.Marshal(memo)
  8803. fsiOPFLD.Memo = string(bytesData)
  8804. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8805. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8806. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8807. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8808. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8809. fsiOPFLD.BilgDeptName = department.Name
  8810. fsiOPFLD.BilgDeptCodg = department.Number
  8811. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8812. fsiOPFLD.BilgDrName = doctor.UserName
  8813. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8814. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8815. fsiOPFLD.MedChrgitmType = "08"
  8816. memo["hosp_appr_flag"] = "1"
  8817. memo["invoice_no"] = fapiao_code
  8818. memo["memo"] = "自费"
  8819. bytesData, _ := json.Marshal(memo)
  8820. fsiOPFLD.Memo = string(bytesData)
  8821. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8822. }
  8823. }
  8824. }
  8825. fmt.Println(fsiOPFLDs)
  8826. struct4201A.Fopfd = fsiOPFLDs
  8827. fmt.Println(struct4201A.Fopfd)
  8828. var struct4202 models.Struct4202
  8829. timeLayout := "2006-01-02 15:04:05"
  8830. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8831. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8832. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8833. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8834. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8835. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8836. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8837. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8838. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8839. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8840. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8841. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8842. var config []*models.HisXtDiagnoseConfig
  8843. for _, item := range diagnosis_ids {
  8844. id, _ := strconv.ParseInt(item, 10, 64)
  8845. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8846. config = append(config, &diagnosisConfig)
  8847. }
  8848. var tempDiaginfos []models.OwnPayPatnDiagListD
  8849. for index, item := range config {
  8850. if index == 0 {
  8851. var tempDiaginfo models.OwnPayPatnDiagListD
  8852. tempDiaginfo.InoutDiagType = "1"
  8853. tempDiaginfo.DiagCode = item.CountryCode
  8854. tempDiaginfo.DiagName = item.CountryContentName
  8855. tempDiaginfo.DiagType = "1"
  8856. tempDiaginfo.DiagSrtNo = "1"
  8857. tempDiaginfo.MaindiagFlag = "1"
  8858. tempDiaginfo.ValiFlag = "1"
  8859. tempDiaginfo.DiagDrName = doctor.UserName
  8860. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8861. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8862. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8863. } else {
  8864. var tempDiaginfo models.OwnPayPatnDiagListD
  8865. tempDiaginfo.DiagCode = item.CountryCode
  8866. tempDiaginfo.DiagName = item.CountryContentName
  8867. tempDiaginfo.DiagType = "2"
  8868. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8869. tempDiaginfo.MaindiagFlag = "0"
  8870. tempDiaginfo.ValiFlag = "1"
  8871. tempDiaginfo.DiagDrName = doctor.UserName
  8872. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8873. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8874. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8875. }
  8876. }
  8877. struct4202.ODiagListD = tempDiaginfos
  8878. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8879. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8880. var res2 ResultSix
  8881. var respJSON2 map[string]interface{}
  8882. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8885. return
  8886. }
  8887. userJSONBytes2, _ := json.Marshal(respJSON2)
  8888. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8889. utils.ErrorLog("解析失败:%v", err)
  8890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8891. return
  8892. }
  8893. if res2.Infcode != 0 {
  8894. c.ServeSuccessJSON(map[string]interface{}{
  8895. "failed_code": -10,
  8896. "msg": res2.ErrMsg,
  8897. })
  8898. return
  8899. } else {
  8900. order.IsUploadDiagnose = 1
  8901. order.IsUploadOrderInfo = 1
  8902. service.UpdateOrderTwo(order)
  8903. c.ServeSuccessJSON(map[string]interface{}{
  8904. "msg": "上传成功",
  8905. })
  8906. }
  8907. }
  8908. func (c *HisApiController) Get4207() {
  8909. admin_user_id, _ := c.GetInt64("admin_user_id")
  8910. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8911. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8912. order_id, _ := c.GetInt64("order_id")
  8913. order, _ := service.GetHisOrderByIDTwo(order_id)
  8914. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8915. var struct4207 models.Struct4207
  8916. struct4207.PageNum = "1"
  8917. struct4207.PageSize = "1000"
  8918. struct4207.FixmedinsCode = miConfig.Code
  8919. struct4207.FixmedinsMdtrtID = order.Number
  8920. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8921. saveLog(result, requestLog, "4207", "查询")
  8922. var res2 ResultSix
  8923. var respJSON2 map[string]interface{}
  8924. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8927. return
  8928. }
  8929. userJSONBytes2, _ := json.Marshal(respJSON2)
  8930. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8931. utils.ErrorLog("解析失败:%v", err)
  8932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8933. return
  8934. }
  8935. if res2.Infcode != 0 {
  8936. c.ServeSuccessJSON(map[string]interface{}{
  8937. "failed_code": -10,
  8938. "msg": res2.ErrMsg,
  8939. })
  8940. return
  8941. } else {
  8942. c.ServeSuccessJSON(map[string]interface{}{
  8943. "msg": "查询成功",
  8944. })
  8945. }
  8946. }
  8947. func (c *HisApiController) Get4208() {
  8948. admin_user_id, _ := c.GetInt64("admin_user_id")
  8949. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8950. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8951. order_id, _ := c.GetInt64("order_id")
  8952. order, _ := service.GetHisOrderByIDTwo(order_id)
  8953. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8954. var struct4208 models.Struct4208
  8955. struct4208.PageNum = "1"
  8956. struct4208.PageSize = "1000"
  8957. struct4208.PsnCertType = "01"
  8958. struct4208.Certno = his.Certno
  8959. struct4208.MedType = order.MedType
  8960. struct4208.PsnName = his.Name
  8961. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8962. saveLog(result, requestLog, "4208", "查询")
  8963. var res2 ResultSix
  8964. var respJSON2 map[string]interface{}
  8965. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8968. return
  8969. }
  8970. userJSONBytes2, _ := json.Marshal(respJSON2)
  8971. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8972. utils.ErrorLog("解析失败:%v", err)
  8973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8974. return
  8975. }
  8976. if res2.Infcode != 0 {
  8977. c.ServeSuccessJSON(map[string]interface{}{
  8978. "failed_code": -10,
  8979. "msg": res2.ErrMsg,
  8980. })
  8981. return
  8982. } else {
  8983. c.ServeSuccessJSON(map[string]interface{}{
  8984. "msg": "查询成功",
  8985. })
  8986. }
  8987. }
  8988. func (c *HisApiController) Get4209() {
  8989. admin_user_id, _ := c.GetInt64("admin_user_id")
  8990. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8991. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8992. order_id, _ := c.GetInt64("order_id")
  8993. order, _ := service.GetHisOrderByIDTwo(order_id)
  8994. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8995. var struct4209 models.Struct4209
  8996. struct4209.FixmedinsMdtrtID = order.Number
  8997. struct4209.FixmedinsCode = miConfig.Code
  8998. struct4209.PageSize = "1000"
  8999. struct4209.PageNum = "1"
  9000. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9001. saveLog(result, requestLog, "4209", "查询")
  9002. var res2 ResultSix
  9003. var respJSON2 map[string]interface{}
  9004. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9007. return
  9008. }
  9009. userJSONBytes2, _ := json.Marshal(respJSON2)
  9010. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9011. utils.ErrorLog("解析失败:%v", err)
  9012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9013. return
  9014. }
  9015. if res2.Infcode != 0 {
  9016. c.ServeSuccessJSON(map[string]interface{}{
  9017. "failed_code": -10,
  9018. "msg": res2.ErrMsg,
  9019. })
  9020. return
  9021. } else {
  9022. c.ServeSuccessJSON(map[string]interface{}{
  9023. "msg": "查询成功",
  9024. })
  9025. }
  9026. }
  9027. type Result3101 struct {
  9028. Infcode string `json:"infcode"`
  9029. InfRefmsgid string `json:"inf_refmsgid"`
  9030. RefmsgTime string `json:"refmsg_time"`
  9031. RespondTime string `json:"respond_time"`
  9032. Enctype string `json:"enctype"`
  9033. Signtype string `json:"signtype"`
  9034. ErrMsg string `json:"err_msg"`
  9035. Output struct {
  9036. Result []struct {
  9037. JudgeResultDetailDtos []struct {
  9038. VolaItemType string `json:"vola_item_type"`
  9039. MdtrtID string `json:"mdtrt_id"`
  9040. JrdID string `json:"jrd_id"`
  9041. PatnID string `json:"patn_id"`
  9042. RxID string `json:"rx_id"`
  9043. VolaAmt interface{} `json:"vola_amt"`
  9044. } `json:"judge_result_detail_dtos"`
  9045. RuleID string `json:"rule_id"`
  9046. VolaEvid string `json:"vola_evid"`
  9047. MdtrtID string `json:"mdtrt_id"`
  9048. RuleName string `json:"rule_name"`
  9049. VolaAmtStas string `json:"vola_amt_stas"`
  9050. JrID string `json:"jr_id"`
  9051. PatnID string `json:"patn_id"`
  9052. SevDeg string `json:"sev_deg"`
  9053. VolaAmt float64 `json:"vola_amt"`
  9054. VolaBhvrType string `json:"vola_bhvr_type"`
  9055. VolaCont string `json:"vola_cont"`
  9056. } `json:"result"`
  9057. } `json:"output"`
  9058. }
  9059. type Resultgd3101 struct {
  9060. Infcode int64 `json:"infcode"`
  9061. InfRefmsgid string `json:"inf_refmsgid"`
  9062. RefmsgTime string `json:"refmsg_time"`
  9063. RespondTime string `json:"respond_time"`
  9064. Enctype string `json:"enctype"`
  9065. Signtype string `json:"signtype"`
  9066. ErrMsg string `json:"err_msg"`
  9067. Output struct {
  9068. Result []struct {
  9069. JudgeResultDetailDtos []struct {
  9070. VolaItemType string `json:"vola_item_type"`
  9071. MdtrtID string `json:"mdtrt_id"`
  9072. JrdID string `json:"jrd_id"`
  9073. PatnID string `json:"patn_id"`
  9074. RxID string `json:"rx_id"`
  9075. VolaAmt interface{} `json:"vola_amt"`
  9076. } `json:"judge_result_detail_dtos"`
  9077. RuleID string `json:"rule_id"`
  9078. VolaEvid string `json:"vola_evid"`
  9079. MdtrtID string `json:"mdtrt_id"`
  9080. RuleName string `json:"rule_name"`
  9081. VolaAmtStas string `json:"vola_amt_stas"`
  9082. JrID string `json:"jr_id"`
  9083. PatnID string `json:"patn_id"`
  9084. SevDeg string `json:"sev_deg"`
  9085. VolaAmt float64 `json:"vola_amt"`
  9086. VolaBhvrType string `json:"vola_bhvr_type"`
  9087. VolaCont string `json:"vola_cont"`
  9088. } `json:"result"`
  9089. } `json:"output"`
  9090. }
  9091. func (c *HisApiController) ReadEleToken() {
  9092. admin_user_id, _ := c.GetInt64("admin_user_id")
  9093. his_patient_id, _ := c.GetInt64("his_patient_id")
  9094. adminUser := c.GetAdminUserInfo()
  9095. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9096. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9097. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9098. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9099. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9100. if len(tokens) > 0 {
  9101. c.ServeSuccessJSON(map[string]interface{}{
  9102. "msg": "读取成功",
  9103. })
  9104. } else {
  9105. c.ServeSuccessJSON(map[string]interface{}{
  9106. "failed_code": -10,
  9107. "msg": "读取失败",
  9108. })
  9109. }
  9110. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9111. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9112. if len(tokens) > 0 {
  9113. c.ServeSuccessJSON(map[string]interface{}{
  9114. "msg": "读取成功",
  9115. })
  9116. } else {
  9117. c.ServeSuccessJSON(map[string]interface{}{
  9118. "failed_code": -10,
  9119. "msg": "读取失败",
  9120. })
  9121. }
  9122. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9123. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9124. if len(tokens) > 0 {
  9125. c.ServeSuccessJSON(map[string]interface{}{
  9126. "msg": "读取成功",
  9127. })
  9128. } else {
  9129. c.ServeSuccessJSON(map[string]interface{}{
  9130. "failed_code": -10,
  9131. "msg": "读取失败",
  9132. })
  9133. }
  9134. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9135. var api string
  9136. 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 +
  9137. "&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"
  9138. resp, requestErr := http.Get(api)
  9139. if requestErr != nil {
  9140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9141. }
  9142. body, ioErr := ioutil.ReadAll(resp.Body)
  9143. if ioErr != nil {
  9144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9146. }
  9147. var respJSON map[string]interface{}
  9148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9151. return
  9152. }
  9153. var status string
  9154. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9155. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9156. var token string
  9157. var res ResultTwo //1101结果
  9158. var res10265 ResultTwo10265 //1101结果
  9159. if status == "0" { //读卡成功
  9160. var card_info string //卡信息
  9161. var busi_card_info string
  9162. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9163. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9164. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9165. fmt.Println(card_info)
  9166. fmt.Println(busi_card_info)
  9167. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9168. result, _ := json.Marshal(respJSON)
  9169. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9170. utils.ErrorLog("解析失败:%v", err)
  9171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9172. return
  9173. }
  9174. res.ErrMsg = res10265.ErrMsg
  9175. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9176. res.Infcode = infocode
  9177. res.Output = res10265.Output
  9178. res.InfRefmsgid = res10265.InfRefmsgid
  9179. if res.Infcode == 0 {
  9180. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9181. if err == gorm.ErrRecordNotFound {
  9182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9183. return
  9184. } else if err != nil {
  9185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9186. return
  9187. } else {
  9188. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9189. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9190. infoStr := string(Iinfos)
  9191. idetinfoStr := string(Idetinfos)
  9192. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9193. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9194. psn := &models.HisPsn{
  9195. PsnNo: res.Output.Baseinfo.PsnNo,
  9196. PatientId: patient.ID,
  9197. Certno: res.Output.Baseinfo.Certno,
  9198. Gend: res.Output.Baseinfo.Gend,
  9199. Naty: res.Output.Baseinfo.Naty,
  9200. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9201. PsnName: res.Output.Baseinfo.PsnName,
  9202. Age: float64(age),
  9203. Brdy: b,
  9204. Idetinfo: idetinfoStr,
  9205. Insuinfo: infoStr,
  9206. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9207. CardInfo: card_info,
  9208. VerifyNumber: token,
  9209. IdCardType: 4,
  9210. }
  9211. var rf []*ResultFive
  9212. json.Unmarshal([]byte(infoStr), &rf)
  9213. var insutypes []*ResultFive
  9214. var insutype string
  9215. var is390 int = 0
  9216. var is310 int = 0
  9217. for _, item := range rf {
  9218. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9219. insutypes = append(insutypes, item)
  9220. }
  9221. }
  9222. if len(insutypes) == 1 {
  9223. insutype = insutypes[0].Insutype
  9224. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9225. } else {
  9226. for _, i := range insutypes {
  9227. if i.Insutype == "390" {
  9228. is390 = 1
  9229. }
  9230. if i.Insutype == "310" {
  9231. is310 = 1
  9232. }
  9233. }
  9234. }
  9235. if is390 == 1 {
  9236. insutype = "390"
  9237. }
  9238. if is310 == 1 {
  9239. insutype = "310"
  9240. }
  9241. if len(insutypes) == 0 {
  9242. insutype = "310"
  9243. }
  9244. service.CreateHisPsn(psn)
  9245. c.ServeSuccessJSON(map[string]interface{}{
  9246. "patient": patient,
  9247. "number": token,
  9248. "insutype": insutype,
  9249. })
  9250. }
  9251. } else {
  9252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9253. return
  9254. }
  9255. } else { //读卡失败
  9256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9257. return
  9258. }
  9259. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9260. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9261. if len(errMsg) == 0 {
  9262. type ELeData struct {
  9263. Data struct {
  9264. IdNo string `json:"idNo"`
  9265. IdType string `json:"idType"`
  9266. UserName string `json:"userName"`
  9267. EcToken string `json:"ecToken"`
  9268. InsuOrg string `json:"insuOrg"`
  9269. Gender string `json:"gender"`
  9270. Birthday string `json:"birthday"`
  9271. Nationality string `json:"nationality"`
  9272. Email string `json:"email"`
  9273. Extra string `json:"extra"`
  9274. } `json:"data"`
  9275. Code int `json:"code"`
  9276. Message string `json:"message"`
  9277. }
  9278. var ele ELeData
  9279. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9280. if err != nil {
  9281. utils.ErrorLog("解析失败:%v", err)
  9282. }
  9283. token := ele.Data.EcToken
  9284. if len(token) > 0 {
  9285. psn := &models.HisPsn{
  9286. PsnNo: his.PsnNo,
  9287. Age: 0,
  9288. PatientId: his.PatientId,
  9289. Certno: his.Certno,
  9290. Brdy: his.Brdy,
  9291. Gend: his.Gend,
  9292. Naty: his.Naty,
  9293. PsnCertType: his.PsnCertType,
  9294. PsnName: his.PsnName,
  9295. Idetinfo: his.Idetinfo,
  9296. Insuinfo: his.Iinfo,
  9297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9298. CardInfo: outPutInfo,
  9299. VerifyNumber: token,
  9300. }
  9301. service.CreateHisPsn(psn)
  9302. }
  9303. if len(token) > 0 {
  9304. c.ServeSuccessJSON(map[string]interface{}{
  9305. "msg": "读取成功",
  9306. })
  9307. } else {
  9308. c.ServeSuccessJSON(map[string]interface{}{
  9309. "failed_code": -10,
  9310. "msg": "读取失败",
  9311. })
  9312. }
  9313. }
  9314. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9315. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9316. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9317. type ELeData struct {
  9318. Data struct {
  9319. IdNo string `json:"idNo"`
  9320. IdType string `json:"idType"`
  9321. UserName string `json:"userName"`
  9322. EcToken string `json:"ecToken"`
  9323. InsuOrg string `json:"insuOrg"`
  9324. Gender string `json:"gender"`
  9325. Birthday string `json:"birthday"`
  9326. Nationality string `json:"nationality"`
  9327. Email string `json:"email"`
  9328. Extra string `json:"extra"`
  9329. } `json:"data"`
  9330. Code int `json:"code"`
  9331. Message string `json:"message"`
  9332. }
  9333. var ele ELeData
  9334. err := json.Unmarshal([]byte(result), &ele)
  9335. if err != nil {
  9336. utils.ErrorLog("解析失败:%v", err)
  9337. }
  9338. token := ele.Data.EcToken
  9339. token = Remove0000(token)
  9340. fmt.Println(ele.Data.UserName)
  9341. 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)
  9342. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9343. var res ResultTwo
  9344. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9345. utils.ErrorLog("解析失败:%v", err)
  9346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9347. return
  9348. }
  9349. if res.Infcode == 0 {
  9350. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9351. if err == gorm.ErrRecordNotFound {
  9352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9353. return
  9354. } else if err != nil {
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9356. return
  9357. } else {
  9358. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9359. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9360. infoStr := string(Iinfos)
  9361. idetinfoStr := string(Idetinfos)
  9362. psn := &models.HisPsn{
  9363. PsnNo: res.Output.Baseinfo.PsnNo,
  9364. PatientId: patient.ID,
  9365. Certno: res.Output.Baseinfo.Certno,
  9366. Gend: res.Output.Baseinfo.Gend,
  9367. Naty: res.Output.Baseinfo.Naty,
  9368. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9369. PsnName: res.Output.Baseinfo.PsnName,
  9370. Idetinfo: idetinfoStr,
  9371. Insuinfo: infoStr,
  9372. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9373. CardInfo: "",
  9374. VerifyNumber: token,
  9375. }
  9376. service.CreateHisPsn(psn)
  9377. c.ServeSuccessJSON(map[string]interface{}{
  9378. "patient": patient,
  9379. "number": token,
  9380. })
  9381. }
  9382. } else {
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9384. return
  9385. }
  9386. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9387. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9388. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9389. type ELeData struct {
  9390. Data struct {
  9391. IdNo string `json:"idNo"`
  9392. IdType string `json:"idType"`
  9393. UserName string `json:"userName"`
  9394. EcToken string `json:"ecToken"`
  9395. InsuOrg string `json:"insuOrg"`
  9396. Gender string `json:"gender"`
  9397. Birthday string `json:"birthday"`
  9398. Nationality string `json:"nationality"`
  9399. Email string `json:"email"`
  9400. Extra string `json:"extra"`
  9401. } `json:"data"`
  9402. Code int `json:"code"`
  9403. Message string `json:"message"`
  9404. }
  9405. var ele ELeData
  9406. err := json.Unmarshal([]byte(result), &ele)
  9407. if err != nil {
  9408. utils.ErrorLog("解析失败:%v", err)
  9409. }
  9410. token := ele.Data.EcToken
  9411. token = Remove0000(token)
  9412. fmt.Println(ele.Data.UserName)
  9413. 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)
  9414. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9415. var res ResultTwo
  9416. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9417. utils.ErrorLog("解析失败:%v", err)
  9418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9419. return
  9420. }
  9421. if res.Infcode == 0 {
  9422. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9423. if err == gorm.ErrRecordNotFound {
  9424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9425. return
  9426. } else if err != nil {
  9427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9428. return
  9429. } else {
  9430. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9431. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9432. infoStr := string(Iinfos)
  9433. idetinfoStr := string(Idetinfos)
  9434. psn := &models.HisPsn{
  9435. PsnNo: res.Output.Baseinfo.PsnNo,
  9436. PatientId: patient.ID,
  9437. Certno: res.Output.Baseinfo.Certno,
  9438. Gend: res.Output.Baseinfo.Gend,
  9439. Naty: res.Output.Baseinfo.Naty,
  9440. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9441. PsnName: res.Output.Baseinfo.PsnName,
  9442. Idetinfo: idetinfoStr,
  9443. Insuinfo: infoStr,
  9444. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9445. CardInfo: "",
  9446. VerifyNumber: token,
  9447. }
  9448. service.CreateHisPsn(psn)
  9449. c.ServeSuccessJSON(map[string]interface{}{
  9450. "patient": patient,
  9451. "number": token,
  9452. })
  9453. }
  9454. } else {
  9455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9456. return
  9457. }
  9458. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9459. //if initFlag == 0 {
  9460. //c.TestGetJiangXiBasBaseInit()
  9461. //}
  9462. //if initEleFlag == 0 {
  9463. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9464. //}
  9465. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9466. utils.ErrorLog("解析失败:%v", json_result)
  9467. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9468. type ELeData struct {
  9469. Data struct {
  9470. IdNo string `json:"idNo"`
  9471. IdType string `json:"idType"`
  9472. UserName string `json:"userName"`
  9473. EcToken string `json:"ecToken"`
  9474. InsuOrg string `json:"insuOrg"`
  9475. Gender string `json:"gender"`
  9476. Birthday string `json:"birthday"`
  9477. Nationality string `json:"nationality"`
  9478. Email string `json:"email"`
  9479. Extra string `json:"extra"`
  9480. } `json:"data"`
  9481. Code int `json:"code"`
  9482. Message string `json:"message"`
  9483. }
  9484. var ele ELeData
  9485. err := json.Unmarshal([]byte(json_result), &ele)
  9486. if err != nil {
  9487. utils.ErrorLog("解析失败:%v", err)
  9488. }
  9489. token := ele.Data.EcToken
  9490. token = Remove0000(token)
  9491. //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)
  9492. 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)
  9493. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9494. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9495. var res ResultTwo
  9496. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9497. utils.ErrorLog("解析失败:%v", err)
  9498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9499. return
  9500. }
  9501. if res.Infcode == 0 {
  9502. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9503. if err == gorm.ErrRecordNotFound {
  9504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9505. return
  9506. } else if err != nil {
  9507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9508. return
  9509. } else {
  9510. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9511. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9512. infoStr := string(Iinfos)
  9513. idetinfoStr := string(Idetinfos)
  9514. psn := &models.HisPsn{
  9515. PsnNo: res.Output.Baseinfo.PsnNo,
  9516. PatientId: patient.ID,
  9517. Certno: res.Output.Baseinfo.Certno,
  9518. Gend: res.Output.Baseinfo.Gend,
  9519. Naty: res.Output.Baseinfo.Naty,
  9520. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9521. PsnName: res.Output.Baseinfo.PsnName,
  9522. Idetinfo: idetinfoStr,
  9523. Insuinfo: infoStr,
  9524. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9525. CardInfo: "",
  9526. VerifyNumber: token,
  9527. InsuplcAdmdvs: ele.Data.InsuOrg,
  9528. }
  9529. service.CreateHisPsn(psn)
  9530. c.ServeSuccessJSON(map[string]interface{}{
  9531. "patient": patient,
  9532. "number": token,
  9533. })
  9534. }
  9535. } else {
  9536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9537. return
  9538. }
  9539. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9540. res := c.GetoleInfo()
  9541. if res.Infcode == 0 {
  9542. var result string
  9543. if res.Output.MdtrtCertType == "01" {
  9544. 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)
  9545. } else if res.Output.MdtrtCertType == "02" {
  9546. 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)
  9547. } else if res.Output.MdtrtCertType == "03" {
  9548. 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)
  9549. }
  9550. var dat map[string]interface{}
  9551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9552. fmt.Println(dat)
  9553. } else {
  9554. fmt.Println(err)
  9555. }
  9556. userJSONBytes, _ := json.Marshal(dat)
  9557. var res2 ResultTwo
  9558. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9559. utils.ErrorLog("解析失败:%v", err)
  9560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9561. return
  9562. }
  9563. if res2.Infcode == 0 {
  9564. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9565. if err == gorm.ErrRecordNotFound {
  9566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9567. return
  9568. } else if err != nil {
  9569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9570. return
  9571. } else {
  9572. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9573. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9574. infoStr := string(Iinfos)
  9575. idetinfoStr := string(Idetinfos)
  9576. var rf []*ResultFive
  9577. json.Unmarshal([]byte(infoStr), &rf)
  9578. var insutypes []*ResultFive
  9579. var insutype string
  9580. var is390 int = 0
  9581. var is310 int = 0
  9582. //var insuplc_admdvs string
  9583. for _, item := range rf {
  9584. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9585. insutypes = append(insutypes, item)
  9586. }
  9587. }
  9588. if len(insutypes) == 1 {
  9589. insutype = insutypes[0].Insutype
  9590. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9591. } else {
  9592. for _, i := range insutypes {
  9593. if i.Insutype == "390" {
  9594. is390 = 1
  9595. }
  9596. if i.Insutype == "310" {
  9597. is310 = 1
  9598. }
  9599. }
  9600. }
  9601. if is390 == 1 {
  9602. insutype = "390"
  9603. }
  9604. if is310 == 1 {
  9605. insutype = "310"
  9606. }
  9607. if len(insutypes) == 0 {
  9608. insutype = "310"
  9609. }
  9610. psn := &models.HisPsn{
  9611. PsnNo: res2.Output.Baseinfo.PsnNo,
  9612. PatientId: patient.ID,
  9613. Certno: res2.Output.Baseinfo.Certno,
  9614. Gend: res2.Output.Baseinfo.Gend,
  9615. Naty: res2.Output.Baseinfo.Naty,
  9616. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9617. PsnName: res2.Output.Baseinfo.PsnName,
  9618. Idetinfo: idetinfoStr,
  9619. Insuinfo: infoStr,
  9620. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9621. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9622. VerifyNumber: res.Output.EcToken,
  9623. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9624. }
  9625. service.CreateHisPsn(psn)
  9626. c.ServeSuccessJSON(map[string]interface{}{
  9627. "patient": patient,
  9628. "number": res.Output.CardNo,
  9629. "insutype": insutype,
  9630. })
  9631. }
  9632. } else {
  9633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9634. return
  9635. }
  9636. } else {
  9637. c.ServeSuccessJSON(map[string]interface{}{
  9638. "failed_code": -10,
  9639. "msg": res.ErrMsg,
  9640. })
  9641. }
  9642. } else {
  9643. //if initFlag == 0 {
  9644. // c.TestGetBasBaseInit()
  9645. //}
  9646. //token := c.GetEleBaseInfo()
  9647. //token = Remove0000(token)
  9648. type ELeData struct {
  9649. Code string `json:"code"`
  9650. Data struct {
  9651. Aac002 string `json:"aac002"`
  9652. Aaz500 string `json:"aaz500"`
  9653. ActCardNo string `json:"actCardNo"`
  9654. Bab520 string `json:"bab520"`
  9655. Bkz543 string `json:"bkz543"`
  9656. BusinessType string `json:"businessType"`
  9657. CertfCodg string `json:"certfCodg"`
  9658. EcIndexNo string `json:"ecIndexNo"`
  9659. EcToken string `json:"ecToken"`
  9660. ID0000 string `json:"id0000"`
  9661. IDNo string `json:"idNo"`
  9662. IDType string `json:"idType"`
  9663. Idcode string `json:"idcode"`
  9664. IdentityToken string `json:"identity_token"`
  9665. InsuOrg string `json:"insuOrg"`
  9666. OfficeID string `json:"officeId"`
  9667. OfficeName string `json:"officeName"`
  9668. OperatorID string `json:"operatorId"`
  9669. OperatorName string `json:"operatorName"`
  9670. OrgID string `json:"orgId"`
  9671. UserName string `json:"userName"`
  9672. } `json:"data"`
  9673. Infno interface{} `json:"infno"`
  9674. Message string `json:"message"`
  9675. OrgID string `json:"orgId"`
  9676. TransType string `json:"transType"`
  9677. }
  9678. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9679. fmt.Println(result)
  9680. outPutInfo := Remove0000(result)
  9681. fmt.Println(outPutInfo)
  9682. var ele ELeData
  9683. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9684. if err != nil {
  9685. utils.ErrorLog("解析失败:%v", err)
  9686. }
  9687. token := ele.Data.EcToken
  9688. var result2 string
  9689. var requestLog2 string
  9690. if len(token) > 0 {
  9691. if strings.Contains(ele.Data.IDNo, "HKG") {
  9692. 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)
  9693. } else {
  9694. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9695. }
  9696. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9697. var res ResultTwo
  9698. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9699. utils.ErrorLog("解析失败:%v", err)
  9700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9701. return
  9702. }
  9703. if res.Infcode == 0 {
  9704. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9705. if err == gorm.ErrRecordNotFound {
  9706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9707. return
  9708. } else if err != nil {
  9709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9710. return
  9711. } else {
  9712. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9713. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9714. infoStr := string(Iinfos)
  9715. idetinfoStr := string(Idetinfos)
  9716. psn := &models.HisPsn{
  9717. PsnNo: res.Output.Baseinfo.PsnNo,
  9718. PatientId: patient.ID,
  9719. Certno: res.Output.Baseinfo.Certno,
  9720. Gend: res.Output.Baseinfo.Gend,
  9721. Naty: res.Output.Baseinfo.Naty,
  9722. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9723. PsnName: res.Output.Baseinfo.PsnName,
  9724. Idetinfo: idetinfoStr,
  9725. Insuinfo: infoStr,
  9726. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9727. CardInfo: "",
  9728. VerifyNumber: token,
  9729. }
  9730. service.CreateHisPsn(psn)
  9731. c.ServeSuccessJSON(map[string]interface{}{
  9732. "msg": "读取成功",
  9733. })
  9734. }
  9735. } else {
  9736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9737. return
  9738. }
  9739. } else {
  9740. c.ServeSuccessJSON(map[string]interface{}{
  9741. "failed_code": -10,
  9742. "msg": "读取失败",
  9743. })
  9744. }
  9745. }
  9746. }
  9747. func (c *HisApiController) ReadEleFace() {
  9748. admin_user_id, _ := c.GetInt64("admin_user_id")
  9749. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9750. adminUser := c.GetAdminUserInfo()
  9751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9752. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9753. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9754. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9755. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9756. if len(tokens) > 0 {
  9757. c.ServeSuccessJSON(map[string]interface{}{
  9758. "msg": "读取成功",
  9759. })
  9760. } else {
  9761. c.ServeSuccessJSON(map[string]interface{}{
  9762. "failed_code": -10,
  9763. "msg": "读取失败",
  9764. })
  9765. }
  9766. }
  9767. }
  9768. func (c *HisApiController) Get9001() {
  9769. adminUser := c.GetAdminUserInfo()
  9770. admin_user_id, _ := c.GetInt64("admin_user_id")
  9771. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9772. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9773. if miConfig.MdtrtareaAdmvs == "350500" {
  9774. service.GetFjAuthorizationInfo(miConfig.Code)
  9775. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9776. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9777. var dat map[string]interface{}
  9778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9779. fmt.Println(dat)
  9780. } else {
  9781. fmt.Println(err)
  9782. }
  9783. userJSONBytes, _ := json.Marshal(dat)
  9784. var res models.Result9001
  9785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9786. utils.ErrorLog("解析失败:%v", err)
  9787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9788. return
  9789. }
  9790. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9791. fmt.Println(miConfig.SecretKey)
  9792. var res models.Result9001Two
  9793. 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 +
  9794. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9795. resp, requestErr := http.Get(api)
  9796. if requestErr != nil {
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9798. return
  9799. }
  9800. body, ioErr := ioutil.ReadAll(resp.Body)
  9801. if ioErr != nil {
  9802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9804. return
  9805. }
  9806. var respJSON map[string]interface{}
  9807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9810. return
  9811. }
  9812. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9813. if status == "0" {
  9814. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9815. c.ServeSuccessJSON(map[string]interface{}{
  9816. "failed_code": -10,
  9817. "msg": err_msg,
  9818. })
  9819. return
  9820. }
  9821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9822. result, _ := json.Marshal(respJSON)
  9823. fmt.Println("log")
  9824. fmt.Println(string(result))
  9825. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9826. utils.ErrorLog("解析失败:%v", err)
  9827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9828. return
  9829. }
  9830. if res.Infcode == 0 {
  9831. sign := models.HisSignIn{
  9832. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9833. SignNo: res.Output.Signinoutb.SignNo,
  9834. SignTime: "",
  9835. Ctime: time.Now().Unix(),
  9836. Mtime: time.Now().Unix(),
  9837. Status: 1,
  9838. InputLog: "",
  9839. OutputLog: "",
  9840. FixmedinsCode: miConfig.Code,
  9841. }
  9842. err := service.CreateSignIn(&sign)
  9843. if err == nil {
  9844. c.ServeSuccessJSON(map[string]interface{}{
  9845. "msg": "签到成功",
  9846. })
  9847. }
  9848. } else {
  9849. c.ServeSuccessJSON(map[string]interface{}{
  9850. "failed_code": -10,
  9851. "msg": res.ErrMsg,
  9852. })
  9853. return
  9854. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9855. //return
  9856. }
  9857. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9858. fmt.Println(miConfig.SecretKey)
  9859. var res models.Result9001Two
  9860. 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 +
  9861. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9862. resp, requestErr := http.Get(api)
  9863. if requestErr != nil {
  9864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9865. return
  9866. }
  9867. body, ioErr := ioutil.ReadAll(resp.Body)
  9868. if ioErr != nil {
  9869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9871. return
  9872. }
  9873. var respJSON map[string]interface{}
  9874. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9877. return
  9878. }
  9879. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9880. if status == "0" {
  9881. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9882. c.ServeSuccessJSON(map[string]interface{}{
  9883. "failed_code": -10,
  9884. "msg": err_msg,
  9885. })
  9886. return
  9887. }
  9888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9889. result, _ := json.Marshal(respJSON)
  9890. fmt.Println("log")
  9891. fmt.Println(string(result))
  9892. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9893. utils.ErrorLog("解析失败:%v", err)
  9894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9895. return
  9896. }
  9897. if res.Infcode == 0 {
  9898. sign := models.HisSignIn{
  9899. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9900. SignNo: res.Output.Signinoutb.SignNo,
  9901. SignTime: "",
  9902. Ctime: time.Now().Unix(),
  9903. Mtime: time.Now().Unix(),
  9904. Status: 1,
  9905. InputLog: "",
  9906. OutputLog: "",
  9907. FixmedinsCode: miConfig.Code,
  9908. }
  9909. err := service.CreateSignIn(&sign)
  9910. if err == nil {
  9911. c.ServeSuccessJSON(map[string]interface{}{
  9912. "msg": "签到成功",
  9913. })
  9914. }
  9915. } else {
  9916. c.ServeSuccessJSON(map[string]interface{}{
  9917. "failed_code": -10,
  9918. "msg": res.ErrMsg,
  9919. })
  9920. return
  9921. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9922. //return
  9923. }
  9924. } else {
  9925. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9926. var dat map[string]interface{}
  9927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9928. fmt.Println(dat)
  9929. } else {
  9930. fmt.Println(err)
  9931. }
  9932. userJSONBytes, _ := json.Marshal(dat)
  9933. var res models.Result9001
  9934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9935. utils.ErrorLog("解析失败:%v", err)
  9936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9937. return
  9938. }
  9939. if res.Infcode == 0 {
  9940. sign := models.HisSignIn{
  9941. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9942. SignNo: res.Output.Signinoutb.SignNo,
  9943. SignTime: res.Output.Signinoutb.SignTime,
  9944. Ctime: time.Now().Unix(),
  9945. Mtime: time.Now().Unix(),
  9946. Status: 1,
  9947. InputLog: "",
  9948. OutputLog: "",
  9949. FixmedinsCode: miConfig.Code,
  9950. }
  9951. err := service.CreateSignIn(&sign)
  9952. if err == nil {
  9953. c.ServeSuccessJSON(map[string]interface{}{
  9954. "msg": "签到成功",
  9955. })
  9956. }
  9957. }
  9958. }
  9959. }
  9960. 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) {
  9961. var res Result3101
  9962. adminUser := c.GetAdminUserInfo()
  9963. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9964. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9965. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9966. //record_time := c.GetString("record_time")
  9967. //trig_scen := c.GetString("trig_scen")
  9968. timeLayout := "2006-01-02"
  9969. loc, _ := time.LoadLocation("Local")
  9970. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9971. if err != nil {
  9972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9973. return res
  9974. }
  9975. recordDateTime := theTime.Unix()
  9976. var patientPrescription models.HisPrescriptionInfo
  9977. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9978. //if patientPrescription.ID == 0 {
  9979. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9980. //}
  9981. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9982. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9983. //
  9984. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9985. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9986. var pp models.PublicParams
  9987. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9988. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9989. pp.FixmedinsName = miConfig.OrgName
  9990. pp.FixmedinsCode = miConfig.Code
  9991. pp.RequestUrl = miConfig.Url
  9992. pp.Cainfo = miConfig.Cainfo
  9993. pp.SecretKey = miConfig.SecretKey
  9994. pp.AccessKey = miConfig.AccessKey
  9995. pp.OpterName = roles.UserName
  9996. var config []*models.HisXtDiagnoseConfig
  9997. for _, item := range diagnosis_ids {
  9998. id, _ := strconv.ParseInt(item, 10, 64)
  9999. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10000. config = append(config, &diagnosisConfig)
  10001. }
  10002. var pd models.PatientDtos
  10003. pd.PatnID = his.PsnNo
  10004. pd.PatnName = his.Name
  10005. pd.Gend = his.Gend
  10006. pd.Brdy = his.Brdy
  10007. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10008. pd.CurrMdtrtID = his.Number
  10009. var fed models.FsiEncounterDtos
  10010. fed.MdtrtID = his.Number
  10011. fed.MedinsID = miConfig.Code
  10012. fed.MedinsName = miConfig.OrgName
  10013. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10014. fed.MedMdtrtType = "1"
  10015. fed.MedinsType = "1"
  10016. fed.MedinsLv = "11"
  10017. tm := time.Unix(his.RecordDate, 0)
  10018. s_tm := tm.Format("2006-01-02 15:04:05")
  10019. fed.AdmDate = s_tm
  10020. fed.DscgDate = s_tm
  10021. fed.DscgMainDiseCodg = config[0].CountryCode
  10022. fed.DscgMainDiseName = config[0].CountryContentName
  10023. //诊断信息
  10024. var fdds []*models.FsiDiagnoseDtos
  10025. for index, item := range config {
  10026. if index == 0 {
  10027. var fdd models.FsiDiagnoseDtos
  10028. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10029. fdd.InoutDiseType = "1"
  10030. fdd.MaindiseFlag = "1"
  10031. fdd.DiseDate = s_tm
  10032. fdd.DiasSrtNo = "1"
  10033. fdd.DiseName = item.CountryContentName
  10034. fdd.DiseCodg = item.CountryCode
  10035. fdds = append(fdds, &fdd)
  10036. } else {
  10037. var fdd models.FsiDiagnoseDtos
  10038. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10039. fdd.InoutDiseType = "1"
  10040. fdd.MaindiseFlag = "1"
  10041. fdd.DiseDate = s_tm
  10042. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10043. fdd.DiseName = item.CountryContentName
  10044. fdd.DiseCodg = item.CountryCode
  10045. fdds = append(fdds, &fdd)
  10046. }
  10047. }
  10048. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10049. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10050. fed.AdmDeptName = de.Name
  10051. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10052. fed.DscgDeptName = de.Name
  10053. fed.MedMdtrtType = "1"
  10054. fed.MedType = "11"
  10055. //if his.Insutype == "390" {
  10056. // fed.MedType = "1402"
  10057. //} else {
  10058. // fed.MedType = "9933"
  10059. //}
  10060. var orders []*models.FsiOrderDtos
  10061. if trig_scen == "2" {
  10062. //处方医嘱信息
  10063. for _, item := range prescriptions {
  10064. for _, subItem := range item.HisDoctorAdviceInfo {
  10065. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10066. var order models.FsiOrderDtos
  10067. order.RxID = strconv.FormatInt(item.ID, 10)
  10068. order.Rxno = strconv.FormatInt(item.ID, 10)
  10069. order.LongDrordFlag = "0"
  10070. order.HilistType = "1"
  10071. order.ChrgType = "1"
  10072. order.DrordBhvr = "-"
  10073. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10074. order.HosplistName = subItem.BaseDrugLib.DrugName
  10075. order.HilistLv = "1"
  10076. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10077. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10078. order.HosplistName = subItem.BaseDrugLib.DrugName
  10079. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10080. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10081. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10082. order.OwnpayAmt = ""
  10083. order.SelfpayAmt = ""
  10084. order.Spec = ""
  10085. order.SpecUnt = ""
  10086. order.DrordBegnDate = s_tm
  10087. order.DrordStopDate = ""
  10088. order.DrordDrCodg = doctor_info.DoctorNumber
  10089. order.DrordDeptName = department.Name
  10090. order.DrordDeptCodg = department.Number
  10091. order.DrordDrName = doctor_info.UserName
  10092. order.DrordDrProfttl = "234"
  10093. order.CurrDrordFlag = "1"
  10094. orders = append(orders, &order)
  10095. }
  10096. }
  10097. for _, subItem := range item.HisPrescriptionProject {
  10098. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10099. var order models.FsiOrderDtos
  10100. order.RxID = strconv.FormatInt(item.ID, 10)
  10101. order.Rxno = strconv.FormatInt(item.ID, 10)
  10102. order.LongDrordFlag = "0"
  10103. order.HilistType = "1"
  10104. order.ChrgType = "1"
  10105. order.DrordBhvr = "-"
  10106. order.HilistCode = subItem.HisProject.MedicalCode
  10107. order.HosplistName = subItem.HisProject.ProjectName
  10108. order.HilistLv = "1"
  10109. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10110. order.HosplistCode = subItem.HisProject.MedicalCode
  10111. order.HosplistName = subItem.HisProject.ProjectName
  10112. order.Cnt = subItem.Count
  10113. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10114. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10115. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10116. order.OwnpayAmt = ""
  10117. order.SelfpayAmt = ""
  10118. order.Spec = ""
  10119. order.SpecUnt = ""
  10120. order.DrordBegnDate = s_tm
  10121. order.DrordStopDate = ""
  10122. order.DrordDrCodg = doctor_info.DoctorNumber
  10123. order.DrordDeptName = department.Name
  10124. order.DrordDeptCodg = department.Number
  10125. order.DrordDrName = doctor_info.UserName
  10126. order.DrordDrProfttl = "234"
  10127. order.CurrDrordFlag = "1"
  10128. orders = append(orders, &order)
  10129. }
  10130. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10131. var order models.FsiOrderDtos
  10132. order.RxID = strconv.FormatInt(item.ID, 10)
  10133. order.Rxno = strconv.FormatInt(item.ID, 10)
  10134. order.LongDrordFlag = "0"
  10135. order.HilistType = "1"
  10136. order.ChrgType = "1"
  10137. order.DrordBhvr = "-"
  10138. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10139. order.HosplistName = subItem.GoodInfo.GoodName
  10140. order.HilistLv = "1"
  10141. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10142. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10143. order.HosplistName = subItem.GoodInfo.GoodName
  10144. order.Cnt = subItem.Count
  10145. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10146. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10147. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10148. order.OwnpayAmt = ""
  10149. order.SelfpayAmt = ""
  10150. order.Spec = ""
  10151. order.SpecUnt = ""
  10152. order.DrordBegnDate = s_tm
  10153. order.DrordStopDate = ""
  10154. order.DrordDrCodg = doctor_info.DoctorNumber
  10155. order.DrordDeptName = department.Name
  10156. order.DrordDeptCodg = department.Number
  10157. order.DrordDrName = doctor_info.UserName
  10158. order.DrordDrProfttl = "234"
  10159. order.CurrDrordFlag = "1"
  10160. orders = append(orders, &order)
  10161. }
  10162. }
  10163. }
  10164. //处方医嘱信息
  10165. }
  10166. fed.MatnStas = "0"
  10167. fed.MedfeeSumamt = "0"
  10168. fed.OwnpayAmt = "0"
  10169. fed.SelfpayAmt = "0"
  10170. fed.AcctPayamt = "0"
  10171. fed.MaAmt = "0"
  10172. fed.HifpPayamt = "0"
  10173. fed.SetlTotlnum = "1"
  10174. fed.Insutype = his.Insutype
  10175. fed.ReimFlag = "0"
  10176. fed.OutSetlFlag = "0"
  10177. var fopd []*models.FsiOperationDtosData
  10178. data := make(map[string]interface{})
  10179. data["fed"] = fed
  10180. data["fdd"] = fdds
  10181. data["fod"] = orders
  10182. data["pd"] = pd
  10183. data["pp"] = pp
  10184. data["fopd"] = fopd
  10185. data["trig_scen"] = trig_scen
  10186. fmt.Println(data)
  10187. fmt.Println(fed)
  10188. fmt.Println(fdds)
  10189. fmt.Println(orders)
  10190. fmt.Println(pd)
  10191. fmt.Println(pp)
  10192. fmt.Println(fopd)
  10193. client := &http.Client{}
  10194. bytesData, _ := json.Marshal(data)
  10195. var req *http.Request
  10196. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10197. if miConfig.MdtrtareaAdmvs == "320921" {
  10198. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10199. } else {
  10200. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10201. }
  10202. resp, _ := client.Do(req)
  10203. defer resp.Body.Close()
  10204. body, ioErr := ioutil.ReadAll(resp.Body)
  10205. if ioErr != nil {
  10206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10208. return res
  10209. }
  10210. var respJSON map[string]interface{}
  10211. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10214. return res
  10215. }
  10216. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10217. fmt.Println(respJSON)
  10218. result, _ := json.Marshal(respJSON)
  10219. fmt.Println(result)
  10220. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10221. utils.ErrorLog("解析失败:%v", err)
  10222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10223. return res
  10224. }
  10225. return res
  10226. } else {
  10227. //if miConfig.MdtrtareaAdmvs == "441202" {
  10228. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10229. saveLog(output, input, "3101", "事前")
  10230. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10231. utils.ErrorLog("解析失败:%v", err)
  10232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10233. return
  10234. }
  10235. return res
  10236. //}
  10237. }
  10238. }
  10239. 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) {
  10240. adminUser := c.GetAdminUserInfo()
  10241. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10242. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10243. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10244. //record_time := c.GetString("record_time")
  10245. //trig_scen := c.GetString("trig_scen")
  10246. timeLayout := "2006-01-02"
  10247. loc, _ := time.LoadLocation("Local")
  10248. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10249. if err != nil {
  10250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10251. return res
  10252. }
  10253. recordDateTime := theTime.Unix()
  10254. var patientPrescription models.HisPrescriptionInfo
  10255. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10256. if patientPrescription.ID == 0 {
  10257. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10258. }
  10259. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10260. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10261. //
  10262. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10263. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10264. var pp models.PublicParams
  10265. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10266. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10267. pp.FixmedinsName = miConfig.OrgName
  10268. pp.FixmedinsCode = miConfig.Code
  10269. pp.RequestUrl = miConfig.Url
  10270. pp.Cainfo = miConfig.Cainfo
  10271. pp.SecretKey = miConfig.SecretKey
  10272. pp.AccessKey = miConfig.AccessKey
  10273. pp.OpterName = roles.UserName
  10274. var config []*models.HisXtDiagnoseConfig
  10275. for _, item := range diagnosis_ids {
  10276. id, _ := strconv.ParseInt(item, 10, 64)
  10277. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10278. config = append(config, &diagnosisConfig)
  10279. }
  10280. var pd models.PatientDtos
  10281. pd.PatnID = his.PsnNo
  10282. pd.PatnName = his.Name
  10283. pd.Gend = his.Gend
  10284. pd.Brdy = his.Brdy
  10285. pd.Poolarea = his.InsuplcAdmdvs
  10286. pd.CurrMdtrtID = his.Number
  10287. var fed models.FsiEncounterDtos
  10288. fed.MdtrtID = his.Number
  10289. fed.MedinsID = miConfig.Code
  10290. fed.MedinsName = miConfig.OrgName
  10291. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10292. fed.MedMdtrtType = "1"
  10293. fed.MedinsType = "1"
  10294. fed.MedinsLv = "11"
  10295. tm := time.Unix(his.RecordDate, 0)
  10296. s_tm := tm.Format("2006-01-02 15:04:05")
  10297. fed.AdmDate = s_tm
  10298. fed.DscgDate = s_tm
  10299. fed.DscgMainDiseCodg = config[0].CountryCode
  10300. fed.DscgMainDiseName = config[0].CountryContentName
  10301. //诊断信息
  10302. var fdds []*models.FsiDiagnoseDtos
  10303. for index, item := range config {
  10304. if index == 0 {
  10305. var fdd models.FsiDiagnoseDtos
  10306. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10307. fdd.InoutDiseType = "1"
  10308. fdd.MaindiseFlag = "1"
  10309. fdd.DiseDate = s_tm
  10310. fdd.DiasSrtNo = "1"
  10311. fdd.DiseName = item.CountryContentName
  10312. fdd.DiseCodg = item.CountryCode
  10313. fdds = append(fdds, &fdd)
  10314. } else {
  10315. var fdd models.FsiDiagnoseDtos
  10316. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10317. fdd.InoutDiseType = "1"
  10318. fdd.MaindiseFlag = "1"
  10319. fdd.DiseDate = s_tm
  10320. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10321. fdd.DiseName = item.CountryContentName
  10322. fdd.DiseCodg = item.CountryCode
  10323. fdds = append(fdds, &fdd)
  10324. }
  10325. }
  10326. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10327. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10328. fed.AdmDeptName = department.Name
  10329. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10330. fed.DscgDeptName = department.Name
  10331. fed.MedMdtrtType = "1"
  10332. fed.MedType = "11"
  10333. //if his.Insutype == "390" {
  10334. // fed.MedType = "1402"
  10335. //} else {
  10336. // fed.MedType = "9933"
  10337. //}
  10338. var orders []*models.FsiOrderDtos
  10339. if trig_scen == "2" {
  10340. //处方医嘱信息
  10341. for _, item := range prescriptions {
  10342. for _, subItem := range item.HisDoctorAdviceInfo {
  10343. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10344. var order models.FsiOrderDtos
  10345. order.RxID = strconv.FormatInt(item.ID, 10)
  10346. order.Rxno = strconv.FormatInt(item.ID, 10)
  10347. order.LongDrordFlag = "0"
  10348. order.HilistType = "1"
  10349. order.ChrgType = "1"
  10350. order.DrordBhvr = "-"
  10351. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10352. order.HosplistName = subItem.BaseDrugLib.DrugName
  10353. order.HilistLv = "1"
  10354. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10355. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10356. order.HosplistName = subItem.BaseDrugLib.DrugName
  10357. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10358. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10359. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10360. order.OwnpayAmt = ""
  10361. order.SelfpayAmt = ""
  10362. order.Spec = ""
  10363. order.SpecUnt = ""
  10364. order.DrordBegnDate = s_tm
  10365. order.DrordStopDate = ""
  10366. order.DrordDrCodg = doctor_info.DoctorNumber
  10367. order.DrordDeptName = department.Name
  10368. order.DrordDeptCodg = department.Number
  10369. order.DrordDrName = doctor_info.UserName
  10370. order.DrordDrProfttl = "234"
  10371. order.CurrDrordFlag = "1"
  10372. orders = append(orders, &order)
  10373. }
  10374. }
  10375. for _, subItem := range item.HisPrescriptionProject {
  10376. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10377. var order models.FsiOrderDtos
  10378. order.RxID = strconv.FormatInt(item.ID, 10)
  10379. order.Rxno = strconv.FormatInt(item.ID, 10)
  10380. order.LongDrordFlag = "0"
  10381. order.HilistType = "1"
  10382. order.ChrgType = "1"
  10383. order.DrordBhvr = "-"
  10384. order.HilistCode = subItem.HisProject.MedicalCode
  10385. order.HosplistName = subItem.HisProject.ProjectName
  10386. order.HilistLv = "1"
  10387. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10388. order.HosplistCode = subItem.HisProject.MedicalCode
  10389. order.HosplistName = subItem.HisProject.ProjectName
  10390. order.Cnt = subItem.Count
  10391. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10392. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10393. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10394. order.OwnpayAmt = ""
  10395. order.SelfpayAmt = ""
  10396. order.Spec = ""
  10397. order.SpecUnt = ""
  10398. order.DrordBegnDate = s_tm
  10399. order.DrordStopDate = ""
  10400. order.DrordDrCodg = doctor_info.DoctorNumber
  10401. order.DrordDeptName = department.Name
  10402. order.DrordDeptCodg = department.Number
  10403. order.DrordDrName = doctor_info.UserName
  10404. order.DrordDrProfttl = "234"
  10405. order.CurrDrordFlag = "1"
  10406. orders = append(orders, &order)
  10407. }
  10408. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10409. var order models.FsiOrderDtos
  10410. order.RxID = strconv.FormatInt(item.ID, 10)
  10411. order.Rxno = strconv.FormatInt(item.ID, 10)
  10412. order.LongDrordFlag = "0"
  10413. order.HilistType = "1"
  10414. order.ChrgType = "1"
  10415. order.DrordBhvr = "-"
  10416. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10417. order.HosplistName = subItem.GoodInfo.GoodName
  10418. order.HilistLv = "1"
  10419. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10420. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10421. order.HosplistName = subItem.GoodInfo.GoodName
  10422. order.Cnt = subItem.Count
  10423. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10424. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10425. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10426. order.OwnpayAmt = ""
  10427. order.SelfpayAmt = ""
  10428. order.Spec = ""
  10429. order.SpecUnt = ""
  10430. order.DrordBegnDate = s_tm
  10431. order.DrordStopDate = ""
  10432. order.DrordDrCodg = doctor_info.DoctorNumber
  10433. order.DrordDeptName = department.Name
  10434. order.DrordDeptCodg = department.Number
  10435. order.DrordDrName = doctor_info.UserName
  10436. order.DrordDrProfttl = "234"
  10437. order.CurrDrordFlag = "1"
  10438. orders = append(orders, &order)
  10439. }
  10440. }
  10441. }
  10442. //处方医嘱信息
  10443. }
  10444. fed.MatnStas = "0"
  10445. fed.MedfeeSumamt = "0"
  10446. fed.OwnpayAmt = "0"
  10447. fed.SelfpayAmt = "0"
  10448. fed.AcctPayamt = "0"
  10449. fed.MaAmt = "0"
  10450. fed.HifpPayamt = "0"
  10451. fed.SetlTotlnum = "1"
  10452. fed.Insutype = his.Insutype
  10453. fed.ReimFlag = "0"
  10454. fed.OutSetlFlag = "0"
  10455. var fopd []*models.FsiOperationDtosData
  10456. data := make(map[string]interface{})
  10457. data["fed"] = fed
  10458. data["fdd"] = fdds
  10459. data["fod"] = orders
  10460. data["pd"] = pd
  10461. data["pp"] = pp
  10462. data["fopd"] = fopd
  10463. data["trig_scen"] = trig_scen
  10464. fmt.Println(data)
  10465. fmt.Println(fed)
  10466. fmt.Println(fdds)
  10467. fmt.Println(orders)
  10468. fmt.Println(pd)
  10469. fmt.Println(pp)
  10470. fmt.Println(fopd)
  10471. client := &http.Client{}
  10472. bytesData, _ := json.Marshal(data)
  10473. var req *http.Request
  10474. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10475. if miConfig.MdtrtareaAdmvs == "320921" {
  10476. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10477. } else {
  10478. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10479. }
  10480. resp, _ := client.Do(req)
  10481. defer resp.Body.Close()
  10482. body, ioErr := ioutil.ReadAll(resp.Body)
  10483. if ioErr != nil {
  10484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10486. return res
  10487. }
  10488. var respJSON map[string]interface{}
  10489. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10492. return res
  10493. }
  10494. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10495. fmt.Println(respJSON)
  10496. result, _ := json.Marshal(respJSON)
  10497. fmt.Println(result)
  10498. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10499. utils.ErrorLog("解析失败:%v", err)
  10500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10501. return res
  10502. }
  10503. return res
  10504. } else {
  10505. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10506. saveLog(output, input, "3101", "事前")
  10507. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10508. utils.ErrorLog("解析失败:%v", err)
  10509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10510. return
  10511. }
  10512. return res
  10513. }
  10514. return res
  10515. }
  10516. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10517. ////patient_id, _ := c.GetInt64("patient_id")
  10518. //order_id, _ := c.GetInt64("order_id")
  10519. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10520. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10521. //trig_scen := c.GetString("trig_scen")
  10522. adminUser := c.GetAdminUserInfo()
  10523. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10524. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10525. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10526. record_time := c.GetString("record_time")
  10527. order, _ := service.GetHisOrderByID(order_id)
  10528. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10529. timeLayout := "2006-01-02"
  10530. loc, _ := time.LoadLocation("Local")
  10531. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10532. if err != nil {
  10533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10534. return
  10535. }
  10536. recordDateTime := theTime.Unix()
  10537. var patientPrescription models.HisPrescriptionInfo
  10538. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10539. if patientPrescription.ID == 0 {
  10540. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10541. }
  10542. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10543. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10544. //
  10545. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10546. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10547. var pp models.PublicParams
  10548. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10549. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10550. pp.FixmedinsName = miConfig.OrgName
  10551. pp.FixmedinsCode = miConfig.Code
  10552. pp.RequestUrl = miConfig.Url
  10553. pp.Cainfo = miConfig.Cainfo
  10554. pp.SecretKey = miConfig.SecretKey
  10555. pp.AccessKey = miConfig.AccessKey
  10556. pp.OpterName = roles.UserName
  10557. var config []*models.HisXtDiagnoseConfig
  10558. for _, item := range diagnosis_ids {
  10559. id, _ := strconv.ParseInt(item, 10, 64)
  10560. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10561. config = append(config, &diagnosisConfig)
  10562. }
  10563. var pd models.PatientDtos
  10564. pd.PatnID = his.PsnNo
  10565. pd.PatnName = his.Name
  10566. pd.Gend = his.Gend
  10567. pd.Brdy = psn_info.Brdy
  10568. pd.Poolarea = his.InsuplcAdmdvs
  10569. pd.CurrMdtrtID = his.Number
  10570. var fed models.FsiEncounterDtos
  10571. fed.MdtrtID = his.Number
  10572. fed.MedinsID = miConfig.Code
  10573. fed.MedinsName = miConfig.OrgName
  10574. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10575. fed.MedMdtrtType = "1"
  10576. fed.MedinsType = "1"
  10577. fed.MedinsLv = "11"
  10578. tm := time.Unix(his.RecordDate, 0)
  10579. s_tm := tm.Format("2006-01-02 15:04:05")
  10580. fed.AdmDate = s_tm
  10581. fed.DscgDate = s_tm
  10582. fed.DscgMainDiseCodg = config[0].CountryCode
  10583. fed.DscgMainDiseName = config[0].CountryContentName
  10584. //诊断信息
  10585. var fdds []*models.FsiDiagnoseDtos
  10586. for index, item := range config {
  10587. if index == 0 {
  10588. var fdd models.FsiDiagnoseDtos
  10589. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10590. fdd.InoutDiseType = "1"
  10591. fdd.MaindiseFlag = "1"
  10592. fdd.DiseDate = s_tm
  10593. fdd.DiasSrtNo = "1"
  10594. fdd.DiseName = item.CountryContentName
  10595. fdd.DiseCodg = item.CountryCode
  10596. fdds = append(fdds, &fdd)
  10597. } else {
  10598. var fdd models.FsiDiagnoseDtos
  10599. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10600. fdd.InoutDiseType = "1"
  10601. fdd.MaindiseFlag = "1"
  10602. fdd.DiseDate = s_tm
  10603. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10604. fdd.DiseName = item.CountryContentName
  10605. fdd.DiseCodg = item.CountryCode
  10606. fdds = append(fdds, &fdd)
  10607. }
  10608. }
  10609. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10610. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10611. fed.AdmDeptName = department.Name
  10612. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10613. fed.DscgDeptName = department.Name
  10614. fed.MedType = order.MedType
  10615. //处方医嘱信息
  10616. var orders []*models.FsiOrderDtos
  10617. //for _, item := range prescriptions {
  10618. // for _, subItem := range item.HisDoctorAdviceInfo {
  10619. // var order models.FsiOrderDtos
  10620. // order.RxID = strconv.FormatInt(item.ID, 10)
  10621. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10622. // order.LongDrordFlag = "0"
  10623. // order.HilistType = "1"
  10624. // order.ChrgType = "1"
  10625. // order.DrordBhvr = "-"
  10626. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10627. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10628. // order.HilistLv = "1"
  10629. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10630. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10631. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10632. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10633. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10634. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10635. // order.OwnpayAmt = ""
  10636. // order.SelfpayAmt = ""
  10637. // order.Spec = ""
  10638. // order.SpecUnt = ""
  10639. // order.DrordBegnDate = s_tm
  10640. // order.DrordStopDate = ""
  10641. // order.DrordDrCodg = "1"
  10642. // order.DrordDeptName = department.Name
  10643. // order.DrordDrCodg = "1"
  10644. // order.DrordDrName = doctor_info.UserName
  10645. // order.DrordDrProfttl = ""
  10646. // order.CurrDrordFlag = "1"
  10647. // orders = append(orders, &order)
  10648. // }
  10649. // for _, subItem := range item.HisPrescriptionProject {
  10650. // if subItem.Type == 2 {
  10651. // var order models.FsiOrderDtos
  10652. // order.RxID = strconv.FormatInt(item.ID, 10)
  10653. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10654. // order.LongDrordFlag = "0"
  10655. // order.HilistType = "1"
  10656. // order.ChrgType = "1"
  10657. // order.DrordBhvr = "-"
  10658. // order.HilistCode = subItem.HisProject.MedicalCode
  10659. // order.HosplistName = subItem.HisProject.ProjectName
  10660. // order.HilistLv = "1"
  10661. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10662. // order.HosplistCode = subItem.HisProject.MedicalCode
  10663. // order.HosplistName = subItem.HisProject.ProjectName
  10664. // order.Cnt = subItem.Count
  10665. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10666. //
  10667. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10668. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10669. // order.OwnpayAmt = ""
  10670. // order.SelfpayAmt = ""
  10671. // order.Spec = ""
  10672. // order.SpecUnt = ""
  10673. // order.DrordBegnDate = s_tm
  10674. // order.DrordStopDate = ""
  10675. // order.DrordDrCodg = "1"
  10676. // order.DrordDeptName = department.Name
  10677. // order.DrordDrCodg = "1"
  10678. // order.DrordDrName = doctor_info.UserName
  10679. // order.DrordDrProfttl = ""
  10680. // order.CurrDrordFlag = "1"
  10681. // orders = append(orders, &order)
  10682. //
  10683. // }
  10684. // if subItem.Type == 3 {
  10685. //
  10686. // var order models.FsiOrderDtos
  10687. // order.RxID = strconv.FormatInt(item.ID, 10)
  10688. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10689. // order.LongDrordFlag = "0"
  10690. // order.HilistType = "1"
  10691. // order.ChrgType = "1"
  10692. // order.DrordBhvr = "-"
  10693. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10694. // order.HosplistName = subItem.GoodInfo.GoodName
  10695. // order.HilistLv = "1"
  10696. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10697. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10698. // order.HosplistName = subItem.GoodInfo.GoodName
  10699. // order.Cnt = subItem.Count
  10700. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10701. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10702. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10703. // order.OwnpayAmt = ""
  10704. // order.SelfpayAmt = ""
  10705. // order.Spec = ""
  10706. // order.SpecUnt = ""
  10707. // order.DrordBegnDate = s_tm
  10708. // order.DrordStopDate = ""
  10709. // order.DrordDrCodg = "1"
  10710. // order.DrordDeptName = department.Name
  10711. // order.DrordDrCodg = "1"
  10712. // order.DrordDrName = doctor_info.UserName
  10713. // order.DrordDrProfttl = ""
  10714. // order.CurrDrordFlag = "1"
  10715. // orders = append(orders, &order)
  10716. //
  10717. // }
  10718. // }
  10719. //}
  10720. for _, item := range prescriptions {
  10721. for _, subItem := range item.HisDoctorAdviceInfo {
  10722. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10723. var order models.FsiOrderDtos
  10724. order.RxID = strconv.FormatInt(item.ID, 10)
  10725. order.Rxno = strconv.FormatInt(item.ID, 10)
  10726. order.LongDrordFlag = "0"
  10727. order.HilistType = "1"
  10728. order.ChrgType = "1"
  10729. order.DrordBhvr = "-"
  10730. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10731. order.HosplistName = subItem.BaseDrugLib.DrugName
  10732. order.HilistLv = "1"
  10733. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10734. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10735. order.HosplistName = subItem.BaseDrugLib.DrugName
  10736. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10737. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10738. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10739. order.OwnpayAmt = ""
  10740. order.SelfpayAmt = ""
  10741. order.Spec = ""
  10742. order.SpecUnt = ""
  10743. order.DrordBegnDate = s_tm
  10744. order.DrordStopDate = ""
  10745. order.DrordDrCodg = doctor_info.DoctorNumber
  10746. order.DrordDeptName = department.Name
  10747. order.DrordDeptCodg = department.Number
  10748. order.DrordDrName = doctor_info.UserName
  10749. order.DrordDrProfttl = "234"
  10750. order.CurrDrordFlag = "1"
  10751. orders = append(orders, &order)
  10752. }
  10753. }
  10754. for _, subItem := range item.HisPrescriptionProject {
  10755. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10756. var order models.FsiOrderDtos
  10757. order.RxID = strconv.FormatInt(item.ID, 10)
  10758. order.Rxno = strconv.FormatInt(item.ID, 10)
  10759. order.LongDrordFlag = "0"
  10760. order.HilistType = "1"
  10761. order.ChrgType = "1"
  10762. order.DrordBhvr = "-"
  10763. order.HilistCode = subItem.HisProject.MedicalCode
  10764. order.HosplistName = subItem.HisProject.ProjectName
  10765. order.HilistLv = "1"
  10766. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10767. order.HosplistCode = subItem.HisProject.MedicalCode
  10768. order.HosplistName = subItem.HisProject.ProjectName
  10769. order.Cnt = subItem.Count
  10770. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10771. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10772. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10773. order.OwnpayAmt = ""
  10774. order.SelfpayAmt = ""
  10775. order.Spec = ""
  10776. order.SpecUnt = ""
  10777. order.DrordBegnDate = s_tm
  10778. order.DrordStopDate = ""
  10779. order.DrordDrCodg = doctor_info.DoctorNumber
  10780. order.DrordDeptName = department.Name
  10781. order.DrordDeptCodg = department.Number
  10782. order.DrordDrName = doctor_info.UserName
  10783. order.DrordDrProfttl = "234"
  10784. order.CurrDrordFlag = "1"
  10785. orders = append(orders, &order)
  10786. }
  10787. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10788. var order models.FsiOrderDtos
  10789. order.RxID = strconv.FormatInt(item.ID, 10)
  10790. order.Rxno = strconv.FormatInt(item.ID, 10)
  10791. order.LongDrordFlag = "0"
  10792. order.HilistType = "1"
  10793. order.ChrgType = "1"
  10794. order.DrordBhvr = "0"
  10795. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10796. order.HosplistName = subItem.GoodInfo.GoodName
  10797. order.HilistLv = "1"
  10798. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10799. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10800. order.HosplistName = subItem.GoodInfo.GoodName
  10801. order.Cnt = subItem.Count
  10802. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10803. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10804. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10805. order.OwnpayAmt = ""
  10806. order.SelfpayAmt = ""
  10807. order.Spec = ""
  10808. order.SpecUnt = ""
  10809. order.DrordBegnDate = s_tm
  10810. order.DrordStopDate = ""
  10811. order.DrordDrCodg = doctor_info.DoctorNumber
  10812. order.DrordDeptName = department.Name
  10813. order.DrordDeptCodg = department.Number
  10814. order.DrordDrName = doctor_info.UserName
  10815. order.DrordDrProfttl = "234"
  10816. order.CurrDrordFlag = "1"
  10817. orders = append(orders, &order)
  10818. }
  10819. }
  10820. }
  10821. //处方医嘱信息
  10822. fed.MatnStas = "0"
  10823. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10824. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10825. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10826. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10827. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10828. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10829. fed.SetlTotlnum = "1"
  10830. fed.Insutype = his.Insutype
  10831. fed.ReimFlag = "0"
  10832. fed.OutSetlFlag = "0"
  10833. var fopd []*models.FsiOperationDtosData
  10834. data := make(map[string]interface{})
  10835. data["fed"] = fed
  10836. data["fdd"] = fdds
  10837. data["fod"] = orders
  10838. data["pd"] = pd
  10839. data["pp"] = pp
  10840. data["fopd"] = fopd
  10841. data["trig_scen"] = trig_scen
  10842. client := &http.Client{}
  10843. bytesData, _ := json.Marshal(data)
  10844. var req *http.Request
  10845. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10846. if miConfig.MdtrtareaAdmvs == "320921" {
  10847. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10848. } else {
  10849. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10850. }
  10851. resp, _ := client.Do(req)
  10852. defer resp.Body.Close()
  10853. body, ioErr := ioutil.ReadAll(resp.Body)
  10854. if ioErr != nil {
  10855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10857. return res
  10858. }
  10859. var respJSON map[string]interface{}
  10860. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10863. return res
  10864. }
  10865. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10866. result, _ := json.Marshal(respJSON)
  10867. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10868. utils.ErrorLog("解析失败:%v", err)
  10869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10870. return res
  10871. }
  10872. return res
  10873. } else {
  10874. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10875. saveLog(output, input, "3102", "事中")
  10876. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10877. utils.ErrorLog("解析失败:%v", err)
  10878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10879. return
  10880. }
  10881. return res
  10882. }
  10883. return res
  10884. }
  10885. 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) {
  10886. var res Resultgd3101
  10887. adminUser := c.GetAdminUserInfo()
  10888. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10889. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10891. //record_time := c.GetString("record_time")
  10892. //trig_scen := c.GetString("trig_scen")
  10893. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10894. //psn_info, _ := service.GetPatientId(patient_id)
  10895. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10896. timeLayout := "2006-01-02"
  10897. loc, _ := time.LoadLocation("Local")
  10898. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10899. if err != nil {
  10900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10901. return res
  10902. }
  10903. recordDateTime := theTime.Unix()
  10904. var patientPrescription models.HisPrescriptionInfo
  10905. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10906. //if patientPrescription.ID == 0 {
  10907. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10908. //}
  10909. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10910. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10911. //
  10912. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10913. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10914. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10915. var pp models.PublicParams
  10916. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10917. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10918. pp.FixmedinsName = miConfig.OrgName
  10919. pp.FixmedinsCode = miConfig.Code
  10920. pp.RequestUrl = miConfig.Url
  10921. pp.Cainfo = miConfig.Cainfo
  10922. pp.SecretKey = miConfig.SecretKey
  10923. pp.AccessKey = miConfig.AccessKey
  10924. pp.OpterName = roles.UserName
  10925. var config []*models.HisXtDiagnoseConfig
  10926. for _, item := range diagnosis_ids {
  10927. id, _ := strconv.ParseInt(item, 10, 64)
  10928. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10929. config = append(config, &diagnosisConfig)
  10930. }
  10931. var pd models.PatientDtos
  10932. pd.PatnID = his.PsnNo
  10933. pd.PatnName = his.Name
  10934. pd.Gend = his.Gend
  10935. pd.Brdy = str
  10936. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10937. pd.CurrMdtrtID = his.Number
  10938. var fed models.FsiEncounterDtos
  10939. fed.MdtrtID = his.Number
  10940. fed.MedinsID = miConfig.Code
  10941. fed.MedinsName = miConfig.OrgName
  10942. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10943. fed.MedMdtrtType = "1"
  10944. fed.MedinsType = "1"
  10945. fed.MedinsLv = "11"
  10946. tm := time.Unix(his.RecordDate, 0)
  10947. s_tm := tm.Format("2006-01-02 15:04:05")
  10948. fed.AdmDate = s_tm
  10949. fed.DscgDate = s_tm
  10950. fed.DscgMainDiseCodg = config[0].CountryCode
  10951. fed.DscgMainDiseName = config[0].CountryContentName
  10952. //诊断信息
  10953. var fdds []*models.FsiDiagnoseDtos
  10954. for index, item := range config {
  10955. if index == 0 {
  10956. var fdd models.FsiDiagnoseDtos
  10957. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10958. fdd.InoutDiseType = "1"
  10959. fdd.MaindiseFlag = "1"
  10960. fdd.DiseDate = s_tm
  10961. fdd.DiasSrtNo = "1"
  10962. fdd.DiseName = item.CountryContentName
  10963. fdd.DiseCodg = item.CountryCode
  10964. fdds = append(fdds, &fdd)
  10965. } else {
  10966. var fdd models.FsiDiagnoseDtos
  10967. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10968. fdd.InoutDiseType = "1"
  10969. fdd.MaindiseFlag = "1"
  10970. fdd.DiseDate = s_tm
  10971. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10972. fdd.DiseName = item.CountryContentName
  10973. fdd.DiseCodg = item.CountryCode
  10974. fdds = append(fdds, &fdd)
  10975. }
  10976. }
  10977. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10978. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10979. fed.AdmDeptName = de.Name
  10980. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10981. fed.DscgDeptName = de.Name
  10982. fed.MedMdtrtType = "1"
  10983. fed.MedType = "11"
  10984. //if his.Insutype == "390" {
  10985. // fed.MedType = "1402"
  10986. //} else {
  10987. // fed.MedType = "9933"
  10988. //}
  10989. var orders []*models.FsiOrderDtos
  10990. if trig_scen == "2" {
  10991. //处方医嘱信息
  10992. for _, item := range prescriptions {
  10993. for _, subItem := range item.HisDoctorAdviceInfo {
  10994. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10995. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10996. var order models.FsiOrderDtos
  10997. order.RxID = strconv.FormatInt(item.ID, 10)
  10998. order.Rxno = strconv.FormatInt(item.ID, 10)
  10999. order.LongDrordFlag = "0"
  11000. order.HilistType = "1"
  11001. order.ChrgType = "1"
  11002. order.DrordBhvr = "0"
  11003. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11004. order.HosplistName = subItem.BaseDrugLib.DrugName
  11005. order.HilistLv = "1"
  11006. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11007. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11008. order.HosplistName = subItem.BaseDrugLib.DrugName
  11009. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11010. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11011. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11012. order.OwnpayAmt = ""
  11013. order.SelfpayAmt = ""
  11014. order.Spec = spec
  11015. order.SpecUnt = subItem.PrescribingNumberUnit
  11016. order.DrordBegnDate = s_tm
  11017. order.DrordStopDate = ""
  11018. order.DrordDrCodg = doctor_info.DoctorNumber
  11019. order.DrordDeptName = department.Name
  11020. order.DrordDeptCodg = department.Number
  11021. order.DrordDrName = doctor_info.UserName
  11022. order.DrordDrProfttl = "234"
  11023. order.CurrDrordFlag = "1"
  11024. orders = append(orders, &order)
  11025. }
  11026. }
  11027. for _, subItem := range item.HisPrescriptionProject {
  11028. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11029. var order models.FsiOrderDtos
  11030. order.RxID = strconv.FormatInt(item.ID, 10)
  11031. order.Rxno = strconv.FormatInt(item.ID, 10)
  11032. order.LongDrordFlag = "0"
  11033. order.HilistType = "1"
  11034. order.ChrgType = "1"
  11035. order.DrordBhvr = "0"
  11036. order.HilistCode = subItem.HisProject.MedicalCode
  11037. order.HosplistName = subItem.HisProject.ProjectName
  11038. order.HilistLv = "1"
  11039. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11040. order.HosplistCode = subItem.HisProject.MedicalCode
  11041. order.HosplistName = subItem.HisProject.ProjectName
  11042. order.Cnt = subItem.Count
  11043. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11044. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11045. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11046. order.OwnpayAmt = ""
  11047. order.SelfpayAmt = ""
  11048. order.Spec = subItem.Unit
  11049. order.SpecUnt = subItem.Unit
  11050. order.DrordBegnDate = s_tm
  11051. order.DrordStopDate = ""
  11052. order.DrordDrCodg = doctor_info.DoctorNumber
  11053. order.DrordDeptName = department.Name
  11054. order.DrordDeptCodg = department.Number
  11055. order.DrordDrName = doctor_info.UserName
  11056. order.DrordDrProfttl = "234"
  11057. order.CurrDrordFlag = "1"
  11058. orders = append(orders, &order)
  11059. }
  11060. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11061. var order models.FsiOrderDtos
  11062. order.RxID = strconv.FormatInt(item.ID, 10)
  11063. order.Rxno = strconv.FormatInt(item.ID, 10)
  11064. order.LongDrordFlag = "0"
  11065. order.HilistType = "1"
  11066. order.ChrgType = "1"
  11067. order.DrordBhvr = "0"
  11068. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11069. order.HosplistName = subItem.GoodInfo.GoodName
  11070. order.HilistLv = "1"
  11071. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11072. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11073. order.HosplistName = subItem.GoodInfo.GoodName
  11074. order.Cnt = subItem.Count
  11075. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11076. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11077. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11078. order.OwnpayAmt = ""
  11079. order.SelfpayAmt = ""
  11080. order.Spec = subItem.GoodInfo.SpecificationName
  11081. order.SpecUnt = subItem.Unit
  11082. order.DrordBegnDate = s_tm
  11083. order.DrordStopDate = ""
  11084. order.DrordDrCodg = doctor_info.DoctorNumber
  11085. order.DrordDeptName = department.Name
  11086. order.DrordDeptCodg = department.Number
  11087. order.DrordDrName = doctor_info.UserName
  11088. order.DrordDrProfttl = "234"
  11089. order.CurrDrordFlag = "1"
  11090. orders = append(orders, &order)
  11091. }
  11092. }
  11093. }
  11094. //处方医嘱信息
  11095. }
  11096. fed.MatnStas = "0"
  11097. fed.MedfeeSumamt = "0"
  11098. fed.OwnpayAmt = "0"
  11099. fed.SelfpayAmt = "0"
  11100. fed.AcctPayamt = "0"
  11101. fed.MaAmt = "0"
  11102. fed.HifpPayamt = "0"
  11103. fed.SetlTotlnum = "1"
  11104. fed.Insutype = his.Insutype
  11105. fed.ReimFlag = "0"
  11106. fed.OutSetlFlag = "0"
  11107. var fopd []*models.FsiOperationDtosData
  11108. data := make(map[string]interface{})
  11109. data["fed"] = fed
  11110. data["fdd"] = fdds
  11111. data["fod"] = orders
  11112. data["pd"] = pd
  11113. data["pp"] = pp
  11114. data["fopd"] = fopd
  11115. data["trig_scen"] = trig_scen
  11116. fmt.Println(data)
  11117. fmt.Println(fed)
  11118. fmt.Println(fdds)
  11119. fmt.Println(orders)
  11120. fmt.Println(pd)
  11121. fmt.Println(pp)
  11122. fmt.Println(fopd)
  11123. client := &http.Client{}
  11124. bytesData, _ := json.Marshal(data)
  11125. var req *http.Request
  11126. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11127. if miConfig.MdtrtareaAdmvs == "320921" {
  11128. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11129. } else {
  11130. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11131. }
  11132. resp, _ := client.Do(req)
  11133. defer resp.Body.Close()
  11134. body, ioErr := ioutil.ReadAll(resp.Body)
  11135. if ioErr != nil {
  11136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11138. return res
  11139. }
  11140. var respJSON map[string]interface{}
  11141. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11144. return res
  11145. }
  11146. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11147. fmt.Println(respJSON)
  11148. result, _ := json.Marshal(respJSON)
  11149. fmt.Println(result)
  11150. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11151. utils.ErrorLog("解析失败:%v", err)
  11152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11153. return res
  11154. }
  11155. return res
  11156. } else {
  11157. //if miConfig.MdtrtareaAdmvs == "441202" {
  11158. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11159. saveLog(output, input, "3101", "事前")
  11160. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11161. utils.ErrorLog("解析失败:%v", err)
  11162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11163. return
  11164. }
  11165. return res
  11166. //}
  11167. }
  11168. }
  11169. 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) {
  11170. adminUser := c.GetAdminUserInfo()
  11171. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11172. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11173. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11174. //record_time := c.GetString("record_time")
  11175. //trig_scen := c.GetString("trig_scen")
  11176. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11177. timeLayout := "2006-01-02"
  11178. loc, _ := time.LoadLocation("Local")
  11179. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11180. if err != nil {
  11181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11182. return res
  11183. }
  11184. recordDateTime := theTime.Unix()
  11185. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11186. var patientPrescription models.HisPrescriptionInfo
  11187. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11188. if patientPrescription.ID == 0 {
  11189. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11190. }
  11191. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11192. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11193. //
  11194. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11195. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11196. var pp models.PublicParams
  11197. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11198. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11199. pp.FixmedinsName = miConfig.OrgName
  11200. pp.FixmedinsCode = miConfig.Code
  11201. pp.RequestUrl = miConfig.Url
  11202. pp.Cainfo = miConfig.Cainfo
  11203. pp.SecretKey = miConfig.SecretKey
  11204. pp.AccessKey = miConfig.AccessKey
  11205. pp.OpterName = roles.UserName
  11206. var config []*models.HisXtDiagnoseConfig
  11207. for _, item := range diagnosis_ids {
  11208. id, _ := strconv.ParseInt(item, 10, 64)
  11209. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11210. config = append(config, &diagnosisConfig)
  11211. }
  11212. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11213. var pd models.PatientDtos
  11214. pd.PatnID = his.PsnNo
  11215. pd.PatnName = his.Name
  11216. pd.Gend = his.Gend
  11217. pd.Brdy = str
  11218. pd.Poolarea = his.InsuplcAdmdvs
  11219. pd.CurrMdtrtID = his.Number
  11220. var fed models.FsiEncounterDtos
  11221. fed.MdtrtID = his.Number
  11222. fed.MedinsID = miConfig.Code
  11223. fed.MedinsName = miConfig.OrgName
  11224. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11225. fed.MedMdtrtType = "1"
  11226. fed.MedinsType = "1"
  11227. fed.MedinsLv = "11"
  11228. tm := time.Unix(his.RecordDate, 0)
  11229. s_tm := tm.Format("2006-01-02 15:04:05")
  11230. fed.AdmDate = s_tm
  11231. fed.DscgDate = s_tm
  11232. fed.DscgMainDiseCodg = config[0].CountryCode
  11233. fed.DscgMainDiseName = config[0].CountryContentName
  11234. //诊断信息
  11235. var fdds []*models.FsiDiagnoseDtos
  11236. for index, item := range config {
  11237. if index == 0 {
  11238. var fdd models.FsiDiagnoseDtos
  11239. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11240. fdd.InoutDiseType = "1"
  11241. fdd.MaindiseFlag = "1"
  11242. fdd.DiseDate = s_tm
  11243. fdd.DiasSrtNo = "1"
  11244. fdd.DiseName = item.CountryContentName
  11245. fdd.DiseCodg = item.CountryCode
  11246. fdds = append(fdds, &fdd)
  11247. } else {
  11248. var fdd models.FsiDiagnoseDtos
  11249. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11250. fdd.InoutDiseType = "1"
  11251. fdd.MaindiseFlag = "1"
  11252. fdd.DiseDate = s_tm
  11253. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11254. fdd.DiseName = item.CountryContentName
  11255. fdd.DiseCodg = item.CountryCode
  11256. fdds = append(fdds, &fdd)
  11257. }
  11258. }
  11259. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11260. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11261. fed.AdmDeptName = department.Name
  11262. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11263. fed.DscgDeptName = department.Name
  11264. fed.MedMdtrtType = "1"
  11265. fed.MedType = "11"
  11266. //if his.Insutype == "390" {
  11267. // fed.MedType = "1402"
  11268. //} else {
  11269. // fed.MedType = "9933"
  11270. //}
  11271. var orders []*models.FsiOrderDtos
  11272. if trig_scen == "2" {
  11273. //处方医嘱信息
  11274. for _, item := range prescriptions {
  11275. for _, subItem := range item.HisDoctorAdviceInfo {
  11276. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11277. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11278. var order models.FsiOrderDtos
  11279. order.RxID = strconv.FormatInt(item.ID, 10)
  11280. order.Rxno = strconv.FormatInt(item.ID, 10)
  11281. order.LongDrordFlag = "0"
  11282. order.HilistType = "1"
  11283. order.ChrgType = "1"
  11284. order.DrordBhvr = "0"
  11285. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11286. order.HosplistName = subItem.BaseDrugLib.DrugName
  11287. order.HilistLv = "1"
  11288. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11289. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11290. order.HosplistName = subItem.BaseDrugLib.DrugName
  11291. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11292. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11293. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11294. order.OwnpayAmt = ""
  11295. order.SelfpayAmt = ""
  11296. order.Spec = spec
  11297. order.SpecUnt = subItem.PrescribingNumberUnit
  11298. order.DrordBegnDate = s_tm
  11299. order.DrordStopDate = ""
  11300. order.DrordDrCodg = doctor_info.DoctorNumber
  11301. order.DrordDeptName = department.Name
  11302. order.DrordDeptCodg = department.Number
  11303. order.DrordDrName = doctor_info.UserName
  11304. order.DrordDrProfttl = "234"
  11305. order.CurrDrordFlag = "1"
  11306. orders = append(orders, &order)
  11307. }
  11308. }
  11309. for _, subItem := range item.HisPrescriptionProject {
  11310. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11311. var order models.FsiOrderDtos
  11312. order.RxID = strconv.FormatInt(item.ID, 10)
  11313. order.Rxno = strconv.FormatInt(item.ID, 10)
  11314. order.LongDrordFlag = "0"
  11315. order.HilistType = "1"
  11316. order.ChrgType = "1"
  11317. order.DrordBhvr = "0"
  11318. order.HilistCode = subItem.HisProject.MedicalCode
  11319. order.HosplistName = subItem.HisProject.ProjectName
  11320. order.HilistLv = "1"
  11321. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11322. order.HosplistCode = subItem.HisProject.MedicalCode
  11323. order.HosplistName = subItem.HisProject.ProjectName
  11324. order.Cnt = subItem.Count
  11325. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11326. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11327. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11328. order.OwnpayAmt = ""
  11329. order.SelfpayAmt = ""
  11330. order.Spec = subItem.Unit
  11331. order.SpecUnt = subItem.Unit
  11332. order.DrordBegnDate = s_tm
  11333. order.DrordStopDate = ""
  11334. order.DrordDrCodg = doctor_info.DoctorNumber
  11335. order.DrordDeptName = department.Name
  11336. order.DrordDeptCodg = department.Number
  11337. order.DrordDrName = doctor_info.UserName
  11338. order.DrordDrProfttl = "234"
  11339. order.CurrDrordFlag = "1"
  11340. orders = append(orders, &order)
  11341. }
  11342. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11343. var order models.FsiOrderDtos
  11344. order.RxID = strconv.FormatInt(item.ID, 10)
  11345. order.Rxno = strconv.FormatInt(item.ID, 10)
  11346. order.LongDrordFlag = "0"
  11347. order.HilistType = "1"
  11348. order.ChrgType = "1"
  11349. order.DrordBhvr = "0"
  11350. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11351. order.HosplistName = subItem.GoodInfo.GoodName
  11352. order.HilistLv = "1"
  11353. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11354. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11355. order.HosplistName = subItem.GoodInfo.GoodName
  11356. order.Cnt = subItem.Count
  11357. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11358. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11359. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11360. order.OwnpayAmt = ""
  11361. order.SelfpayAmt = ""
  11362. order.Spec = subItem.GoodInfo.SpecificationName
  11363. order.SpecUnt = subItem.Unit
  11364. order.DrordBegnDate = s_tm
  11365. order.DrordStopDate = ""
  11366. order.DrordDrCodg = doctor_info.DoctorNumber
  11367. order.DrordDeptName = department.Name
  11368. order.DrordDeptCodg = department.Number
  11369. order.DrordDrName = doctor_info.UserName
  11370. order.DrordDrProfttl = "234"
  11371. order.CurrDrordFlag = "1"
  11372. orders = append(orders, &order)
  11373. }
  11374. }
  11375. }
  11376. //处方医嘱信息
  11377. }
  11378. fed.MatnStas = "0"
  11379. fed.MedfeeSumamt = "0"
  11380. fed.OwnpayAmt = "0"
  11381. fed.SelfpayAmt = "0"
  11382. fed.AcctPayamt = "0"
  11383. fed.MaAmt = "0"
  11384. fed.HifpPayamt = "0"
  11385. fed.SetlTotlnum = "1"
  11386. fed.Insutype = his.Insutype
  11387. fed.ReimFlag = "0"
  11388. fed.OutSetlFlag = "0"
  11389. var fopd []*models.FsiOperationDtosData
  11390. data := make(map[string]interface{})
  11391. data["fed"] = fed
  11392. data["fdd"] = fdds
  11393. data["fod"] = orders
  11394. data["pd"] = pd
  11395. data["pp"] = pp
  11396. data["fopd"] = fopd
  11397. data["trig_scen"] = trig_scen
  11398. fmt.Println(data)
  11399. fmt.Println(fed)
  11400. fmt.Println(fdds)
  11401. fmt.Println(orders)
  11402. fmt.Println(pd)
  11403. fmt.Println(pp)
  11404. fmt.Println(fopd)
  11405. client := &http.Client{}
  11406. bytesData, _ := json.Marshal(data)
  11407. var req *http.Request
  11408. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11409. if miConfig.MdtrtareaAdmvs == "320921" {
  11410. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11411. } else {
  11412. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11413. }
  11414. resp, _ := client.Do(req)
  11415. defer resp.Body.Close()
  11416. body, ioErr := ioutil.ReadAll(resp.Body)
  11417. if ioErr != nil {
  11418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11420. return res
  11421. }
  11422. var respJSON map[string]interface{}
  11423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11426. return res
  11427. }
  11428. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11429. fmt.Println(respJSON)
  11430. result, _ := json.Marshal(respJSON)
  11431. fmt.Println(result)
  11432. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11433. utils.ErrorLog("解析失败:%v", err)
  11434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11435. return res
  11436. }
  11437. return res
  11438. } else {
  11439. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11440. saveLog(output, input, "3101", "事前")
  11441. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11442. utils.ErrorLog("解析失败:%v", err)
  11443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11444. return
  11445. }
  11446. return res
  11447. }
  11448. return res
  11449. }
  11450. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11451. ////patient_id, _ := c.GetInt64("patient_id")
  11452. //order_id, _ := c.GetInt64("order_id")
  11453. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11454. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11455. //trig_scen := c.GetString("trig_scen")
  11456. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11457. //utils.ErrorLog("解析失败:%v", psn_info)
  11458. adminUser := c.GetAdminUserInfo()
  11459. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11460. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11461. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11462. record_time := c.GetString("record_time")
  11463. order, _ := service.GetHisOrderByID(order_id)
  11464. timeLayout := "2006-01-02"
  11465. loc, _ := time.LoadLocation("Local")
  11466. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11467. if err != nil {
  11468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11469. return
  11470. }
  11471. recordDateTime := theTime.Unix()
  11472. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11473. var patientPrescription models.HisPrescriptionInfo
  11474. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11475. if patientPrescription.ID == 0 {
  11476. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11477. }
  11478. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11479. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11480. //
  11481. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11482. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11483. var pp models.PublicParams
  11484. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11485. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11486. pp.FixmedinsName = miConfig.OrgName
  11487. pp.FixmedinsCode = miConfig.Code
  11488. pp.RequestUrl = miConfig.Url
  11489. pp.Cainfo = miConfig.Cainfo
  11490. pp.SecretKey = miConfig.SecretKey
  11491. pp.AccessKey = miConfig.AccessKey
  11492. pp.OpterName = roles.UserName
  11493. var config []*models.HisXtDiagnoseConfig
  11494. for _, item := range diagnosis_ids {
  11495. id, _ := strconv.ParseInt(item, 10, 64)
  11496. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11497. config = append(config, &diagnosisConfig)
  11498. }
  11499. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11500. var pd models.PatientDtos
  11501. pd.PatnID = his.PsnNo
  11502. pd.PatnName = his.Name
  11503. pd.Gend = his.Gend
  11504. pd.Brdy = str
  11505. pd.Poolarea = his.InsuplcAdmdvs
  11506. pd.CurrMdtrtID = his.Number
  11507. var fed models.FsiEncounterDtos
  11508. fed.MdtrtID = his.Number
  11509. fed.MedinsID = miConfig.Code
  11510. fed.MedinsName = miConfig.OrgName
  11511. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11512. fed.MedMdtrtType = "1"
  11513. fed.MedinsType = "1"
  11514. fed.MedinsLv = "11"
  11515. tm := time.Unix(his.RecordDate, 0)
  11516. s_tm := tm.Format("2006-01-02 15:04:05")
  11517. fed.AdmDate = s_tm
  11518. fed.DscgDate = s_tm
  11519. fed.DscgMainDiseCodg = config[0].CountryCode
  11520. fed.DscgMainDiseName = config[0].CountryContentName
  11521. //诊断信息
  11522. var fdds []*models.FsiDiagnoseDtos
  11523. for index, item := range config {
  11524. if index == 0 {
  11525. var fdd models.FsiDiagnoseDtos
  11526. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11527. fdd.InoutDiseType = "1"
  11528. fdd.MaindiseFlag = "1"
  11529. fdd.DiseDate = s_tm
  11530. fdd.DiasSrtNo = "1"
  11531. fdd.DiseName = item.CountryContentName
  11532. fdd.DiseCodg = item.CountryCode
  11533. fdds = append(fdds, &fdd)
  11534. } else {
  11535. var fdd models.FsiDiagnoseDtos
  11536. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11537. fdd.InoutDiseType = "1"
  11538. fdd.MaindiseFlag = "1"
  11539. fdd.DiseDate = s_tm
  11540. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11541. fdd.DiseName = item.CountryContentName
  11542. fdd.DiseCodg = item.CountryCode
  11543. fdds = append(fdds, &fdd)
  11544. }
  11545. }
  11546. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11547. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11548. fed.AdmDeptName = department.Name
  11549. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11550. fed.DscgDeptName = department.Name
  11551. fed.MedType = order.MedType
  11552. //处方医嘱信息
  11553. var orders []*models.FsiOrderDtos
  11554. //for _, item := range prescriptions {
  11555. // for _, subItem := range item.HisDoctorAdviceInfo {
  11556. // var order models.FsiOrderDtos
  11557. // order.RxID = strconv.FormatInt(item.ID, 10)
  11558. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11559. // order.LongDrordFlag = "0"
  11560. // order.HilistType = "1"
  11561. // order.ChrgType = "1"
  11562. // order.DrordBhvr = "-"
  11563. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11564. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11565. // order.HilistLv = "1"
  11566. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11567. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11568. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11569. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11570. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11571. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11572. // order.OwnpayAmt = ""
  11573. // order.SelfpayAmt = ""
  11574. // order.Spec = ""
  11575. // order.SpecUnt = ""
  11576. // order.DrordBegnDate = s_tm
  11577. // order.DrordStopDate = ""
  11578. // order.DrordDrCodg = "1"
  11579. // order.DrordDeptName = department.Name
  11580. // order.DrordDrCodg = "1"
  11581. // order.DrordDrName = doctor_info.UserName
  11582. // order.DrordDrProfttl = ""
  11583. // order.CurrDrordFlag = "1"
  11584. // orders = append(orders, &order)
  11585. // }
  11586. // for _, subItem := range item.HisPrescriptionProject {
  11587. // if subItem.Type == 2 {
  11588. // var order models.FsiOrderDtos
  11589. // order.RxID = strconv.FormatInt(item.ID, 10)
  11590. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11591. // order.LongDrordFlag = "0"
  11592. // order.HilistType = "1"
  11593. // order.ChrgType = "1"
  11594. // order.DrordBhvr = "-"
  11595. // order.HilistCode = subItem.HisProject.MedicalCode
  11596. // order.HosplistName = subItem.HisProject.ProjectName
  11597. // order.HilistLv = "1"
  11598. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11599. // order.HosplistCode = subItem.HisProject.MedicalCode
  11600. // order.HosplistName = subItem.HisProject.ProjectName
  11601. // order.Cnt = subItem.Count
  11602. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11603. //
  11604. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11605. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11606. // order.OwnpayAmt = ""
  11607. // order.SelfpayAmt = ""
  11608. // order.Spec = ""
  11609. // order.SpecUnt = ""
  11610. // order.DrordBegnDate = s_tm
  11611. // order.DrordStopDate = ""
  11612. // order.DrordDrCodg = "1"
  11613. // order.DrordDeptName = department.Name
  11614. // order.DrordDrCodg = "1"
  11615. // order.DrordDrName = doctor_info.UserName
  11616. // order.DrordDrProfttl = ""
  11617. // order.CurrDrordFlag = "1"
  11618. // orders = append(orders, &order)
  11619. //
  11620. // }
  11621. // if subItem.Type == 3 {
  11622. //
  11623. // var order models.FsiOrderDtos
  11624. // order.RxID = strconv.FormatInt(item.ID, 10)
  11625. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11626. // order.LongDrordFlag = "0"
  11627. // order.HilistType = "1"
  11628. // order.ChrgType = "1"
  11629. // order.DrordBhvr = "-"
  11630. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11631. // order.HosplistName = subItem.GoodInfo.GoodName
  11632. // order.HilistLv = "1"
  11633. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11634. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11635. // order.HosplistName = subItem.GoodInfo.GoodName
  11636. // order.Cnt = subItem.Count
  11637. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11638. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11639. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11640. // order.OwnpayAmt = ""
  11641. // order.SelfpayAmt = ""
  11642. // order.Spec = ""
  11643. // order.SpecUnt = ""
  11644. // order.DrordBegnDate = s_tm
  11645. // order.DrordStopDate = ""
  11646. // order.DrordDrCodg = "1"
  11647. // order.DrordDeptName = department.Name
  11648. // order.DrordDrCodg = "1"
  11649. // order.DrordDrName = doctor_info.UserName
  11650. // order.DrordDrProfttl = ""
  11651. // order.CurrDrordFlag = "1"
  11652. // orders = append(orders, &order)
  11653. //
  11654. // }
  11655. // }
  11656. //}
  11657. for _, item := range prescriptions {
  11658. for _, subItem := range item.HisDoctorAdviceInfo {
  11659. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11660. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11661. var order models.FsiOrderDtos
  11662. order.RxID = strconv.FormatInt(item.ID, 10)
  11663. order.Rxno = strconv.FormatInt(item.ID, 10)
  11664. order.LongDrordFlag = "0"
  11665. order.HilistType = "1"
  11666. order.ChrgType = "1"
  11667. order.DrordBhvr = "0"
  11668. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11669. order.HosplistName = subItem.BaseDrugLib.DrugName
  11670. order.HilistLv = "1"
  11671. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11672. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11673. order.HosplistName = subItem.BaseDrugLib.DrugName
  11674. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11675. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11676. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11677. order.OwnpayAmt = ""
  11678. order.SelfpayAmt = ""
  11679. order.Spec = spec
  11680. order.SpecUnt = subItem.PrescribingNumberUnit
  11681. order.DrordBegnDate = s_tm
  11682. order.DrordStopDate = ""
  11683. order.DrordDrCodg = doctor_info.DoctorNumber
  11684. order.DrordDeptName = department.Name
  11685. order.DrordDeptCodg = department.Number
  11686. order.DrordDrName = doctor_info.UserName
  11687. order.DrordDrProfttl = "234"
  11688. order.CurrDrordFlag = "1"
  11689. orders = append(orders, &order)
  11690. }
  11691. }
  11692. for _, subItem := range item.HisPrescriptionProject {
  11693. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11694. var order models.FsiOrderDtos
  11695. order.RxID = strconv.FormatInt(item.ID, 10)
  11696. order.Rxno = strconv.FormatInt(item.ID, 10)
  11697. order.LongDrordFlag = "0"
  11698. order.HilistType = "1"
  11699. order.ChrgType = "1"
  11700. order.DrordBhvr = "0"
  11701. order.HilistCode = subItem.HisProject.MedicalCode
  11702. order.HosplistName = subItem.HisProject.ProjectName
  11703. order.HilistLv = "1"
  11704. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11705. order.HosplistCode = subItem.HisProject.MedicalCode
  11706. order.HosplistName = subItem.HisProject.ProjectName
  11707. order.Cnt = subItem.Count
  11708. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11709. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11710. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11711. order.OwnpayAmt = ""
  11712. order.SelfpayAmt = ""
  11713. order.Spec = subItem.Unit
  11714. order.SpecUnt = subItem.Unit
  11715. order.DrordBegnDate = s_tm
  11716. order.DrordStopDate = ""
  11717. order.DrordDrCodg = doctor_info.DoctorNumber
  11718. order.DrordDeptName = department.Name
  11719. order.DrordDeptCodg = department.Number
  11720. order.DrordDrName = doctor_info.UserName
  11721. order.DrordDrProfttl = "234"
  11722. order.CurrDrordFlag = "1"
  11723. orders = append(orders, &order)
  11724. }
  11725. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11726. var order models.FsiOrderDtos
  11727. order.RxID = strconv.FormatInt(item.ID, 10)
  11728. order.Rxno = strconv.FormatInt(item.ID, 10)
  11729. order.LongDrordFlag = "0"
  11730. order.HilistType = "1"
  11731. order.ChrgType = "1"
  11732. order.DrordBhvr = "0"
  11733. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11734. order.HosplistName = subItem.GoodInfo.GoodName
  11735. order.HilistLv = "1"
  11736. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11737. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11738. order.HosplistName = subItem.GoodInfo.GoodName
  11739. order.Cnt = subItem.Count
  11740. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11741. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11742. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11743. order.OwnpayAmt = ""
  11744. order.SelfpayAmt = ""
  11745. order.Spec = subItem.GoodInfo.SpecificationName
  11746. order.SpecUnt = subItem.Unit
  11747. order.DrordBegnDate = s_tm
  11748. order.DrordStopDate = ""
  11749. order.DrordDrCodg = doctor_info.DoctorNumber
  11750. order.DrordDeptName = department.Name
  11751. order.DrordDeptCodg = department.Number
  11752. order.DrordDrName = doctor_info.UserName
  11753. order.DrordDrProfttl = "234"
  11754. order.CurrDrordFlag = "1"
  11755. orders = append(orders, &order)
  11756. }
  11757. }
  11758. }
  11759. //处方医嘱信息
  11760. fed.MatnStas = "0"
  11761. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11762. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11763. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11764. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11765. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11766. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11767. fed.SetlTotlnum = "1"
  11768. fed.Insutype = his.Insutype
  11769. fed.ReimFlag = "0"
  11770. fed.OutSetlFlag = "0"
  11771. var fopd []*models.FsiOperationDtosData
  11772. data := make(map[string]interface{})
  11773. data["fed"] = fed
  11774. data["fdd"] = fdds
  11775. data["fod"] = orders
  11776. data["pd"] = pd
  11777. data["pp"] = pp
  11778. data["fopd"] = fopd
  11779. data["trig_scen"] = trig_scen
  11780. client := &http.Client{}
  11781. bytesData, _ := json.Marshal(data)
  11782. var req *http.Request
  11783. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11784. if miConfig.MdtrtareaAdmvs == "320921" {
  11785. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11786. } else {
  11787. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11788. }
  11789. resp, _ := client.Do(req)
  11790. defer resp.Body.Close()
  11791. body, ioErr := ioutil.ReadAll(resp.Body)
  11792. if ioErr != nil {
  11793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11795. return res
  11796. }
  11797. var respJSON map[string]interface{}
  11798. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11801. return res
  11802. }
  11803. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11804. result, _ := json.Marshal(respJSON)
  11805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11806. utils.ErrorLog("解析失败:%v", err)
  11807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11808. return res
  11809. }
  11810. return res
  11811. } else {
  11812. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11813. saveLog(output, input, "3102", "事中")
  11814. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11815. utils.ErrorLog("解析失败:%v", err)
  11816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11817. return
  11818. }
  11819. return res
  11820. }
  11821. return res
  11822. }
  11823. func (c *HisApiController) Check() {
  11824. psn_no := c.GetString("psn_no")
  11825. in := c.GetString("in")
  11826. mt := c.GetString("mt")
  11827. baseParams := models.BaseParams{
  11828. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11829. FixmedinsCode: "H15049901371",
  11830. InsuplcAdmdvs: "150499",
  11831. MdtrtareaAdmvs: "150499",
  11832. OrgName: "赤峰费森血液透析中心",
  11833. Doctor: "1111",
  11834. }
  11835. service.Gdyb2001(baseParams, psn_no, in, mt)
  11836. }
  11837. func (c *HisApiController) GetPsnNcdsInfo() {
  11838. admin_user_id, _ := c.GetInt64("admin_user_id")
  11839. patient_id, _ := c.GetInt64("patient_id")
  11840. //id, _ := c.GetInt64("id")
  11841. adminUser := c.GetAdminUserInfo()
  11842. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11843. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11844. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11845. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11846. //psn_record, _ := service.GetP(id)
  11847. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11848. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11849. //
  11850. //if psn_record.ID == 0 {
  11851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11852. // return
  11853. //}
  11854. var res Result5301
  11855. var res10265 Result5301For10265
  11856. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11857. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11858. var api string
  11859. if miConfig.MdtrtareaAdmvs == "320921" {
  11860. 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 +
  11861. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11862. } else {
  11863. 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 +
  11864. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11865. }
  11866. resp, requestErr := http.Get(api)
  11867. if requestErr != nil {
  11868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11869. return
  11870. }
  11871. body, ioErr := ioutil.ReadAll(resp.Body)
  11872. if ioErr != nil {
  11873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11875. return
  11876. }
  11877. var respJSON map[string]interface{}
  11878. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11881. return
  11882. }
  11883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11884. result, _ := json.Marshal(respJSON)
  11885. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11886. utils.ErrorLog("解析失败:%v", err)
  11887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11888. return
  11889. }
  11890. res.ErrMsg = res10265.ErrMsg
  11891. res.Output = res10265.Output
  11892. res.InfRefmsgid = res10265.InfRefmsgid
  11893. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11894. res.Infcode = infocode
  11895. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11896. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11897. var api string
  11898. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11899. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11900. resp, requestErr := http.Get(api)
  11901. if requestErr != nil {
  11902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11903. return
  11904. }
  11905. body, ioErr := ioutil.ReadAll(resp.Body)
  11906. if ioErr != nil {
  11907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11909. return
  11910. }
  11911. var respJSON map[string]interface{}
  11912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11915. return
  11916. }
  11917. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11918. if status == "0" {
  11919. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11920. c.ServeSuccessJSON(map[string]interface{}{
  11921. "failed_code": -10,
  11922. "msg": err_msg,
  11923. })
  11924. return
  11925. }
  11926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11927. result, _ := json.Marshal(respJSON)
  11928. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11929. utils.ErrorLog("解析失败:%v", err)
  11930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11931. return
  11932. }
  11933. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11934. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  11935. var api string
  11936. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11937. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11938. resp, requestErr := http.Get(api)
  11939. if requestErr != nil {
  11940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11941. return
  11942. }
  11943. body, ioErr := ioutil.ReadAll(resp.Body)
  11944. if ioErr != nil {
  11945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11947. return
  11948. }
  11949. var respJSON map[string]interface{}
  11950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11953. return
  11954. }
  11955. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11956. if status == "0" {
  11957. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11958. c.ServeSuccessJSON(map[string]interface{}{
  11959. "failed_code": -10,
  11960. "msg": err_msg,
  11961. })
  11962. return
  11963. }
  11964. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11965. result, _ := json.Marshal(respJSON)
  11966. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11967. utils.ErrorLog("解析失败:%v", err)
  11968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11969. return
  11970. }
  11971. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11972. p, _ := service.GetHisPatientById(patient_id)
  11973. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11974. var dat map[string]interface{}
  11975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11976. fmt.Println(dat)
  11977. } else {
  11978. fmt.Println(err)
  11979. }
  11980. userJSONBytes, _ := json.Marshal(dat)
  11981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11982. utils.ErrorLog("解析失败:%v", err)
  11983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11984. return
  11985. }
  11986. } else if miConfig.MdtrtareaAdmvs == "361025" {
  11987. p, _ := service.GetHisPatientById(patient_id)
  11988. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11989. var dat map[string]interface{}
  11990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11991. fmt.Println(dat)
  11992. } else {
  11993. fmt.Println(err)
  11994. }
  11995. userJSONBytes, _ := json.Marshal(dat)
  11996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11997. utils.ErrorLog("解析失败:%v", err)
  11998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11999. return
  12000. }
  12001. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12002. p, _ := service.GetHisPatientById(patient_id)
  12003. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12004. var dat map[string]interface{}
  12005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12006. fmt.Println(dat)
  12007. } else {
  12008. fmt.Println(err)
  12009. }
  12010. userJSONBytes, _ := json.Marshal(dat)
  12011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12012. utils.ErrorLog("解析失败:%v", err)
  12013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12014. return
  12015. }
  12016. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12017. p, _ := service.GetHisPatientById(patient_id)
  12018. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12019. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12020. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12021. resp, requestErr := http.Get(api)
  12022. if requestErr != nil {
  12023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12024. return
  12025. }
  12026. body, ioErr := ioutil.ReadAll(resp.Body)
  12027. if ioErr != nil {
  12028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12030. return
  12031. }
  12032. var respJSON map[string]interface{}
  12033. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12036. return
  12037. }
  12038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12039. result, _ := json.Marshal(respJSON)
  12040. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12041. utils.ErrorLog("解析失败:%v", err)
  12042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12043. return
  12044. }
  12045. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12046. p, _ := service.GetHisPatientById(patient_id)
  12047. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12048. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12049. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12050. resp, requestErr := http.Get(api)
  12051. if requestErr != nil {
  12052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12053. return
  12054. }
  12055. body, ioErr := ioutil.ReadAll(resp.Body)
  12056. if ioErr != nil {
  12057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12059. return
  12060. }
  12061. var respJSON map[string]interface{}
  12062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12065. return
  12066. }
  12067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12068. result, _ := json.Marshal(respJSON)
  12069. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12070. utils.ErrorLog("解析失败:%v", err)
  12071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12072. return
  12073. }
  12074. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12075. p, _ := service.GetHisPatientById(patient_id)
  12076. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12077. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12078. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12079. resp, requestErr := http.Get(api)
  12080. if requestErr != nil {
  12081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12082. return
  12083. }
  12084. body, ioErr := ioutil.ReadAll(resp.Body)
  12085. if ioErr != nil {
  12086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12088. return
  12089. }
  12090. var respJSON map[string]interface{}
  12091. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12094. return
  12095. }
  12096. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12097. result, _ := json.Marshal(respJSON)
  12098. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12099. utils.ErrorLog("解析失败:%v", err)
  12100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12101. return
  12102. }
  12103. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12104. p, _ := service.GetHisPatientById(patient_id)
  12105. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12106. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12107. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12108. resp, requestErr := http.Get(api)
  12109. if requestErr != nil {
  12110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12111. return
  12112. }
  12113. body, ioErr := ioutil.ReadAll(resp.Body)
  12114. if ioErr != nil {
  12115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12117. return
  12118. }
  12119. var respJSON map[string]interface{}
  12120. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12123. return
  12124. }
  12125. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12126. result, _ := json.Marshal(respJSON)
  12127. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12128. utils.ErrorLog("解析失败:%v", err)
  12129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12130. return
  12131. }
  12132. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12133. p, _ := service.GetHisPatientById(patient_id)
  12134. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12135. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12136. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12137. resp, requestErr := http.Get(api)
  12138. if requestErr != nil {
  12139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12140. return
  12141. }
  12142. body, ioErr := ioutil.ReadAll(resp.Body)
  12143. if ioErr != nil {
  12144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12146. return
  12147. }
  12148. var respJSON map[string]interface{}
  12149. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12152. return
  12153. }
  12154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12155. result, _ := json.Marshal(respJSON)
  12156. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12157. utils.ErrorLog("解析失败:%v", err)
  12158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12159. return
  12160. }
  12161. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12162. p, _ := service.GetHisPatientById(patient_id)
  12163. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12164. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12165. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12166. resp, requestErr := http.Get(api)
  12167. if requestErr != nil {
  12168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12169. return
  12170. }
  12171. body, ioErr := ioutil.ReadAll(resp.Body)
  12172. if ioErr != nil {
  12173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12175. return
  12176. }
  12177. var respJSON map[string]interface{}
  12178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12181. return
  12182. }
  12183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12184. result, _ := json.Marshal(respJSON)
  12185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12186. utils.ErrorLog("解析失败:%v", err)
  12187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12188. return
  12189. }
  12190. } else {
  12191. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12192. var dat map[string]interface{}
  12193. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12194. fmt.Println(dat)
  12195. } else {
  12196. fmt.Println(err)
  12197. }
  12198. userJSONBytes, _ := json.Marshal(dat)
  12199. if miConfig.Code == "H15049901371" {
  12200. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12201. utils.ErrorLog("解析失败:%v", err)
  12202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12203. return
  12204. }
  12205. res.InfRefmsgid = res10265.InfRefmsgid
  12206. res.Output = res10265.Output
  12207. res.ErrMsg = res10265.ErrMsg
  12208. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12209. res.Infcode = infocode
  12210. } else {
  12211. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12212. utils.ErrorLog("解析失败:%v", err)
  12213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. return
  12215. }
  12216. }
  12217. }
  12218. if res.Infcode == 0 {
  12219. c.ServeSuccessJSON(map[string]interface{}{
  12220. "result": res.Output.Result,
  12221. })
  12222. }
  12223. }
  12224. func (c *HisApiController) CheckInsutype() {
  12225. his_patient_id, _ := c.GetInt64("his_patient_id")
  12226. admin_user_id, _ := c.GetInt64("admin_user_id")
  12227. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12228. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12230. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12231. var dat map[string]interface{}
  12232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12233. fmt.Println(dat)
  12234. } else {
  12235. fmt.Println(err)
  12236. }
  12237. userJSONBytes, _ := json.Marshal(dat)
  12238. var res Result90100
  12239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12240. utils.ErrorLog("解析失败:%v", err)
  12241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12242. return
  12243. }
  12244. if res.Infcode != 0 {
  12245. c.ServeSuccessJSON(map[string]interface{}{
  12246. "failed_code": -10,
  12247. "msg": res.ErrMsg,
  12248. })
  12249. return
  12250. } else {
  12251. fmt.Println(res)
  12252. }
  12253. }
  12254. func (c *HisApiController) CheckCardPWD() {
  12255. card_pwd := c.GetString("card_pwd")
  12256. his_patient_id, _ := c.GetInt64("his_patient_id")
  12257. admin_user_id, _ := c.GetInt64("admin_user_id")
  12258. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12259. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12260. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12261. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12262. bas := strings.Split(psn.CardInfo, "|")
  12263. basNumber := bas[2]
  12264. if psn.InsuplcAdmdvs[:4] == "4403" {
  12265. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12266. var dat map[string]interface{}
  12267. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12268. fmt.Println(dat)
  12269. } else {
  12270. fmt.Println(err)
  12271. }
  12272. userJSONBytes, _ := json.Marshal(dat)
  12273. var res Result90991
  12274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12275. utils.ErrorLog("解析失败:%v", err)
  12276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12277. return
  12278. }
  12279. if res.Infcode != 0 {
  12280. c.ServeSuccessJSON(map[string]interface{}{
  12281. "failed_code": -10,
  12282. "msg": res.ErrMsg,
  12283. })
  12284. return
  12285. } else {
  12286. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12287. var msg string
  12288. switch res.Output.Result.CardStat {
  12289. case "00":
  12290. msg = "未激活"
  12291. break
  12292. case "10":
  12293. msg = "激活"
  12294. break
  12295. case "20":
  12296. msg = "窗口挂失"
  12297. break
  12298. case "21":
  12299. msg = "电话挂失"
  12300. break
  12301. case "22":
  12302. msg = "单位网上申报挂失"
  12303. break
  12304. case "23":
  12305. msg = "保健办挂失"
  12306. break
  12307. case "24":
  12308. msg = "个人网上挂失"
  12309. break
  12310. case "25":
  12311. msg = "网上服务大厅挂失"
  12312. break
  12313. case "30":
  12314. msg = "注销"
  12315. break
  12316. case "40":
  12317. msg = "回收"
  12318. break
  12319. case "99":
  12320. msg = "制卡中(无效卡)"
  12321. break
  12322. }
  12323. c.ServeSuccessJSON(map[string]interface{}{
  12324. "failed_code": -10,
  12325. "msg": msg,
  12326. })
  12327. return
  12328. } else {
  12329. c.ServeSuccessJSON(map[string]interface{}{
  12330. "msg": "校验成功",
  12331. })
  12332. return
  12333. }
  12334. }
  12335. } else {
  12336. c.ServeSuccessJSON(map[string]interface{}{
  12337. "msg": "校验成功",
  12338. })
  12339. return
  12340. }
  12341. }
  12342. func (c *HisApiController) CheckCardPWDTwo() {
  12343. //card_pwd := c.GetString("card_pwd")
  12344. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12345. admin_user_id, _ := c.GetInt64("admin_user_id")
  12346. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12347. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12348. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12349. var dat map[string]interface{}
  12350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12351. fmt.Println(dat)
  12352. } else {
  12353. fmt.Println(err)
  12354. }
  12355. userJSONBytes, _ := json.Marshal(dat)
  12356. var res Result90991
  12357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12358. utils.ErrorLog("解析失败:%v", err)
  12359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12360. return
  12361. }
  12362. if res.Infcode != 0 {
  12363. c.ServeSuccessJSON(map[string]interface{}{
  12364. "failed_code": -10,
  12365. "msg": res.ErrMsg,
  12366. })
  12367. return
  12368. } else {
  12369. if res.Output.Result.SscnoCheckStat == "0" {
  12370. var msg string
  12371. switch res.Output.Result.CardStat {
  12372. case "00":
  12373. msg = "未激活"
  12374. break
  12375. case "10":
  12376. msg = "激活"
  12377. break
  12378. case "20":
  12379. msg = "窗口挂失"
  12380. break
  12381. case "21":
  12382. msg = "电话挂失"
  12383. break
  12384. case "22":
  12385. msg = "单位网上申报挂失"
  12386. break
  12387. case "23":
  12388. msg = "保健办挂失"
  12389. break
  12390. case "24":
  12391. msg = "个人网上挂失"
  12392. break
  12393. case "25":
  12394. msg = "网上服务大厅挂失"
  12395. break
  12396. case "30":
  12397. msg = "注销"
  12398. break
  12399. case "40":
  12400. msg = "回收"
  12401. break
  12402. case "99":
  12403. msg = "制卡中(无效卡)"
  12404. break
  12405. }
  12406. c.ServeSuccessJSON(map[string]interface{}{
  12407. "failed_code": -10,
  12408. "msg": msg,
  12409. })
  12410. return
  12411. } else {
  12412. c.ServeSuccessJSON(map[string]interface{}{
  12413. "msg": "校验成功",
  12414. })
  12415. return
  12416. }
  12417. }
  12418. }
  12419. type ELeCertData struct {
  12420. Data struct {
  12421. Extra string `json:"extra"`
  12422. IDNo string `json:"idNo"`
  12423. IDType string `json:"idType"`
  12424. EcToken string `json:"ecToken"`
  12425. InsuOrg string `json:"insuOrg"`
  12426. UserName string `json:"userName"`
  12427. EcIndexNo string `json:"ecIndexNo"`
  12428. Gender string `json:"gender"`
  12429. Birthday string `json:"birthday"`
  12430. Nationality string `json:"nationality"`
  12431. Email string `json:"email"`
  12432. } `json:"OutData"`
  12433. }
  12434. func (c *HisApiController) ReadCard() {
  12435. id_card_type, _ := c.GetInt64("id_card_type")
  12436. admin_user_id, _ := c.GetInt64("admin_user_id")
  12437. certificates, _ := c.GetInt64("certificates")
  12438. //
  12439. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12440. id_card_no := c.GetString("id_card_no")
  12441. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12443. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12444. switch id_card_type {
  12445. case 1:
  12446. if miConfig.MdtrtareaAdmvs == "421300" {
  12447. var res ResultTwo
  12448. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12449. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12450. "&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)
  12451. resp, requestErr := http.Get(api)
  12452. if requestErr != nil {
  12453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12454. return
  12455. }
  12456. body, ioErr := ioutil.ReadAll(resp.Body)
  12457. if ioErr != nil {
  12458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12460. return
  12461. }
  12462. var respJSON map[string]interface{}
  12463. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12466. return
  12467. }
  12468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12469. result, _ := json.Marshal(respJSON)
  12470. fmt.Println("log")
  12471. fmt.Println(string(result))
  12472. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12473. utils.ErrorLog("解析失败:%v", err)
  12474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12475. return
  12476. }
  12477. if res.Infcode == 0 {
  12478. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12479. if err == gorm.ErrRecordNotFound {
  12480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12481. return
  12482. } else if err != nil {
  12483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12484. return
  12485. } else {
  12486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12488. infoStr := string(Iinfos)
  12489. idetinfoStr := string(Idetinfos)
  12490. var rf []*ResultFive
  12491. json.Unmarshal([]byte(infoStr), &rf)
  12492. var insutypes []*ResultFive
  12493. var insutype string
  12494. var is390 int = 0
  12495. var is310 int = 0
  12496. for _, item := range rf {
  12497. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12498. insutypes = append(insutypes, item)
  12499. }
  12500. }
  12501. if len(insutypes) == 1 {
  12502. insutype = insutypes[0].Insutype
  12503. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12504. } else {
  12505. for _, i := range insutypes {
  12506. if i.Insutype == "390" {
  12507. is390 = 1
  12508. }
  12509. if i.Insutype == "310" {
  12510. is310 = 1
  12511. }
  12512. }
  12513. }
  12514. if is390 == 1 {
  12515. insutype = "390"
  12516. }
  12517. if is310 == 1 {
  12518. insutype = "310"
  12519. }
  12520. if len(insutypes) == 0 {
  12521. insutype = "390"
  12522. }
  12523. var insuplc_admdvs string
  12524. for _, item := range rf {
  12525. if item.Insutype == insutype {
  12526. insuplc_admdvs = item.InsuplcAdmdvs
  12527. }
  12528. }
  12529. if strings.Contains(insuplc_admdvs, "4213") {
  12530. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12531. }
  12532. psn := &models.HisPsn{
  12533. PsnNo: res.Output.Baseinfo.PsnNo,
  12534. PatientId: patient.ID,
  12535. Certno: res.Output.Baseinfo.Certno,
  12536. Gend: res.Output.Baseinfo.Gend,
  12537. Naty: res.Output.Baseinfo.Naty,
  12538. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12539. PsnName: res.Output.Baseinfo.PsnName,
  12540. Idetinfo: idetinfoStr,
  12541. Insuinfo: infoStr,
  12542. InsuplcAdmdvs: insuplc_admdvs,
  12543. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12544. }
  12545. service.CreateHisPsn(psn)
  12546. c.ServeSuccessJSON(map[string]interface{}{
  12547. "patient": patient,
  12548. "number": res.Output.Baseinfo.Certno,
  12549. })
  12550. }
  12551. } else {
  12552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12553. return
  12554. }
  12555. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12556. var res ResultTwo
  12557. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12558. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12559. "&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)
  12560. resp, requestErr := http.Get(api)
  12561. if requestErr != nil {
  12562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12563. return
  12564. }
  12565. body, ioErr := ioutil.ReadAll(resp.Body)
  12566. if ioErr != nil {
  12567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12569. return
  12570. }
  12571. var respJSON map[string]interface{}
  12572. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12575. return
  12576. }
  12577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12578. result, _ := json.Marshal(respJSON)
  12579. fmt.Println("log")
  12580. fmt.Println(string(result))
  12581. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12582. utils.ErrorLog("解析失败:%v", err)
  12583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12584. return
  12585. }
  12586. if res.Infcode == 0 {
  12587. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12588. if err == gorm.ErrRecordNotFound {
  12589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12590. return
  12591. } else if err != nil {
  12592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12593. return
  12594. } else {
  12595. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12596. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12597. infoStr := string(Iinfos)
  12598. idetinfoStr := string(Idetinfos)
  12599. psn := &models.HisPsn{
  12600. PsnNo: res.Output.Baseinfo.PsnNo,
  12601. PatientId: patient.ID,
  12602. Certno: res.Output.Baseinfo.Certno,
  12603. Gend: res.Output.Baseinfo.Gend,
  12604. Naty: res.Output.Baseinfo.Naty,
  12605. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12606. PsnName: res.Output.Baseinfo.PsnName,
  12607. Idetinfo: idetinfoStr,
  12608. Insuinfo: infoStr,
  12609. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12610. }
  12611. service.CreateHisPsn(psn)
  12612. var rf []*ResultFive
  12613. json.Unmarshal([]byte(infoStr), &rf)
  12614. var insutypes []*ResultFive
  12615. var insutype string
  12616. var is390 int = 0
  12617. var is310 int = 0
  12618. for _, item := range rf {
  12619. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12620. insutypes = append(insutypes, item)
  12621. }
  12622. }
  12623. if len(insutypes) == 1 {
  12624. insutype = insutypes[0].Insutype
  12625. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12626. } else {
  12627. for _, i := range insutypes {
  12628. if i.Insutype == "390" {
  12629. is390 = 1
  12630. }
  12631. if i.Insutype == "310" {
  12632. is310 = 1
  12633. }
  12634. }
  12635. }
  12636. if is390 == 1 {
  12637. insutype = "390"
  12638. }
  12639. if is310 == 1 {
  12640. insutype = "310"
  12641. }
  12642. if len(insutypes) == 0 {
  12643. insutype = "310"
  12644. }
  12645. c.ServeSuccessJSON(map[string]interface{}{
  12646. "patient": patient,
  12647. "number": res.Output.Baseinfo.Certno,
  12648. "insutype": insutype,
  12649. })
  12650. }
  12651. } else {
  12652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12653. return
  12654. }
  12655. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12656. var res ResultTwo
  12657. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12658. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12659. "&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)
  12660. resp, requestErr := http.Get(api)
  12661. if requestErr != nil {
  12662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12663. return
  12664. }
  12665. body, ioErr := ioutil.ReadAll(resp.Body)
  12666. if ioErr != nil {
  12667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12669. return
  12670. }
  12671. var respJSON map[string]interface{}
  12672. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12675. return
  12676. }
  12677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12678. result, _ := json.Marshal(respJSON)
  12679. fmt.Println("log")
  12680. fmt.Println(string(result))
  12681. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12682. utils.ErrorLog("解析失败:%v", err)
  12683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12684. return
  12685. }
  12686. if res.Infcode == 0 {
  12687. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12688. if err == gorm.ErrRecordNotFound {
  12689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12690. return
  12691. } else if err != nil {
  12692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12693. return
  12694. } else {
  12695. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12696. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12697. infoStr := string(Iinfos)
  12698. idetinfoStr := string(Idetinfos)
  12699. var rf []*ResultFive
  12700. json.Unmarshal([]byte(infoStr), &rf)
  12701. var insutypes []*ResultFive
  12702. var insutype string
  12703. var is390 int = 0
  12704. var is310 int = 0
  12705. for _, item := range rf {
  12706. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12707. insutypes = append(insutypes, item)
  12708. }
  12709. }
  12710. if len(insutypes) == 1 {
  12711. insutype = insutypes[0].Insutype
  12712. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12713. } else {
  12714. for _, i := range insutypes {
  12715. if i.Insutype == "390" {
  12716. is390 = 1
  12717. }
  12718. if i.Insutype == "310" {
  12719. is310 = 1
  12720. }
  12721. }
  12722. }
  12723. if is390 == 1 {
  12724. insutype = "390"
  12725. }
  12726. if is310 == 1 {
  12727. insutype = "310"
  12728. }
  12729. if len(insutypes) == 0 {
  12730. insutype = "390"
  12731. }
  12732. var insuplc_admdvs string
  12733. for _, item := range rf {
  12734. if item.Insutype == insutype {
  12735. insuplc_admdvs = item.InsuplcAdmdvs
  12736. }
  12737. }
  12738. psn := &models.HisPsn{
  12739. PsnNo: res.Output.Baseinfo.PsnNo,
  12740. PatientId: patient.ID,
  12741. Certno: res.Output.Baseinfo.Certno,
  12742. Gend: res.Output.Baseinfo.Gend,
  12743. Naty: res.Output.Baseinfo.Naty,
  12744. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12745. PsnName: res.Output.Baseinfo.PsnName,
  12746. Idetinfo: idetinfoStr,
  12747. Insuinfo: infoStr,
  12748. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12749. InsuplcAdmdvs: insuplc_admdvs,
  12750. }
  12751. service.CreateHisPsn(psn)
  12752. for _, item := range rf {
  12753. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12754. insutypes = append(insutypes, item)
  12755. }
  12756. }
  12757. if len(insutypes) == 1 {
  12758. insutype = insutypes[0].Insutype
  12759. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12760. } else {
  12761. for _, i := range insutypes {
  12762. if i.Insutype == "390" {
  12763. is390 = 1
  12764. }
  12765. if i.Insutype == "310" {
  12766. is310 = 1
  12767. }
  12768. }
  12769. }
  12770. if is390 == 1 {
  12771. insutype = "390"
  12772. }
  12773. if is310 == 1 {
  12774. insutype = "310"
  12775. }
  12776. if len(insutypes) == 0 {
  12777. insutype = "310"
  12778. }
  12779. c.ServeSuccessJSON(map[string]interface{}{
  12780. "patient": patient,
  12781. "number": res.Output.Baseinfo.Certno,
  12782. "insutype": insutype,
  12783. })
  12784. }
  12785. } else {
  12786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12787. return
  12788. }
  12789. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12790. var res ResultTwo
  12791. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12792. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12793. "&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)
  12794. resp, requestErr := http.Get(api)
  12795. if requestErr != nil {
  12796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12797. return
  12798. }
  12799. body, ioErr := ioutil.ReadAll(resp.Body)
  12800. if ioErr != nil {
  12801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12803. return
  12804. }
  12805. var respJSON map[string]interface{}
  12806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12809. return
  12810. }
  12811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12812. result, _ := json.Marshal(respJSON)
  12813. fmt.Println("log")
  12814. fmt.Println(string(result))
  12815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12816. utils.ErrorLog("解析失败:%v", err)
  12817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12818. return
  12819. }
  12820. if res.Infcode == 0 {
  12821. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12822. if err == gorm.ErrRecordNotFound {
  12823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12824. return
  12825. } else if err != nil {
  12826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12827. return
  12828. } else {
  12829. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12830. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12831. infoStr := string(Iinfos)
  12832. idetinfoStr := string(Idetinfos)
  12833. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12834. psn := &models.HisPsn{
  12835. PsnNo: res.Output.Baseinfo.PsnNo,
  12836. PatientId: patient.ID,
  12837. Certno: res.Output.Baseinfo.Certno,
  12838. Brdy: b,
  12839. Age: float64(age),
  12840. Gend: res.Output.Baseinfo.Gend,
  12841. Naty: res.Output.Baseinfo.Naty,
  12842. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12843. PsnName: res.Output.Baseinfo.PsnName,
  12844. Idetinfo: idetinfoStr,
  12845. Insuinfo: infoStr,
  12846. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12847. }
  12848. service.CreateHisPsn(psn)
  12849. var rf []*ResultFive
  12850. json.Unmarshal([]byte(infoStr), &rf)
  12851. var insutypes []*ResultFive
  12852. var insutype string
  12853. var is390 int = 0
  12854. var is310 int = 0
  12855. for _, item := range rf {
  12856. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12857. insutypes = append(insutypes, item)
  12858. }
  12859. }
  12860. if len(insutypes) == 1 {
  12861. insutype = insutypes[0].Insutype
  12862. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12863. } else {
  12864. for _, i := range insutypes {
  12865. if i.Insutype == "390" {
  12866. is390 = 1
  12867. }
  12868. if i.Insutype == "310" {
  12869. is310 = 1
  12870. }
  12871. }
  12872. }
  12873. if is390 == 1 {
  12874. insutype = "390"
  12875. }
  12876. if is310 == 1 {
  12877. insutype = "310"
  12878. }
  12879. if len(insutypes) == 0 {
  12880. insutype = "310"
  12881. }
  12882. c.ServeSuccessJSON(map[string]interface{}{
  12883. "patient": patient,
  12884. "number": res.Output.Baseinfo.Certno,
  12885. "insutype": insutype,
  12886. })
  12887. }
  12888. } else {
  12889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12890. return
  12891. }
  12892. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12893. var api string
  12894. if miConfig.MdtrtareaAdmvs == "320921" {
  12895. 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 +
  12896. "&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
  12897. fmt.Println(api)
  12898. } else {
  12899. 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 +
  12900. "&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)
  12901. }
  12902. resp, requestErr := http.Get(api)
  12903. if requestErr != nil {
  12904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12905. return
  12906. }
  12907. body, ioErr := ioutil.ReadAll(resp.Body)
  12908. if ioErr != nil {
  12909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12911. return
  12912. }
  12913. var respJSON map[string]interface{}
  12914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12917. return
  12918. }
  12919. var status string
  12920. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12921. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12922. //console.log()
  12923. fmt.Println("type===")
  12924. fmt.Println(card_type)
  12925. var token string
  12926. var res ResultTwo //1101结果
  12927. var res10265 ResultTwo10265 //1101结果
  12928. var card_info string //卡信息
  12929. var busi_card_info string
  12930. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12931. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12932. if status == "0" { //读卡成功
  12933. if card_type == "1" {
  12934. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12935. result, _ := json.Marshal(respJSON)
  12936. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12937. utils.ErrorLog("解析失败:%v", err)
  12938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12939. return
  12940. }
  12941. res.ErrMsg = res10265.ErrMsg
  12942. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12943. res.Infcode = infocode
  12944. res.Output = res10265.Output
  12945. res.InfRefmsgid = res10265.InfRefmsgid
  12946. } else {
  12947. //var card_info string //卡信息
  12948. //var busi_card_info string
  12949. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12950. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12951. //fmt.Println(card_info)
  12952. //fmt.Println(busi_card_info)
  12953. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12954. result, _ := json.Marshal(respJSON)
  12955. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12956. utils.ErrorLog("解析失败:%v", err)
  12957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12958. return
  12959. }
  12960. res.ErrMsg = res10265.ErrMsg
  12961. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12962. res.Infcode = infocode
  12963. res.Output = res10265.Output
  12964. res.InfRefmsgid = res10265.InfRefmsgid
  12965. }
  12966. if res.Infcode == 0 {
  12967. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12968. if err == gorm.ErrRecordNotFound {
  12969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12970. return
  12971. } else if err != nil {
  12972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12973. return
  12974. } else {
  12975. if card_type == "1" {
  12976. bas := strings.Split(card_info, "|")
  12977. basNumber := bas[2]
  12978. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12979. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12980. infoStr := string(Iinfos)
  12981. idetinfoStr := string(Idetinfos)
  12982. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12983. psn := &models.HisPsn{
  12984. PsnNo: res.Output.Baseinfo.PsnNo,
  12985. PatientId: patient.ID,
  12986. Certno: res.Output.Baseinfo.Certno,
  12987. Brdy: b,
  12988. Age: float64(age),
  12989. Gend: res.Output.Baseinfo.Gend,
  12990. Naty: res.Output.Baseinfo.Naty,
  12991. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12992. PsnName: res.Output.Baseinfo.PsnName,
  12993. Idetinfo: idetinfoStr,
  12994. Insuinfo: infoStr,
  12995. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12996. CardInfo: card_info,
  12997. VerifyNumber: busi_card_info,
  12998. }
  12999. service.CreateHisPsn(psn)
  13000. var rf []*ResultFive
  13001. json.Unmarshal([]byte(infoStr), &rf)
  13002. var insutypes []*ResultFive
  13003. var insutype string
  13004. var is390 int = 0
  13005. var is310 int = 0
  13006. for _, item := range rf {
  13007. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13008. insutypes = append(insutypes, item)
  13009. }
  13010. }
  13011. if len(insutypes) == 1 {
  13012. insutype = insutypes[0].Insutype
  13013. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13014. } else {
  13015. for _, i := range insutypes {
  13016. if i.Insutype == "390" {
  13017. is390 = 1
  13018. }
  13019. if i.Insutype == "310" {
  13020. is310 = 1
  13021. }
  13022. }
  13023. }
  13024. if is390 == 1 {
  13025. insutype = "390"
  13026. }
  13027. if is310 == 1 {
  13028. insutype = "310"
  13029. }
  13030. if len(insutypes) == 0 {
  13031. insutype = "310"
  13032. }
  13033. c.ServeSuccessJSON(map[string]interface{}{
  13034. "patient": patient,
  13035. "number": basNumber,
  13036. "insutype": insutype,
  13037. })
  13038. } else {
  13039. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13040. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13041. infoStr := string(Iinfos)
  13042. idetinfoStr := string(Idetinfos)
  13043. psn := &models.HisPsn{
  13044. PsnNo: res.Output.Baseinfo.PsnNo,
  13045. PatientId: patient.ID,
  13046. Certno: res.Output.Baseinfo.Certno,
  13047. Gend: res.Output.Baseinfo.Gend,
  13048. Naty: res.Output.Baseinfo.Naty,
  13049. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13050. PsnName: res.Output.Baseinfo.PsnName,
  13051. Idetinfo: idetinfoStr,
  13052. Insuinfo: infoStr,
  13053. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13054. CardInfo: card_info,
  13055. VerifyNumber: token,
  13056. }
  13057. service.CreateHisPsn(psn)
  13058. c.ServeSuccessJSON(map[string]interface{}{
  13059. "patient": patient,
  13060. "number": token,
  13061. })
  13062. }
  13063. }
  13064. } else {
  13065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13066. return
  13067. }
  13068. } else { //读卡失败
  13069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13070. return
  13071. }
  13072. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13073. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13074. cardnum = DeleteExtraSpaceTwo(cardnum)
  13075. cardCode = DeleteExtraSpaceTwo(cardCode)
  13076. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13077. name = DeleteExtraSpaceTwo(name)
  13078. errmsg = DeleteExtraSpaceTwo(errmsg)
  13079. cardnum = Remove0000(cardnum)
  13080. cardCode = Remove0000(cardCode)
  13081. id_card_no = Remove0000(id_card_no)
  13082. name = Remove0000(name)
  13083. errmsg = Remove0000(errmsg)
  13084. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13085. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13086. //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)
  13087. //fmt.Println(result2)
  13088. //fmt.Println(requestLog2)
  13089. //fmt.Println(errMsgLog2)
  13090. 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)
  13091. saveLog(result, requestLog, "1101", "获取人员信息")
  13092. fmt.Println(errMsgLog)
  13093. if len(errMsgLog) > 0 {
  13094. } else {
  13095. var dat map[string]interface{}
  13096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13097. fmt.Println(dat)
  13098. } else {
  13099. fmt.Println(err)
  13100. }
  13101. userJSONBytes, _ := json.Marshal(dat)
  13102. var res ResultTwo
  13103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13104. utils.ErrorLog("解析失败:%v", err)
  13105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13106. return
  13107. }
  13108. res.ErrMsg = errMsgLog
  13109. if res.Infcode == 0 {
  13110. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13111. if err == gorm.ErrRecordNotFound {
  13112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13113. return
  13114. } else if err != nil {
  13115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13116. return
  13117. } else {
  13118. fmt.Println(res)
  13119. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13120. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13121. infoStr := string(Iinfos)
  13122. idetinfoStr := string(Idetinfos)
  13123. var rf []*ResultFive
  13124. json.Unmarshal([]byte(infoStr), &rf)
  13125. var insutypes []*ResultFive
  13126. var insutype string
  13127. var is390 int = 0
  13128. var is310 int = 0
  13129. for _, item := range rf {
  13130. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13131. insutypes = append(insutypes, item)
  13132. }
  13133. }
  13134. if len(insutypes) == 1 {
  13135. insutype = insutypes[0].Insutype
  13136. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13137. } else {
  13138. for _, i := range insutypes {
  13139. if i.Insutype == "390" {
  13140. is390 = 1
  13141. }
  13142. if i.Insutype == "310" {
  13143. is310 = 1
  13144. }
  13145. }
  13146. }
  13147. if is390 == 1 {
  13148. insutype = "390"
  13149. }
  13150. if is310 == 1 {
  13151. insutype = "310"
  13152. }
  13153. if len(insutypes) == 0 {
  13154. insutype = "390"
  13155. }
  13156. var insuplc_admdvs string
  13157. for _, item := range rf {
  13158. if item.Insutype == insutype {
  13159. insuplc_admdvs = item.InsuplcAdmdvs
  13160. }
  13161. }
  13162. psn := &models.HisPsn{
  13163. PsnNo: res.Output.Baseinfo.PsnNo,
  13164. PatientId: patient.ID,
  13165. Certno: res.Output.Baseinfo.Certno,
  13166. Gend: res.Output.Baseinfo.Gend,
  13167. Naty: res.Output.Baseinfo.Naty,
  13168. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13169. PsnName: res.Output.Baseinfo.PsnName,
  13170. Idetinfo: idetinfoStr,
  13171. Insuinfo: infoStr,
  13172. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13173. CardInfo: basStr,
  13174. VerifyNumber: "",
  13175. InsuplcAdmdvs: insuplc_admdvs,
  13176. }
  13177. service.CreateHisPsn(psn)
  13178. c.ServeSuccessJSON(map[string]interface{}{
  13179. "patient": patient,
  13180. "number": cardnum,
  13181. "insutype": insutype,
  13182. })
  13183. }
  13184. } else {
  13185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13186. return
  13187. }
  13188. }
  13189. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13190. fmt.Println(initFlag)
  13191. fmt.Println("initFlag")
  13192. if initFlag == 0 {
  13193. c.TestGetJiangXiBasBaseInit()
  13194. }
  13195. basStr := c.GetBasBaseInfo()
  13196. if len(basStr) == 0 {
  13197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13198. return
  13199. }
  13200. fmt.Println(basStr)
  13201. bas := strings.Split(basStr, "|")
  13202. basNumber := bas[1]
  13203. fmt.Println(basNumber)
  13204. card_sn := bas[3]
  13205. fmt.Println(card_sn)
  13206. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13207. 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)
  13208. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13209. var dat map[string]interface{}
  13210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13211. fmt.Println(dat)
  13212. } else {
  13213. fmt.Println(err)
  13214. }
  13215. userJSONBytes, _ := json.Marshal(dat)
  13216. var res ResultTwo
  13217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13218. utils.ErrorLog("解析失败:%v", err)
  13219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13220. return
  13221. }
  13222. if res.Infcode == 0 {
  13223. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13224. if err == gorm.ErrRecordNotFound {
  13225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13226. return
  13227. } else if err != nil {
  13228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13229. return
  13230. } else {
  13231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13233. infoStr := string(Iinfos)
  13234. idetinfoStr := string(Idetinfos)
  13235. var rf []*ResultFive
  13236. json.Unmarshal([]byte(infoStr), &rf)
  13237. var insutypes []*ResultFive
  13238. var insutype string
  13239. var is390 int = 0
  13240. var is310 int = 0
  13241. var insuplc_admdvs string
  13242. for _, item := range rf {
  13243. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13244. insutypes = append(insutypes, item)
  13245. }
  13246. }
  13247. if len(insutypes) == 1 {
  13248. insutype = insutypes[0].Insutype
  13249. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13250. } else {
  13251. for _, i := range insutypes {
  13252. if i.Insutype == "390" {
  13253. is390 = 1
  13254. }
  13255. if i.Insutype == "310" {
  13256. is310 = 1
  13257. }
  13258. }
  13259. }
  13260. if is390 == 1 {
  13261. insutype = "390"
  13262. }
  13263. if is310 == 1 {
  13264. insutype = "310"
  13265. }
  13266. if len(insutypes) == 0 {
  13267. insutype = "310"
  13268. }
  13269. for _, item := range rf {
  13270. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13271. insuplc_admdvs = item.InsuplcAdmdvs
  13272. }
  13273. }
  13274. psn := &models.HisPsn{
  13275. PsnNo: res.Output.Baseinfo.PsnNo,
  13276. PatientId: patient.ID,
  13277. Certno: res.Output.Baseinfo.Certno,
  13278. Gend: res.Output.Baseinfo.Gend,
  13279. Naty: res.Output.Baseinfo.Naty,
  13280. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13281. PsnName: res.Output.Baseinfo.PsnName,
  13282. Idetinfo: idetinfoStr,
  13283. Insuinfo: infoStr,
  13284. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13285. CardInfo: basStr,
  13286. InsuplcAdmdvs: insuplc_admdvs,
  13287. VerifyNumber: "",
  13288. }
  13289. service.CreateHisPsn(psn)
  13290. c.ServeSuccessJSON(map[string]interface{}{
  13291. "patient": patient,
  13292. "number": basNumber,
  13293. "insutype": insutype,
  13294. })
  13295. }
  13296. } else {
  13297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13298. return
  13299. }
  13300. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13301. basStr := c.GetBasBaseInfo22222()
  13302. fmt.Println(basStr)
  13303. if len(basStr) == 0 {
  13304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13305. return
  13306. }
  13307. fmt.Println(basStr)
  13308. bas := strings.Split(basStr, "|")
  13309. basNumber := bas[2] //卡号
  13310. card_sn := bas[3] //
  13311. id_card_No := bas[1] //卡号
  13312. fmt.Println(basNumber)
  13313. fmt.Println(card_sn)
  13314. fmt.Println(id_card_No)
  13315. var patient service.Patients
  13316. if len(id_card_No) == 0 {
  13317. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13318. } else {
  13319. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13320. }
  13321. 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)
  13322. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13323. var dat map[string]interface{}
  13324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13325. fmt.Println(dat)
  13326. } else {
  13327. fmt.Println(err)
  13328. }
  13329. userJSONBytes, _ := json.Marshal(dat)
  13330. var res ResultTwo
  13331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13332. utils.ErrorLog("解析失败:%v", err)
  13333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13334. return
  13335. }
  13336. if res.Infcode == 0 {
  13337. var pateint2 service.Patients
  13338. var err error
  13339. if len(id_card_No) == 0 {
  13340. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13341. } else {
  13342. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13343. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13344. }
  13345. if err == gorm.ErrRecordNotFound {
  13346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13347. return
  13348. } else if err != nil {
  13349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13350. return
  13351. } else {
  13352. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13353. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13354. infoStr := string(Iinfos)
  13355. idetinfoStr := string(Idetinfos)
  13356. var rf []*ResultFive
  13357. json.Unmarshal([]byte(infoStr), &rf)
  13358. var insutypes []*ResultFive
  13359. var insutype string
  13360. var is390 int = 0
  13361. var is310 int = 0
  13362. var insuplc_admdvs string
  13363. for _, item := range rf {
  13364. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13365. insutypes = append(insutypes, item)
  13366. }
  13367. }
  13368. if len(insutypes) == 1 {
  13369. insutype = insutypes[0].Insutype
  13370. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13371. } else {
  13372. for _, i := range insutypes {
  13373. if i.Insutype == "390" {
  13374. is390 = 1
  13375. }
  13376. if i.Insutype == "310" {
  13377. is310 = 1
  13378. }
  13379. }
  13380. }
  13381. if is390 == 1 {
  13382. insutype = "390"
  13383. }
  13384. if is310 == 1 {
  13385. insutype = "310"
  13386. }
  13387. if len(insutypes) == 0 {
  13388. insutype = "310"
  13389. }
  13390. for _, item := range rf {
  13391. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13392. insuplc_admdvs = item.InsuplcAdmdvs
  13393. }
  13394. }
  13395. psn := &models.HisPsn{
  13396. PsnNo: res.Output.Baseinfo.PsnNo,
  13397. PatientId: pateint2.ID,
  13398. Certno: res.Output.Baseinfo.Certno,
  13399. Gend: res.Output.Baseinfo.Gend,
  13400. Naty: res.Output.Baseinfo.Naty,
  13401. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13402. PsnName: res.Output.Baseinfo.PsnName,
  13403. Idetinfo: idetinfoStr,
  13404. Insuinfo: infoStr,
  13405. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13406. CardInfo: basStr,
  13407. InsuplcAdmdvs: insuplc_admdvs,
  13408. VerifyNumber: "",
  13409. }
  13410. service.CreateHisPsn(psn)
  13411. c.ServeSuccessJSON(map[string]interface{}{
  13412. "patient": patient,
  13413. "number": basNumber,
  13414. "insutype": insutype,
  13415. })
  13416. }
  13417. } else {
  13418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13419. return
  13420. }
  13421. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13422. fmt.Println(initFlag)
  13423. fmt.Println("initFlag")
  13424. if initFlag == 0 {
  13425. c.TestGetHnBasBaseInit()
  13426. }
  13427. basStr := c.GetBasBaseInfo()
  13428. if len(basStr) == 0 {
  13429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13430. return
  13431. }
  13432. fmt.Println(basStr)
  13433. bas := strings.Split(basStr, "|")
  13434. basNumber := bas[1]
  13435. fmt.Println(basNumber)
  13436. card_sn := bas[3]
  13437. card_no := bas[2]
  13438. fmt.Println(card_sn)
  13439. name := bas[4]
  13440. name = ConvertToString(name, "gbk", "utf-8")
  13441. 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)
  13442. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13443. var dat map[string]interface{}
  13444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13445. fmt.Println(dat)
  13446. } else {
  13447. fmt.Println(err)
  13448. }
  13449. userJSONBytes, _ := json.Marshal(dat)
  13450. var res ResultTwo
  13451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13452. utils.ErrorLog("解析失败:%v", err)
  13453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13454. return
  13455. }
  13456. if res.Infcode == 0 {
  13457. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13458. if err == gorm.ErrRecordNotFound {
  13459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13460. return
  13461. } else if err != nil {
  13462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13463. return
  13464. } else {
  13465. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13466. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13467. infoStr := string(Iinfos)
  13468. idetinfoStr := string(Idetinfos)
  13469. psn := &models.HisPsn{
  13470. PsnNo: res.Output.Baseinfo.PsnNo,
  13471. PatientId: patient.ID,
  13472. Certno: res.Output.Baseinfo.Certno,
  13473. Gend: res.Output.Baseinfo.Gend,
  13474. Naty: res.Output.Baseinfo.Naty,
  13475. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13476. PsnName: res.Output.Baseinfo.PsnName,
  13477. Idetinfo: idetinfoStr,
  13478. Insuinfo: infoStr,
  13479. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13480. CardInfo: basStr,
  13481. VerifyNumber: "",
  13482. }
  13483. service.CreateHisPsn(psn)
  13484. var rf []*ResultFive
  13485. json.Unmarshal([]byte(infoStr), &rf)
  13486. var insutypes []*ResultFive
  13487. var insutype string
  13488. var is390 int = 0
  13489. var is310 int = 0
  13490. for _, item := range rf {
  13491. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13492. insutypes = append(insutypes, item)
  13493. }
  13494. }
  13495. if len(insutypes) == 1 {
  13496. insutype = insutypes[0].Insutype
  13497. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13498. } else {
  13499. for _, i := range insutypes {
  13500. if i.Insutype == "390" {
  13501. is390 = 1
  13502. }
  13503. if i.Insutype == "310" {
  13504. is310 = 1
  13505. }
  13506. }
  13507. }
  13508. if is390 == 1 {
  13509. insutype = "390"
  13510. }
  13511. if is310 == 1 {
  13512. insutype = "310"
  13513. }
  13514. if len(insutypes) == 0 {
  13515. insutype = "310"
  13516. }
  13517. c.ServeSuccessJSON(map[string]interface{}{
  13518. "patient": patient,
  13519. "number": basNumber,
  13520. "insutype": insutype,
  13521. })
  13522. }
  13523. } else {
  13524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13525. return
  13526. }
  13527. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13528. var api string
  13529. 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 +
  13530. "&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
  13531. fmt.Println(api)
  13532. resp, requestErr := http.Get(api)
  13533. if requestErr != nil {
  13534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13535. return
  13536. }
  13537. body, ioErr := ioutil.ReadAll(resp.Body)
  13538. if ioErr != nil {
  13539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13541. return
  13542. }
  13543. var respJSON map[string]interface{}
  13544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13547. return
  13548. }
  13549. var res ResultTwo //1101结果
  13550. var res10265 ResultTwo10265 //1101结果
  13551. var card_info string //卡信息
  13552. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13553. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13554. result, _ := json.Marshal(respJSON)
  13555. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13556. utils.ErrorLog("解析失败:%v", err)
  13557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13558. return
  13559. }
  13560. res.ErrMsg = res10265.ErrMsg
  13561. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13562. res.Infcode = infocode
  13563. res.Output = res10265.Output
  13564. res.InfRefmsgid = res10265.InfRefmsgid
  13565. if res.Infcode == 0 {
  13566. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13567. if err == gorm.ErrRecordNotFound {
  13568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13569. return
  13570. } else if err != nil {
  13571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13572. return
  13573. } else {
  13574. bas := strings.Split(card_info, "|")
  13575. basNumber := bas[2]
  13576. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13577. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13578. infoStr := string(Iinfos)
  13579. idetinfoStr := string(Idetinfos)
  13580. psn := &models.HisPsn{
  13581. PsnNo: res.Output.Baseinfo.PsnNo,
  13582. PatientId: patient.ID,
  13583. Certno: res.Output.Baseinfo.Certno,
  13584. Gend: res.Output.Baseinfo.Gend,
  13585. Naty: res.Output.Baseinfo.Naty,
  13586. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13587. PsnName: res.Output.Baseinfo.PsnName,
  13588. Idetinfo: idetinfoStr,
  13589. Insuinfo: infoStr,
  13590. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13591. CardInfo: card_info,
  13592. VerifyNumber: token,
  13593. }
  13594. service.CreateHisPsn(psn)
  13595. var rf []*ResultFive
  13596. json.Unmarshal([]byte(infoStr), &rf)
  13597. var insutypes []*ResultFive
  13598. var insutype string
  13599. var is390 int = 0
  13600. var is310 int = 0
  13601. for _, item := range rf {
  13602. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13603. insutypes = append(insutypes, item)
  13604. }
  13605. }
  13606. if len(insutypes) == 1 {
  13607. insutype = insutypes[0].Insutype
  13608. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13609. } else {
  13610. for _, i := range insutypes {
  13611. if i.Insutype == "390" {
  13612. is390 = 1
  13613. }
  13614. if i.Insutype == "310" {
  13615. is310 = 1
  13616. }
  13617. }
  13618. }
  13619. if is390 == 1 {
  13620. insutype = "390"
  13621. }
  13622. if is310 == 1 {
  13623. insutype = "310"
  13624. }
  13625. if len(insutypes) == 0 {
  13626. insutype = "310"
  13627. }
  13628. c.ServeSuccessJSON(map[string]interface{}{
  13629. "patient": patient,
  13630. "number": basNumber,
  13631. "insutype": insutype,
  13632. })
  13633. }
  13634. } else {
  13635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13636. return
  13637. }
  13638. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13639. res := c.GetoleInfo()
  13640. if res.Infcode == 0 {
  13641. var result string
  13642. if res.Output.MdtrtCertType == "01" {
  13643. 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)
  13644. } else if res.Output.MdtrtCertType == "02" {
  13645. 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)
  13646. } else if res.Output.MdtrtCertType == "03" {
  13647. 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)
  13648. }
  13649. var dat map[string]interface{}
  13650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13651. fmt.Println(dat)
  13652. } else {
  13653. fmt.Println(err)
  13654. }
  13655. userJSONBytes, _ := json.Marshal(dat)
  13656. var res2 ResultTwo
  13657. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13658. utils.ErrorLog("解析失败:%v", err)
  13659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13660. return
  13661. }
  13662. if res2.Infcode == 0 {
  13663. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13664. if err == gorm.ErrRecordNotFound {
  13665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13666. return
  13667. } else if err != nil {
  13668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13669. return
  13670. } else {
  13671. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13672. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13673. infoStr := string(Iinfos)
  13674. idetinfoStr := string(Idetinfos)
  13675. var rf []*ResultFive
  13676. json.Unmarshal([]byte(infoStr), &rf)
  13677. var insutypes []*ResultFive
  13678. var insutype string
  13679. var is390 int = 0
  13680. var is310 int = 0
  13681. //var insuplc_admdvs string
  13682. for _, item := range rf {
  13683. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13684. insutypes = append(insutypes, item)
  13685. }
  13686. }
  13687. if len(insutypes) == 1 {
  13688. insutype = insutypes[0].Insutype
  13689. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13690. } else {
  13691. for _, i := range insutypes {
  13692. if i.Insutype == "390" {
  13693. is390 = 1
  13694. }
  13695. if i.Insutype == "310" {
  13696. is310 = 1
  13697. }
  13698. }
  13699. }
  13700. if is390 == 1 {
  13701. insutype = "390"
  13702. }
  13703. if is310 == 1 {
  13704. insutype = "310"
  13705. }
  13706. if len(insutypes) == 0 {
  13707. insutype = "310"
  13708. }
  13709. psn := &models.HisPsn{
  13710. PsnNo: res2.Output.Baseinfo.PsnNo,
  13711. PatientId: patient.ID,
  13712. Certno: res2.Output.Baseinfo.Certno,
  13713. Gend: res2.Output.Baseinfo.Gend,
  13714. Naty: res2.Output.Baseinfo.Naty,
  13715. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13716. PsnName: res2.Output.Baseinfo.PsnName,
  13717. Idetinfo: idetinfoStr,
  13718. Insuinfo: infoStr,
  13719. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13720. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13721. VerifyNumber: res.Output.EcToken,
  13722. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13723. }
  13724. if res.Output.MdtrtCertType == "01" {
  13725. psn.VerifyNumber = res.Output.EcToken
  13726. //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)
  13727. } else if res.Output.MdtrtCertType == "02" {
  13728. psn.VerifyNumber = res.Output.MdtrtCertNo
  13729. //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)
  13730. } else if res.Output.MdtrtCertType == "03" {
  13731. psn.VerifyNumber = res.Output.MdtrtCertNo
  13732. //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)
  13733. }
  13734. var balc float64
  13735. for _, item := range rf {
  13736. if item.Insutype == insutype {
  13737. balc = item.Balc
  13738. }
  13739. }
  13740. service.CreateHisPsn(psn)
  13741. c.ServeSuccessJSON(map[string]interface{}{
  13742. "patient": patient,
  13743. "number": res.Output.CardNo,
  13744. "insutype": insutype,
  13745. "blac": balc,
  13746. "desc": idetinfoStr,
  13747. })
  13748. }
  13749. } else {
  13750. c.ServeSuccessJSON(map[string]interface{}{
  13751. "failed_code": -10,
  13752. "msg": res2.ErrMsg,
  13753. })
  13754. }
  13755. } else {
  13756. c.ServeSuccessJSON(map[string]interface{}{
  13757. "failed_code": -10,
  13758. "msg": res.ErrMsg,
  13759. })
  13760. }
  13761. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13762. var api string
  13763. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13764. "&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
  13765. fmt.Println(api)
  13766. resp, requestErr := http.Get(api)
  13767. if requestErr != nil {
  13768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13769. return
  13770. }
  13771. body, ioErr := ioutil.ReadAll(resp.Body)
  13772. if ioErr != nil {
  13773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13775. return
  13776. }
  13777. var respJSON map[string]interface{}
  13778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13781. return
  13782. }
  13783. var status string
  13784. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13785. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13786. //console.log()
  13787. fmt.Println("type===")
  13788. fmt.Println(card_type)
  13789. var token string
  13790. var res ResultTwo //1101结果
  13791. //var res10265 ResultTwoesultTwo10265 //1101结果
  13792. var card_info string //卡信息
  13793. var busi_card_info string
  13794. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13795. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13796. if status == "0" { //读卡成功
  13797. if card_type == "1" {
  13798. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13799. result, _ := json.Marshal(respJSON)
  13800. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13801. utils.ErrorLog("解析失败:%v", err)
  13802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13803. return
  13804. }
  13805. } else {
  13806. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13807. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13808. result, _ := json.Marshal(respJSON)
  13809. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13810. utils.ErrorLog("解析失败:%v", err)
  13811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13812. return
  13813. }
  13814. }
  13815. if res.Infcode == 0 {
  13816. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13817. if err == gorm.ErrRecordNotFound {
  13818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13819. return
  13820. } else if err != nil {
  13821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13822. return
  13823. } else {
  13824. if card_type == "1" {
  13825. bas := strings.Split(card_info, "|")
  13826. basNumber := bas[2]
  13827. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13828. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13829. infoStr := string(Iinfos)
  13830. idetinfoStr := string(Idetinfos)
  13831. psn := &models.HisPsn{
  13832. PsnNo: res.Output.Baseinfo.PsnNo,
  13833. PatientId: patient.ID,
  13834. Certno: res.Output.Baseinfo.Certno,
  13835. Gend: res.Output.Baseinfo.Gend,
  13836. Naty: res.Output.Baseinfo.Naty,
  13837. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13838. PsnName: res.Output.Baseinfo.PsnName,
  13839. Idetinfo: idetinfoStr,
  13840. Insuinfo: infoStr,
  13841. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13842. CardInfo: card_info,
  13843. VerifyNumber: busi_card_info,
  13844. }
  13845. service.CreateHisPsn(psn)
  13846. var rf []*ResultFive
  13847. json.Unmarshal([]byte(infoStr), &rf)
  13848. var insutypes []*ResultFive
  13849. var insutype string
  13850. var is390 int = 0
  13851. var is310 int = 0
  13852. for _, item := range rf {
  13853. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13854. insutypes = append(insutypes, item)
  13855. }
  13856. }
  13857. if len(insutypes) == 1 {
  13858. insutype = insutypes[0].Insutype
  13859. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13860. } else {
  13861. for _, i := range insutypes {
  13862. if i.Insutype == "390" {
  13863. is390 = 1
  13864. }
  13865. if i.Insutype == "310" {
  13866. is310 = 1
  13867. }
  13868. }
  13869. }
  13870. if is390 == 1 {
  13871. insutype = "390"
  13872. }
  13873. if is310 == 1 {
  13874. insutype = "310"
  13875. }
  13876. if len(insutypes) == 0 {
  13877. insutype = "310"
  13878. }
  13879. c.ServeSuccessJSON(map[string]interface{}{
  13880. "patient": patient,
  13881. "number": basNumber,
  13882. "insutype": insutype,
  13883. })
  13884. } else {
  13885. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13886. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13887. infoStr := string(Iinfos)
  13888. idetinfoStr := string(Idetinfos)
  13889. psn := &models.HisPsn{
  13890. PsnNo: res.Output.Baseinfo.PsnNo,
  13891. PatientId: patient.ID,
  13892. Certno: res.Output.Baseinfo.Certno,
  13893. Gend: res.Output.Baseinfo.Gend,
  13894. Naty: res.Output.Baseinfo.Naty,
  13895. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13896. PsnName: res.Output.Baseinfo.PsnName,
  13897. Idetinfo: idetinfoStr,
  13898. Insuinfo: infoStr,
  13899. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13900. CardInfo: card_info,
  13901. VerifyNumber: token,
  13902. }
  13903. service.CreateHisPsn(psn)
  13904. c.ServeSuccessJSON(map[string]interface{}{
  13905. "patient": patient,
  13906. "number": token,
  13907. })
  13908. }
  13909. }
  13910. } else {
  13911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13912. return
  13913. }
  13914. } else { //读卡失败
  13915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13916. return
  13917. }
  13918. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13919. var api string
  13920. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13921. "&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
  13922. fmt.Println(api)
  13923. resp, requestErr := http.Get(api)
  13924. if requestErr != nil {
  13925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13926. return
  13927. }
  13928. body, ioErr := ioutil.ReadAll(resp.Body)
  13929. if ioErr != nil {
  13930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13932. return
  13933. }
  13934. var respJSON map[string]interface{}
  13935. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13938. return
  13939. }
  13940. var status string
  13941. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13942. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13943. //console.log()
  13944. fmt.Println("type===")
  13945. fmt.Println(card_type)
  13946. var token string
  13947. var res ResultTwo //1101结果
  13948. //var res10265 ResultTwoesultTwo10265 //1101结果
  13949. var card_info string //卡信息
  13950. //var busi_card_info string
  13951. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13952. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13953. if status == "0" { //读卡成功
  13954. if card_type == "1" {
  13955. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13956. result, _ := json.Marshal(respJSON)
  13957. fmt.Println(result)
  13958. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13959. utils.ErrorLog("解析失败:%v", err)
  13960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13961. return
  13962. }
  13963. fmt.Println(res)
  13964. } else {
  13965. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13966. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13967. result, _ := json.Marshal(respJSON)
  13968. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13969. utils.ErrorLog("解析失败:%v", err)
  13970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13971. return
  13972. }
  13973. }
  13974. if res.Infcode == 0 {
  13975. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13976. if err == gorm.ErrRecordNotFound {
  13977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13978. return
  13979. } else if err != nil {
  13980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13981. return
  13982. } else {
  13983. if card_type == "1" {
  13984. bas := strings.Split(card_info, "|")
  13985. basNumber := bas[2]
  13986. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13987. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13988. infoStr := string(Iinfos)
  13989. idetinfoStr := string(Idetinfos)
  13990. psn := &models.HisPsn{
  13991. PsnNo: res.Output.Baseinfo.PsnNo,
  13992. PatientId: patient.ID,
  13993. Certno: res.Output.Baseinfo.Certno,
  13994. Gend: res.Output.Baseinfo.Gend,
  13995. Naty: res.Output.Baseinfo.Naty,
  13996. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13997. PsnName: res.Output.Baseinfo.PsnName,
  13998. Idetinfo: idetinfoStr,
  13999. Insuinfo: infoStr,
  14000. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14001. CardInfo: card_info,
  14002. //VerifyNumber: busi_card_info,
  14003. }
  14004. service.CreateHisPsn(psn)
  14005. var rf []*ResultFive
  14006. json.Unmarshal([]byte(infoStr), &rf)
  14007. var insutypes []*ResultFive
  14008. var insutype string
  14009. var is390 int = 0
  14010. var is310 int = 0
  14011. for _, item := range rf {
  14012. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14013. insutypes = append(insutypes, item)
  14014. }
  14015. }
  14016. if len(insutypes) == 1 {
  14017. insutype = insutypes[0].Insutype
  14018. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14019. } else {
  14020. for _, i := range insutypes {
  14021. if i.Insutype == "390" {
  14022. is390 = 1
  14023. }
  14024. if i.Insutype == "310" {
  14025. is310 = 1
  14026. }
  14027. }
  14028. }
  14029. if is390 == 1 {
  14030. insutype = "390"
  14031. }
  14032. if is310 == 1 {
  14033. insutype = "310"
  14034. }
  14035. if len(insutypes) == 0 {
  14036. insutype = "310"
  14037. }
  14038. c.ServeSuccessJSON(map[string]interface{}{
  14039. "patient": patient,
  14040. "number": basNumber,
  14041. "insutype": insutype,
  14042. })
  14043. } else {
  14044. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14045. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14046. infoStr := string(Iinfos)
  14047. idetinfoStr := string(Idetinfos)
  14048. psn := &models.HisPsn{
  14049. PsnNo: res.Output.Baseinfo.PsnNo,
  14050. PatientId: patient.ID,
  14051. Certno: res.Output.Baseinfo.Certno,
  14052. Gend: res.Output.Baseinfo.Gend,
  14053. Naty: res.Output.Baseinfo.Naty,
  14054. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14055. PsnName: res.Output.Baseinfo.PsnName,
  14056. Idetinfo: idetinfoStr,
  14057. Insuinfo: infoStr,
  14058. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14059. CardInfo: card_info,
  14060. VerifyNumber: token,
  14061. }
  14062. service.CreateHisPsn(psn)
  14063. c.ServeSuccessJSON(map[string]interface{}{
  14064. "patient": patient,
  14065. "number": token,
  14066. })
  14067. }
  14068. }
  14069. } else {
  14070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14071. return
  14072. }
  14073. } else { //读卡失败
  14074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14075. return
  14076. }
  14077. } else {
  14078. if initFlag == 0 {
  14079. c.TestGetBasBaseInit()
  14080. }
  14081. basStr := c.GetBasBaseInfo()
  14082. if len(basStr) == 0 {
  14083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14084. return
  14085. }
  14086. fmt.Println(basStr)
  14087. bas := strings.Split(basStr, "|")
  14088. basNumber := bas[1]
  14089. fmt.Println(basNumber)
  14090. card_sn := bas[3]
  14091. fmt.Println(card_sn)
  14092. cardNumber := bas[2]
  14093. fmt.Println(cardNumber)
  14094. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14095. var result string
  14096. if bas[0][:2] == "44" {
  14097. 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)
  14098. } else {
  14099. 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)
  14100. }
  14101. var dat map[string]interface{}
  14102. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14103. fmt.Println(dat)
  14104. } else {
  14105. fmt.Println(err)
  14106. }
  14107. userJSONBytes, _ := json.Marshal(dat)
  14108. var res ResultTwo
  14109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14110. utils.ErrorLog("解析失败:%v", err)
  14111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14112. return
  14113. }
  14114. if res.Infcode == 0 {
  14115. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14116. if err == gorm.ErrRecordNotFound {
  14117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14118. return
  14119. } else if err != nil {
  14120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14121. return
  14122. } else {
  14123. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14124. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14125. infoStr := string(Iinfos)
  14126. idetinfoStr := string(Idetinfos)
  14127. var rf []*ResultFive
  14128. json.Unmarshal([]byte(infoStr), &rf)
  14129. var insutypes []*ResultFive
  14130. var insutype string
  14131. var is390 int = 0
  14132. var is310 int = 0
  14133. var insuplc_admdvs string
  14134. for _, item := range rf {
  14135. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14136. insutypes = append(insutypes, item)
  14137. }
  14138. }
  14139. if len(insutypes) == 1 {
  14140. insutype = insutypes[0].Insutype
  14141. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14142. } else {
  14143. for _, i := range insutypes {
  14144. if i.Insutype == "390" {
  14145. is390 = 1
  14146. }
  14147. if i.Insutype == "310" {
  14148. is310 = 1
  14149. }
  14150. }
  14151. }
  14152. if is390 == 1 {
  14153. insutype = "390"
  14154. }
  14155. if is310 == 1 {
  14156. insutype = "310"
  14157. }
  14158. if len(insutypes) == 0 {
  14159. insutype = "310"
  14160. }
  14161. for _, item := range rf {
  14162. if item.Insutype == insutype {
  14163. insuplc_admdvs = item.InsuplcAdmdvs
  14164. }
  14165. }
  14166. psn := &models.HisPsn{
  14167. PsnNo: res.Output.Baseinfo.PsnNo,
  14168. PatientId: patient.ID,
  14169. Certno: res.Output.Baseinfo.Certno,
  14170. Gend: res.Output.Baseinfo.Gend,
  14171. Naty: res.Output.Baseinfo.Naty,
  14172. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14173. PsnName: res.Output.Baseinfo.PsnName,
  14174. Idetinfo: idetinfoStr,
  14175. Insuinfo: infoStr,
  14176. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14177. CardInfo: basStr,
  14178. VerifyNumber: "",
  14179. InsuplcAdmdvs: insuplc_admdvs,
  14180. }
  14181. service.CreateHisPsn(psn)
  14182. c.ServeSuccessJSON(map[string]interface{}{
  14183. "patient": patient,
  14184. "number": basNumber,
  14185. })
  14186. }
  14187. } else {
  14188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14189. return
  14190. }
  14191. break
  14192. }
  14193. case 2:
  14194. if miConfig.MdtrtareaAdmvs == "430800" {
  14195. if initFlag == 0 {
  14196. c.TestGetHnBasBaseInit()
  14197. }
  14198. SFZStr := c.GetSFZBaseInfo()
  14199. if len(SFZStr) == 0 {
  14200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14201. return
  14202. }
  14203. fmt.Println(SFZStr)
  14204. id_card_str := strings.Split(SFZStr, "^")
  14205. card_no := id_card_str[0]
  14206. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14207. //name := id_card_str[1]
  14208. //name = ConvertToString(name, "gbk", "utf-8")
  14209. 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)
  14210. var dat map[string]interface{}
  14211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14212. fmt.Println(dat)
  14213. } else {
  14214. fmt.Println(err)
  14215. }
  14216. userJSONBytes, _ := json.Marshal(dat)
  14217. var res ResultTwo
  14218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14219. utils.ErrorLog("解析失败:%v", err)
  14220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14221. return
  14222. }
  14223. if res.Infcode == 0 {
  14224. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14225. if err == gorm.ErrRecordNotFound {
  14226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14227. return
  14228. } else if err != nil {
  14229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14230. return
  14231. } else {
  14232. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14233. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14234. infoStr := string(Iinfos)
  14235. idetinfoStr := string(Idetinfos)
  14236. var rf []*ResultFive
  14237. json.Unmarshal([]byte(infoStr), &rf)
  14238. var insutypes []*ResultFive
  14239. var insutype string
  14240. var is390 int = 0
  14241. var is310 int = 0
  14242. for _, item := range rf {
  14243. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14244. insutypes = append(insutypes, item)
  14245. }
  14246. }
  14247. if len(insutypes) == 1 {
  14248. insutype = insutypes[0].Insutype
  14249. } else {
  14250. for _, i := range insutypes {
  14251. if i.Insutype == "390" {
  14252. is390 = 1
  14253. }
  14254. if i.Insutype == "310" {
  14255. is310 = 1
  14256. }
  14257. }
  14258. }
  14259. if is390 == 1 {
  14260. insutype = "390"
  14261. }
  14262. if is310 == 1 {
  14263. insutype = "310"
  14264. }
  14265. if len(insutypes) == 0 {
  14266. insutype = "310"
  14267. }
  14268. var InsuplcAdmdvs string
  14269. for _, item := range rf {
  14270. if item.Insutype == insutype {
  14271. InsuplcAdmdvs = item.InsuplcAdmdvs
  14272. }
  14273. }
  14274. psn := &models.HisPsn{
  14275. PsnNo: res.Output.Baseinfo.PsnNo,
  14276. PatientId: patient.ID,
  14277. Certno: res.Output.Baseinfo.Certno,
  14278. Gend: res.Output.Baseinfo.Gend,
  14279. Naty: res.Output.Baseinfo.Naty,
  14280. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14281. PsnName: res.Output.Baseinfo.PsnName,
  14282. Idetinfo: idetinfoStr,
  14283. Insuinfo: infoStr,
  14284. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14285. CardInfo: SFZStr,
  14286. VerifyNumber: "",
  14287. InsuplcAdmdvs: InsuplcAdmdvs,
  14288. }
  14289. service.CreateHisPsn(psn)
  14290. c.ServeSuccessJSON(map[string]interface{}{
  14291. "patient": patient,
  14292. "number": card_no,
  14293. "insutype": insutype,
  14294. })
  14295. }
  14296. } else {
  14297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14298. return
  14299. }
  14300. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14301. var res ResultTwo
  14302. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14303. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14304. "&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)
  14305. resp, requestErr := http.Get(api)
  14306. if requestErr != nil {
  14307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14308. return
  14309. }
  14310. body, ioErr := ioutil.ReadAll(resp.Body)
  14311. if ioErr != nil {
  14312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14314. return
  14315. }
  14316. var respJSON map[string]interface{}
  14317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14320. return
  14321. }
  14322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14323. result, _ := json.Marshal(respJSON)
  14324. fmt.Println("log")
  14325. fmt.Println(string(result))
  14326. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14327. utils.ErrorLog("解析失败:%v", err)
  14328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14329. return
  14330. }
  14331. if res.Infcode == 0 {
  14332. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14333. if err == gorm.ErrRecordNotFound {
  14334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14335. return
  14336. } else if err != nil {
  14337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14338. return
  14339. } else {
  14340. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14341. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14342. infoStr := string(Iinfos)
  14343. idetinfoStr := string(Idetinfos)
  14344. psn := &models.HisPsn{
  14345. PsnNo: res.Output.Baseinfo.PsnNo,
  14346. PatientId: patient.ID,
  14347. Certno: res.Output.Baseinfo.Certno,
  14348. Gend: res.Output.Baseinfo.Gend,
  14349. Naty: res.Output.Baseinfo.Naty,
  14350. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14351. PsnName: res.Output.Baseinfo.PsnName,
  14352. Idetinfo: idetinfoStr,
  14353. Insuinfo: infoStr,
  14354. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14355. }
  14356. service.CreateHisPsn(psn)
  14357. c.ServeSuccessJSON(map[string]interface{}{
  14358. "patient": patient,
  14359. "number": res.Output.Baseinfo.Certno,
  14360. })
  14361. }
  14362. } else {
  14363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14364. return
  14365. }
  14366. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14367. var res ResultTwo
  14368. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14369. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14370. "&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)
  14371. resp, requestErr := http.Get(api)
  14372. if requestErr != nil {
  14373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14374. return
  14375. }
  14376. body, ioErr := ioutil.ReadAll(resp.Body)
  14377. if ioErr != nil {
  14378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14380. return
  14381. }
  14382. var respJSON map[string]interface{}
  14383. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14386. return
  14387. }
  14388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14389. result, _ := json.Marshal(respJSON)
  14390. fmt.Println("log")
  14391. fmt.Println(string(result))
  14392. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14393. utils.ErrorLog("解析失败:%v", err)
  14394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14395. return
  14396. }
  14397. if res.Infcode == 0 {
  14398. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14399. if err == gorm.ErrRecordNotFound {
  14400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14401. return
  14402. } else if err != nil {
  14403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14404. return
  14405. } else {
  14406. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14407. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14408. infoStr := string(Iinfos)
  14409. idetinfoStr := string(Idetinfos)
  14410. psn := &models.HisPsn{
  14411. PsnNo: res.Output.Baseinfo.PsnNo,
  14412. PatientId: patient.ID,
  14413. Certno: res.Output.Baseinfo.Certno,
  14414. Gend: res.Output.Baseinfo.Gend,
  14415. Naty: res.Output.Baseinfo.Naty,
  14416. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14417. PsnName: res.Output.Baseinfo.PsnName,
  14418. Idetinfo: idetinfoStr,
  14419. Insuinfo: infoStr,
  14420. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14421. }
  14422. service.CreateHisPsn(psn)
  14423. c.ServeSuccessJSON(map[string]interface{}{
  14424. "patient": patient,
  14425. "number": res.Output.Baseinfo.Certno,
  14426. })
  14427. }
  14428. } else {
  14429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14430. return
  14431. }
  14432. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14433. var res ResultTwo
  14434. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14435. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14436. "&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)
  14437. resp, requestErr := http.Get(api)
  14438. if requestErr != nil {
  14439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14440. return
  14441. }
  14442. body, ioErr := ioutil.ReadAll(resp.Body)
  14443. if ioErr != nil {
  14444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14446. return
  14447. }
  14448. var respJSON map[string]interface{}
  14449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14452. return
  14453. }
  14454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14455. result, _ := json.Marshal(respJSON)
  14456. fmt.Println("log")
  14457. fmt.Println(string(result))
  14458. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14459. utils.ErrorLog("解析失败:%v", err)
  14460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14461. return
  14462. }
  14463. if res.Infcode == 0 {
  14464. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14465. if err == gorm.ErrRecordNotFound {
  14466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14467. return
  14468. } else if err != nil {
  14469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14470. return
  14471. } else {
  14472. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14473. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14474. infoStr := string(Iinfos)
  14475. idetinfoStr := string(Idetinfos)
  14476. var rf []*ResultFive
  14477. json.Unmarshal([]byte(infoStr), &rf)
  14478. var insutypes []*ResultFive
  14479. var insutype string
  14480. var is390 int = 0
  14481. var is310 int = 0
  14482. for _, item := range rf {
  14483. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14484. insutypes = append(insutypes, item)
  14485. }
  14486. }
  14487. if len(insutypes) == 1 {
  14488. insutype = insutypes[0].Insutype
  14489. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14490. } else {
  14491. for _, i := range insutypes {
  14492. if i.Insutype == "390" {
  14493. is390 = 1
  14494. }
  14495. if i.Insutype == "310" {
  14496. is310 = 1
  14497. }
  14498. }
  14499. }
  14500. if is390 == 1 {
  14501. insutype = "390"
  14502. }
  14503. if is310 == 1 {
  14504. insutype = "310"
  14505. }
  14506. if len(insutypes) == 0 {
  14507. insutype = "390"
  14508. }
  14509. var insuplc_admdvs string
  14510. for _, item := range rf {
  14511. if item.Insutype == insutype {
  14512. insuplc_admdvs = item.InsuplcAdmdvs
  14513. }
  14514. }
  14515. psn := &models.HisPsn{
  14516. PsnNo: res.Output.Baseinfo.PsnNo,
  14517. PatientId: patient.ID,
  14518. Certno: res.Output.Baseinfo.Certno,
  14519. Gend: res.Output.Baseinfo.Gend,
  14520. Naty: res.Output.Baseinfo.Naty,
  14521. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14522. PsnName: res.Output.Baseinfo.PsnName,
  14523. Idetinfo: idetinfoStr,
  14524. Insuinfo: infoStr,
  14525. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14526. InsuplcAdmdvs: insuplc_admdvs,
  14527. }
  14528. service.CreateHisPsn(psn)
  14529. c.ServeSuccessJSON(map[string]interface{}{
  14530. "patient": patient,
  14531. "number": res.Output.Baseinfo.Certno,
  14532. })
  14533. }
  14534. } else {
  14535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14536. return
  14537. }
  14538. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14539. res := c.GetoleInfo()
  14540. if res.Infcode == 0 {
  14541. var result string
  14542. if res.Output.MdtrtCertType == "01" {
  14543. 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)
  14544. } else if res.Output.MdtrtCertType == "02" {
  14545. 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)
  14546. } else if res.Output.MdtrtCertType == "03" {
  14547. 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)
  14548. }
  14549. var dat map[string]interface{}
  14550. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14551. fmt.Println(dat)
  14552. } else {
  14553. fmt.Println(err)
  14554. }
  14555. userJSONBytes, _ := json.Marshal(dat)
  14556. var res2 ResultTwo
  14557. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14558. utils.ErrorLog("解析失败:%v", err)
  14559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14560. return
  14561. }
  14562. if res2.Infcode == 0 {
  14563. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14564. if err == gorm.ErrRecordNotFound {
  14565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14566. return
  14567. } else if err != nil {
  14568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14569. return
  14570. } else {
  14571. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14572. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14573. infoStr := string(Iinfos)
  14574. idetinfoStr := string(Idetinfos)
  14575. var rf []*ResultFive
  14576. json.Unmarshal([]byte(infoStr), &rf)
  14577. var insutypes []*ResultFive
  14578. var insutype string
  14579. var is390 int = 0
  14580. var is310 int = 0
  14581. //var insuplc_admdvs string
  14582. for _, item := range rf {
  14583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14584. insutypes = append(insutypes, item)
  14585. }
  14586. }
  14587. if len(insutypes) == 1 {
  14588. insutype = insutypes[0].Insutype
  14589. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14590. } else {
  14591. for _, i := range insutypes {
  14592. if i.Insutype == "390" {
  14593. is390 = 1
  14594. }
  14595. if i.Insutype == "310" {
  14596. is310 = 1
  14597. }
  14598. }
  14599. }
  14600. if is390 == 1 {
  14601. insutype = "390"
  14602. }
  14603. if is310 == 1 {
  14604. insutype = "310"
  14605. }
  14606. if len(insutypes) == 0 {
  14607. insutype = "310"
  14608. }
  14609. psn := &models.HisPsn{
  14610. PsnNo: res2.Output.Baseinfo.PsnNo,
  14611. PatientId: patient.ID,
  14612. //Brdy: res2.Output.Baseinfo.Brdy,
  14613. Certno: res2.Output.Baseinfo.Certno,
  14614. Gend: res2.Output.Baseinfo.Gend,
  14615. Naty: res2.Output.Baseinfo.Naty,
  14616. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14617. PsnName: res2.Output.Baseinfo.PsnName,
  14618. Idetinfo: idetinfoStr,
  14619. Insuinfo: infoStr,
  14620. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14621. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14622. VerifyNumber: res.Output.EcToken,
  14623. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14624. }
  14625. service.CreateHisPsn(psn)
  14626. var balc float64
  14627. for _, item := range rf {
  14628. if item.Insutype == insutype {
  14629. balc = item.Balc
  14630. }
  14631. }
  14632. c.ServeSuccessJSON(map[string]interface{}{
  14633. "patient": patient,
  14634. "number": res.Output.CardNo,
  14635. "insutype": insutype,
  14636. "blac": balc,
  14637. "desc": idetinfoStr,
  14638. })
  14639. }
  14640. } else {
  14641. c.ServeSuccessJSON(map[string]interface{}{
  14642. "failed_code": -10,
  14643. "msg": res2.ErrMsg,
  14644. })
  14645. }
  14646. } else {
  14647. c.ServeSuccessJSON(map[string]interface{}{
  14648. "failed_code": -10,
  14649. "msg": res.ErrMsg,
  14650. })
  14651. }
  14652. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14653. var insuplc_admdvs string
  14654. if len(patient.InsuplcAdmdvs) > 0 {
  14655. insuplc_admdvs = patient.InsuplcAdmdvs
  14656. } else {
  14657. if len(insuplc_admdvs_str) > 0 {
  14658. insuplc_admdvs = insuplc_admdvs_str
  14659. } else {
  14660. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14661. }
  14662. }
  14663. //请求内网数据
  14664. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14665. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14666. "&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=" + ""
  14667. resp, requestErr := http.Get(api)
  14668. if requestErr != nil {
  14669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14670. return
  14671. }
  14672. body, ioErr := ioutil.ReadAll(resp.Body)
  14673. if ioErr != nil {
  14674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14676. return
  14677. }
  14678. var respJSON map[string]interface{}
  14679. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14682. return
  14683. }
  14684. status := respJSON["data"].(map[string]interface{})["status"].(string)
  14685. if status == "0" {
  14686. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  14687. c.ServeSuccessJSON(map[string]interface{}{
  14688. "failed_code": -10,
  14689. "msg": err_msg,
  14690. })
  14691. return
  14692. }
  14693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14694. var res ResultTwo
  14695. result, _ := json.Marshal(respJSON)
  14696. fmt.Println("log")
  14697. fmt.Println(string(result))
  14698. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14699. utils.ErrorLog("解析失败:%v", err)
  14700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14701. return
  14702. }
  14703. if res.Infcode == 0 {
  14704. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14705. if err == gorm.ErrRecordNotFound {
  14706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14707. return
  14708. } else if err != nil {
  14709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14710. return
  14711. } else {
  14712. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14713. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14714. infoStr := string(Iinfos)
  14715. idetinfoStr := string(Idetinfos)
  14716. psn := &models.HisPsn{
  14717. PsnNo: res.Output.Baseinfo.PsnNo,
  14718. PatientId: patient.ID,
  14719. Certno: res.Output.Baseinfo.Certno,
  14720. Gend: res.Output.Baseinfo.Gend,
  14721. Naty: res.Output.Baseinfo.Naty,
  14722. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14723. PsnName: res.Output.Baseinfo.PsnName,
  14724. Idetinfo: idetinfoStr,
  14725. Insuinfo: infoStr,
  14726. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14727. }
  14728. service.CreateHisPsn(psn)
  14729. var rf []*ResultFive
  14730. json.Unmarshal([]byte(infoStr), &rf)
  14731. var insutypes []*ResultFive
  14732. var is390 int = 0
  14733. var is310 int = 0
  14734. var insutype string
  14735. for _, item := range rf {
  14736. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14737. insutypes = append(insutypes, item)
  14738. }
  14739. }
  14740. if len(insutypes) == 1 {
  14741. insutype = insutypes[0].Insutype
  14742. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14743. } else {
  14744. for _, i := range insutypes {
  14745. if i.Insutype == "390" {
  14746. is390 = 1
  14747. }
  14748. if i.Insutype == "310" {
  14749. is310 = 1
  14750. }
  14751. }
  14752. }
  14753. if is390 == 1 {
  14754. insutype = "390"
  14755. }
  14756. if is310 == 1 {
  14757. insutype = "310"
  14758. }
  14759. if len(insutypes) == 0 {
  14760. insutype = "390"
  14761. }
  14762. c.ServeSuccessJSON(map[string]interface{}{
  14763. "patient": patient,
  14764. "insutype": insutype,
  14765. "number": res.Output.Baseinfo.Certno,
  14766. "info": res,
  14767. })
  14768. }
  14769. } else {
  14770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14771. return
  14772. }
  14773. } else {
  14774. SFZStr := c.GetSFZBaseInfo()
  14775. id_card_str := strings.Split(SFZStr, "^")
  14776. id_card_number := id_card_str[0]
  14777. card_sn := ""
  14778. 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)
  14779. var dat map[string]interface{}
  14780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14781. fmt.Println(dat)
  14782. } else {
  14783. fmt.Println(err)
  14784. }
  14785. userJSONBytes, _ := json.Marshal(dat)
  14786. var res ResultTwo
  14787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14788. utils.ErrorLog("解析失败:%v", err)
  14789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14790. return
  14791. }
  14792. if res.Infcode == 0 {
  14793. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  14794. if err == gorm.ErrRecordNotFound {
  14795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14796. return
  14797. } else if err != nil {
  14798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14799. return
  14800. } else {
  14801. c.ServeSuccessJSON(map[string]interface{}{
  14802. "patient": patient,
  14803. "number": id_card_number,
  14804. })
  14805. }
  14806. } else {
  14807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14808. return
  14809. }
  14810. }
  14811. break
  14812. case 3:
  14813. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14814. var api string
  14815. if miConfig.MdtrtareaAdmvs == "320921" {
  14816. 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 +
  14817. "&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
  14818. fmt.Println(api)
  14819. } else {
  14820. 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 +
  14821. "&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)
  14822. }
  14823. resp, requestErr := http.Get(api)
  14824. if requestErr != nil {
  14825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14826. return
  14827. }
  14828. body, ioErr := ioutil.ReadAll(resp.Body)
  14829. if ioErr != nil {
  14830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14832. return
  14833. }
  14834. var respJSON map[string]interface{}
  14835. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14838. return
  14839. }
  14840. var status string
  14841. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14842. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14843. var token string
  14844. var res ResultTwo //1101结果
  14845. var res10265 ResultTwo10265 //1101结果
  14846. var card_info string //卡信息
  14847. var busi_card_info string
  14848. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14849. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14850. if status == "0" { //读卡成功
  14851. if card_type == "1" {
  14852. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14853. result, _ := json.Marshal(respJSON)
  14854. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14855. utils.ErrorLog("解析失败:%v", err)
  14856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14857. return
  14858. }
  14859. res.ErrMsg = res10265.ErrMsg
  14860. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14861. res.Infcode = infocode
  14862. res.Output = res10265.Output
  14863. res.InfRefmsgid = res10265.InfRefmsgid
  14864. } else {
  14865. //var card_info string //卡信息
  14866. //var busi_card_info string
  14867. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14868. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14869. //fmt.Println(card_info)
  14870. //fmt.Println(busi_card_info)
  14871. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14872. result, _ := json.Marshal(respJSON)
  14873. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14874. utils.ErrorLog("解析失败:%v", err)
  14875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14876. return
  14877. }
  14878. res.ErrMsg = res10265.ErrMsg
  14879. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14880. res.Infcode = infocode
  14881. res.Output = res10265.Output
  14882. res.InfRefmsgid = res10265.InfRefmsgid
  14883. }
  14884. if res.Infcode == 0 {
  14885. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14886. if err == gorm.ErrRecordNotFound {
  14887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14888. return
  14889. } else if err != nil {
  14890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14891. return
  14892. } else {
  14893. if card_type == "1" {
  14894. bas := strings.Split(card_info, "|")
  14895. basNumber := bas[2]
  14896. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14897. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14898. infoStr := string(Iinfos)
  14899. idetinfoStr := string(Idetinfos)
  14900. psn := &models.HisPsn{
  14901. PsnNo: res.Output.Baseinfo.PsnNo,
  14902. PatientId: patient.ID,
  14903. Certno: res.Output.Baseinfo.Certno,
  14904. //Brdy: res.Output.Baseinfo.Brdy,
  14905. Gend: res.Output.Baseinfo.Gend,
  14906. Naty: res.Output.Baseinfo.Naty,
  14907. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14908. PsnName: res.Output.Baseinfo.PsnName,
  14909. Idetinfo: idetinfoStr,
  14910. Insuinfo: infoStr,
  14911. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14912. CardInfo: card_info,
  14913. VerifyNumber: busi_card_info,
  14914. }
  14915. service.CreateHisPsn(psn)
  14916. c.ServeSuccessJSON(map[string]interface{}{
  14917. "patient": patient,
  14918. "number": basNumber,
  14919. })
  14920. } else {
  14921. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14922. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14923. infoStr := string(Iinfos)
  14924. idetinfoStr := string(Idetinfos)
  14925. psn := &models.HisPsn{
  14926. PsnNo: res.Output.Baseinfo.PsnNo,
  14927. PatientId: patient.ID,
  14928. Certno: res.Output.Baseinfo.Certno,
  14929. Gend: res.Output.Baseinfo.Gend,
  14930. Naty: res.Output.Baseinfo.Naty,
  14931. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14932. PsnName: res.Output.Baseinfo.PsnName,
  14933. Idetinfo: idetinfoStr,
  14934. Insuinfo: infoStr,
  14935. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14936. CardInfo: card_info,
  14937. VerifyNumber: token,
  14938. }
  14939. service.CreateHisPsn(psn)
  14940. var rf []*ResultFive
  14941. json.Unmarshal([]byte(infoStr), &rf)
  14942. var insutypes []*ResultFive
  14943. var insutype string
  14944. var is390 int = 0
  14945. var is310 int = 0
  14946. for _, item := range rf {
  14947. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14948. insutypes = append(insutypes, item)
  14949. }
  14950. }
  14951. if len(insutypes) == 1 {
  14952. insutype = insutypes[0].Insutype
  14953. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14954. } else {
  14955. for _, i := range insutypes {
  14956. if i.Insutype == "390" {
  14957. is390 = 1
  14958. }
  14959. if i.Insutype == "310" {
  14960. is310 = 1
  14961. }
  14962. }
  14963. }
  14964. if is390 == 1 {
  14965. insutype = "390"
  14966. }
  14967. if is310 == 1 {
  14968. insutype = "310"
  14969. }
  14970. if len(insutypes) == 0 {
  14971. insutype = "310"
  14972. }
  14973. c.ServeSuccessJSON(map[string]interface{}{
  14974. "patient": patient,
  14975. "number": token,
  14976. "insutype": insutype,
  14977. })
  14978. }
  14979. }
  14980. } else {
  14981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14982. return
  14983. }
  14984. } else { //读卡失败
  14985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14986. return
  14987. }
  14988. }
  14989. break
  14990. case 4:
  14991. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14992. var api string
  14993. if miConfig.MdtrtareaAdmvs == "320921" {
  14994. 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 +
  14995. "&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
  14996. fmt.Println(api)
  14997. } else {
  14998. 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 +
  14999. "&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)
  15000. }
  15001. resp, requestErr := http.Get(api)
  15002. if requestErr != nil {
  15003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15004. return
  15005. }
  15006. body, ioErr := ioutil.ReadAll(resp.Body)
  15007. if ioErr != nil {
  15008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15010. return
  15011. }
  15012. var respJSON map[string]interface{}
  15013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15016. return
  15017. }
  15018. var status string
  15019. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15020. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15021. var token string
  15022. var res ResultTwo //1101结果
  15023. var res10265 ResultTwo10265 //1101结果
  15024. if status == "0" { //读卡成功
  15025. var card_info string //卡信息
  15026. var busi_card_info string
  15027. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15028. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15029. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15030. fmt.Println(card_info)
  15031. fmt.Println(busi_card_info)
  15032. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15033. result, _ := json.Marshal(respJSON)
  15034. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15035. utils.ErrorLog("解析失败:%v", err)
  15036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15037. return
  15038. }
  15039. res.ErrMsg = res10265.ErrMsg
  15040. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15041. res.Infcode = infocode
  15042. res.Output = res10265.Output
  15043. res.InfRefmsgid = res10265.InfRefmsgid
  15044. if res.Infcode == 0 {
  15045. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15046. if err == gorm.ErrRecordNotFound {
  15047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15048. return
  15049. } else if err != nil {
  15050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15051. return
  15052. } else {
  15053. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15054. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15055. infoStr := string(Iinfos)
  15056. idetinfoStr := string(Idetinfos)
  15057. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15058. psn := &models.HisPsn{
  15059. PsnNo: res.Output.Baseinfo.PsnNo,
  15060. PatientId: patient.ID,
  15061. Certno: res.Output.Baseinfo.Certno,
  15062. Brdy: b,
  15063. Age: float64(age),
  15064. //Brdy: res.Output.Baseinfo.Brdy,
  15065. Gend: res.Output.Baseinfo.Gend,
  15066. Naty: res.Output.Baseinfo.Naty,
  15067. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15068. PsnName: res.Output.Baseinfo.PsnName,
  15069. Idetinfo: idetinfoStr,
  15070. Insuinfo: infoStr,
  15071. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15072. CardInfo: card_info,
  15073. VerifyNumber: token,
  15074. }
  15075. var rf []*ResultFive
  15076. json.Unmarshal([]byte(infoStr), &rf)
  15077. var insutypes []*ResultFive
  15078. var insutype string
  15079. var is390 int = 0
  15080. var is310 int = 0
  15081. for _, item := range rf {
  15082. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15083. insutypes = append(insutypes, item)
  15084. }
  15085. }
  15086. if len(insutypes) == 1 {
  15087. insutype = insutypes[0].Insutype
  15088. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15089. } else {
  15090. for _, i := range insutypes {
  15091. if i.Insutype == "390" {
  15092. is390 = 1
  15093. }
  15094. if i.Insutype == "310" {
  15095. is310 = 1
  15096. }
  15097. }
  15098. }
  15099. if is390 == 1 {
  15100. insutype = "390"
  15101. }
  15102. if is310 == 1 {
  15103. insutype = "310"
  15104. }
  15105. if len(insutypes) == 0 {
  15106. insutype = "310"
  15107. }
  15108. service.CreateHisPsn(psn)
  15109. c.ServeSuccessJSON(map[string]interface{}{
  15110. "patient": patient,
  15111. "number": token,
  15112. "insutype": insutype,
  15113. })
  15114. }
  15115. } else {
  15116. c.ServeSuccessJSON(map[string]interface{}{
  15117. "failed_code": -10,
  15118. "msg": res.ErrMsg,
  15119. })
  15120. }
  15121. } else { //读卡失败
  15122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15123. return
  15124. }
  15125. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15126. var api string
  15127. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15128. "&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
  15129. resp, requestErr := http.Get(api)
  15130. if requestErr != nil {
  15131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15132. return
  15133. }
  15134. body, ioErr := ioutil.ReadAll(resp.Body)
  15135. if ioErr != nil {
  15136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15138. return
  15139. }
  15140. var respJSON map[string]interface{}
  15141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15144. return
  15145. }
  15146. var status string
  15147. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15148. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15149. var token string
  15150. var res ResultTwo //1101结果
  15151. if status == "1" { //读卡成功
  15152. var card_info string //卡信息
  15153. var busi_card_info string
  15154. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15155. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15156. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15157. fmt.Println(card_info)
  15158. fmt.Println(busi_card_info)
  15159. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15160. result, _ := json.Marshal(respJSON)
  15161. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15162. utils.ErrorLog("解析失败:%v", err)
  15163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15164. return
  15165. }
  15166. if res.Infcode == 0 {
  15167. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15168. if err == gorm.ErrRecordNotFound {
  15169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15170. return
  15171. } else if err != nil {
  15172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15173. return
  15174. } else {
  15175. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15176. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15177. infoStr := string(Iinfos)
  15178. idetinfoStr := string(Idetinfos)
  15179. psn := &models.HisPsn{
  15180. PsnNo: res.Output.Baseinfo.PsnNo,
  15181. PatientId: patient.ID,
  15182. Certno: res.Output.Baseinfo.Certno,
  15183. Gend: res.Output.Baseinfo.Gend,
  15184. Naty: res.Output.Baseinfo.Naty,
  15185. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15186. PsnName: res.Output.Baseinfo.PsnName,
  15187. Idetinfo: idetinfoStr,
  15188. Insuinfo: infoStr,
  15189. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15190. CardInfo: card_info,
  15191. VerifyNumber: token,
  15192. }
  15193. var rf []*ResultFive
  15194. json.Unmarshal([]byte(infoStr), &rf)
  15195. var insutypes []*ResultFive
  15196. var insutype string
  15197. var is390 int = 0
  15198. var is310 int = 0
  15199. for _, item := range rf {
  15200. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15201. insutypes = append(insutypes, item)
  15202. }
  15203. }
  15204. if len(insutypes) == 1 {
  15205. insutype = insutypes[0].Insutype
  15206. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15207. } else {
  15208. for _, i := range insutypes {
  15209. if i.Insutype == "390" {
  15210. is390 = 1
  15211. }
  15212. if i.Insutype == "310" {
  15213. is310 = 1
  15214. }
  15215. }
  15216. }
  15217. if is390 == 1 {
  15218. insutype = "390"
  15219. }
  15220. if is310 == 1 {
  15221. insutype = "310"
  15222. }
  15223. if len(insutypes) == 0 {
  15224. insutype = "310"
  15225. }
  15226. service.CreateHisPsn(psn)
  15227. c.ServeSuccessJSON(map[string]interface{}{
  15228. "patient": patient,
  15229. "number": token,
  15230. "insutype": insutype,
  15231. })
  15232. }
  15233. } else {
  15234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15235. return
  15236. }
  15237. } else { //读卡失败
  15238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15239. return
  15240. }
  15241. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15242. var api string
  15243. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15244. "&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
  15245. resp, requestErr := http.Get(api)
  15246. if requestErr != nil {
  15247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15248. return
  15249. }
  15250. body, ioErr := ioutil.ReadAll(resp.Body)
  15251. if ioErr != nil {
  15252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15254. return
  15255. }
  15256. var respJSON map[string]interface{}
  15257. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15260. return
  15261. }
  15262. var status string
  15263. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15264. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15265. var token string
  15266. var res ResultTwo //1101结果
  15267. if status == "1" { //读卡成功
  15268. var card_info string //卡信息
  15269. var busi_card_info string
  15270. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15271. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15272. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15273. fmt.Println(card_info)
  15274. fmt.Println(busi_card_info)
  15275. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15276. result, _ := json.Marshal(respJSON)
  15277. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15278. utils.ErrorLog("解析失败:%v", err)
  15279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15280. return
  15281. }
  15282. if res.Infcode == 0 {
  15283. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15284. if err == gorm.ErrRecordNotFound {
  15285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15286. return
  15287. } else if err != nil {
  15288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15289. return
  15290. } else {
  15291. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15292. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15293. infoStr := string(Iinfos)
  15294. idetinfoStr := string(Idetinfos)
  15295. psn := &models.HisPsn{
  15296. PsnNo: res.Output.Baseinfo.PsnNo,
  15297. PatientId: patient.ID,
  15298. Certno: res.Output.Baseinfo.Certno,
  15299. Gend: res.Output.Baseinfo.Gend,
  15300. Naty: res.Output.Baseinfo.Naty,
  15301. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15302. PsnName: res.Output.Baseinfo.PsnName,
  15303. Idetinfo: idetinfoStr,
  15304. Insuinfo: infoStr,
  15305. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15306. CardInfo: card_info,
  15307. VerifyNumber: token,
  15308. }
  15309. var rf []*ResultFive
  15310. json.Unmarshal([]byte(infoStr), &rf)
  15311. var insutypes []*ResultFive
  15312. var insutype string
  15313. var is390 int = 0
  15314. var is310 int = 0
  15315. for _, item := range rf {
  15316. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15317. insutypes = append(insutypes, item)
  15318. }
  15319. }
  15320. if len(insutypes) == 1 {
  15321. insutype = insutypes[0].Insutype
  15322. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15323. } else {
  15324. for _, i := range insutypes {
  15325. if i.Insutype == "390" {
  15326. is390 = 1
  15327. }
  15328. if i.Insutype == "310" {
  15329. is310 = 1
  15330. }
  15331. }
  15332. }
  15333. if is390 == 1 {
  15334. insutype = "390"
  15335. }
  15336. if is310 == 1 {
  15337. insutype = "310"
  15338. }
  15339. if len(insutypes) == 0 {
  15340. insutype = "310"
  15341. }
  15342. service.CreateHisPsn(psn)
  15343. c.ServeSuccessJSON(map[string]interface{}{
  15344. "patient": patient,
  15345. "number": token,
  15346. "insutype": insutype,
  15347. })
  15348. }
  15349. } else {
  15350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15351. return
  15352. }
  15353. } else { //读卡失败
  15354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15355. return
  15356. }
  15357. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15358. //idNo := c.GetString("idNo")
  15359. //userName := c.GetString("userName")
  15360. //ecToken := c.GetString("ecToken")
  15361. //insuOrg := c.GetString("insuOrg")
  15362. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15363. utils.ErrorLog("解析失败:%v", json_result)
  15364. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15365. type ELeData struct {
  15366. Data struct {
  15367. IdNo string `json:"idNo"`
  15368. IdType string `json:"idType"`
  15369. UserName string `json:"userName"`
  15370. EcToken string `json:"ecToken"`
  15371. InsuOrg string `json:"insuOrg"`
  15372. Gender string `json:"gender"`
  15373. Birthday string `json:"birthday"`
  15374. Nationality string `json:"nationality"`
  15375. Email string `json:"email"`
  15376. Extra string `json:"extra"`
  15377. } `json:"data"`
  15378. Code int `json:"code"`
  15379. Message string `json:"message"`
  15380. }
  15381. var ele ELeData
  15382. err := json.Unmarshal([]byte(json_result), &ele)
  15383. if err != nil {
  15384. utils.ErrorLog("解析失败:%v", err)
  15385. }
  15386. token := ele.Data.EcToken
  15387. token = Remove0000(token)
  15388. 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)
  15389. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15390. var res ResultTwo
  15391. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15392. utils.ErrorLog("解析失败:%v", err)
  15393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15394. return
  15395. }
  15396. if res.Infcode == 0 {
  15397. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15398. if err == gorm.ErrRecordNotFound {
  15399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15400. return
  15401. } else if err != nil {
  15402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15403. return
  15404. } else {
  15405. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15406. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15407. infoStr := string(Iinfos)
  15408. idetinfoStr := string(Idetinfos)
  15409. psn := &models.HisPsn{
  15410. PsnNo: res.Output.Baseinfo.PsnNo,
  15411. PatientId: patient.ID,
  15412. Certno: res.Output.Baseinfo.Certno,
  15413. Gend: res.Output.Baseinfo.Gend,
  15414. Naty: res.Output.Baseinfo.Naty,
  15415. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15416. PsnName: res.Output.Baseinfo.PsnName,
  15417. Idetinfo: idetinfoStr,
  15418. Insuinfo: infoStr,
  15419. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15420. CardInfo: "",
  15421. Stage: "1",
  15422. VerifyNumber: token,
  15423. InsuplcAdmdvs: ele.Data.InsuOrg,
  15424. }
  15425. service.CreateHisPsn(psn)
  15426. var rf []*ResultFive
  15427. json.Unmarshal([]byte(infoStr), &rf)
  15428. var insutypes []*ResultFive
  15429. var insutype string
  15430. var is390 int = 0
  15431. var is310 int = 0
  15432. for _, item := range rf {
  15433. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15434. insutypes = append(insutypes, item)
  15435. }
  15436. }
  15437. if len(insutypes) == 1 {
  15438. insutype = insutypes[0].Insutype
  15439. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15440. } else {
  15441. for _, i := range insutypes {
  15442. if i.Insutype == "390" {
  15443. is390 = 1
  15444. }
  15445. if i.Insutype == "310" {
  15446. is310 = 1
  15447. }
  15448. }
  15449. }
  15450. if is390 == 1 {
  15451. insutype = "390"
  15452. }
  15453. if is310 == 1 {
  15454. insutype = "310"
  15455. }
  15456. if len(insutypes) == 0 {
  15457. insutype = "310"
  15458. }
  15459. c.ServeSuccessJSON(map[string]interface{}{
  15460. "patient": patient,
  15461. "number": token,
  15462. "insutype": insutype,
  15463. })
  15464. }
  15465. } else {
  15466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15467. return
  15468. }
  15469. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15470. //if initFlag == 0 {
  15471. //c.TestGetJiangXiBasBaseInit()
  15472. //}
  15473. //if initEleFlag == 0 {
  15474. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15475. //}
  15476. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15477. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15478. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15479. type ELeData struct {
  15480. Data struct {
  15481. IdNo string `json:"idNo"`
  15482. IdType string `json:"idType"`
  15483. UserName string `json:"userName"`
  15484. EcToken string `json:"ecToken"`
  15485. InsuOrg string `json:"insuOrg"`
  15486. Gender string `json:"gender"`
  15487. Birthday string `json:"birthday"`
  15488. Nationality string `json:"nationality"`
  15489. Email string `json:"email"`
  15490. Extra string `json:"extra"`
  15491. } `json:"data"`
  15492. Code int `json:"code"`
  15493. Message string `json:"message"`
  15494. }
  15495. var ele ELeData
  15496. err := json.Unmarshal([]byte(result), &ele)
  15497. if err != nil {
  15498. utils.ErrorLog("解析失败:%v", err)
  15499. }
  15500. token := ele.Data.EcToken
  15501. token = Remove0000(token)
  15502. 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)
  15503. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15504. var res ResultTwo
  15505. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15506. utils.ErrorLog("解析失败:%v", err)
  15507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15508. return
  15509. }
  15510. if res.Infcode == 0 {
  15511. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15512. if err == gorm.ErrRecordNotFound {
  15513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15514. return
  15515. } else if err != nil {
  15516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15517. return
  15518. } else {
  15519. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15520. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15521. infoStr := string(Iinfos)
  15522. idetinfoStr := string(Idetinfos)
  15523. psn := &models.HisPsn{
  15524. PsnNo: res.Output.Baseinfo.PsnNo,
  15525. PatientId: patient.ID,
  15526. Certno: res.Output.Baseinfo.Certno,
  15527. Gend: res.Output.Baseinfo.Gend,
  15528. Naty: res.Output.Baseinfo.Naty,
  15529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15530. PsnName: res.Output.Baseinfo.PsnName,
  15531. Idetinfo: idetinfoStr,
  15532. Insuinfo: infoStr,
  15533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15534. CardInfo: "",
  15535. VerifyNumber: token,
  15536. InsuplcAdmdvs: ele.Data.InsuOrg,
  15537. }
  15538. service.CreateHisPsn(psn)
  15539. var rf []*ResultFive
  15540. json.Unmarshal([]byte(infoStr), &rf)
  15541. var insutypes []*ResultFive
  15542. var insutype string
  15543. var is390 int = 0
  15544. var is310 int = 0
  15545. for _, item := range rf {
  15546. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15547. insutypes = append(insutypes, item)
  15548. }
  15549. }
  15550. if len(insutypes) == 1 {
  15551. insutype = insutypes[0].Insutype
  15552. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15553. } else {
  15554. for _, i := range insutypes {
  15555. if i.Insutype == "390" {
  15556. is390 = 1
  15557. }
  15558. if i.Insutype == "310" {
  15559. is310 = 1
  15560. }
  15561. }
  15562. }
  15563. if is390 == 1 {
  15564. insutype = "390"
  15565. }
  15566. if is310 == 1 {
  15567. insutype = "310"
  15568. }
  15569. if len(insutypes) == 0 {
  15570. insutype = "310"
  15571. }
  15572. c.ServeSuccessJSON(map[string]interface{}{
  15573. "patient": patient,
  15574. "number": token,
  15575. "insutype": insutype,
  15576. })
  15577. }
  15578. } else {
  15579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15580. return
  15581. }
  15582. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15583. //if initFlag == 0 {
  15584. //c.TestGetJiangXiBasBaseInit()
  15585. //}
  15586. //if initEleFlag == 0 {
  15587. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15588. //}
  15589. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15590. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15591. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15592. type ELeData struct {
  15593. Data struct {
  15594. IdNo string `json:"idNo"`
  15595. IdType string `json:"idType"`
  15596. UserName string `json:"userName"`
  15597. EcToken string `json:"ecToken"`
  15598. InsuOrg string `json:"insuOrg"`
  15599. Gender string `json:"gender"`
  15600. Birthday string `json:"birthday"`
  15601. Nationality string `json:"nationality"`
  15602. Email string `json:"email"`
  15603. Extra string `json:"extra"`
  15604. } `json:"data"`
  15605. Code int `json:"code"`
  15606. Message string `json:"message"`
  15607. }
  15608. var ele ELeData
  15609. err := json.Unmarshal([]byte(result), &ele)
  15610. if err != nil {
  15611. utils.ErrorLog("解析失败:%v", err)
  15612. }
  15613. token := ele.Data.EcToken
  15614. token = Remove0000(token)
  15615. 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)
  15616. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15617. var res ResultTwo
  15618. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15619. utils.ErrorLog("解析失败:%v", err)
  15620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15621. return
  15622. }
  15623. if res.Infcode == 0 {
  15624. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15625. if err == gorm.ErrRecordNotFound {
  15626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15627. return
  15628. } else if err != nil {
  15629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15630. return
  15631. } else {
  15632. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15633. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15634. infoStr := string(Iinfos)
  15635. idetinfoStr := string(Idetinfos)
  15636. psn := &models.HisPsn{
  15637. PsnNo: res.Output.Baseinfo.PsnNo,
  15638. PatientId: patient.ID,
  15639. Certno: res.Output.Baseinfo.Certno,
  15640. Gend: res.Output.Baseinfo.Gend,
  15641. Naty: res.Output.Baseinfo.Naty,
  15642. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15643. PsnName: res.Output.Baseinfo.PsnName,
  15644. Idetinfo: idetinfoStr,
  15645. Insuinfo: infoStr,
  15646. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15647. CardInfo: "",
  15648. VerifyNumber: token,
  15649. InsuplcAdmdvs: ele.Data.InsuOrg,
  15650. }
  15651. service.CreateHisPsn(psn)
  15652. var rf []*ResultFive
  15653. json.Unmarshal([]byte(infoStr), &rf)
  15654. var insutypes []*ResultFive
  15655. var insutype string
  15656. var is390 int = 0
  15657. var is310 int = 0
  15658. for _, item := range rf {
  15659. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15660. insutypes = append(insutypes, item)
  15661. }
  15662. }
  15663. if len(insutypes) == 1 {
  15664. insutype = insutypes[0].Insutype
  15665. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15666. } else {
  15667. for _, i := range insutypes {
  15668. if i.Insutype == "390" {
  15669. is390 = 1
  15670. }
  15671. if i.Insutype == "310" {
  15672. is310 = 1
  15673. }
  15674. }
  15675. }
  15676. if is390 == 1 {
  15677. insutype = "390"
  15678. }
  15679. if is310 == 1 {
  15680. insutype = "310"
  15681. }
  15682. if len(insutypes) == 0 {
  15683. insutype = "310"
  15684. }
  15685. c.ServeSuccessJSON(map[string]interface{}{
  15686. "patient": patient,
  15687. "number": token,
  15688. "insutype": insutype,
  15689. })
  15690. }
  15691. } else {
  15692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15693. return
  15694. }
  15695. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15696. //if initFlag == 0 {
  15697. c.TestGetJiangXiBasBaseInit()
  15698. //}
  15699. //if initEleFlag == 0 {
  15700. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15701. //}
  15702. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15703. type ELeData struct {
  15704. Data struct {
  15705. IdNo string `json:"idNo"`
  15706. IdType string `json:"idType"`
  15707. UserName string `json:"userName"`
  15708. EcToken string `json:"ecToken"`
  15709. InsuOrg string `json:"insuOrg"`
  15710. Gender string `json:"gender"`
  15711. Birthday string `json:"birthday"`
  15712. Nationality string `json:"nationality"`
  15713. Email string `json:"email"`
  15714. Extra string `json:"extra"`
  15715. } `json:"data"`
  15716. Code int `json:"code"`
  15717. Message string `json:"message"`
  15718. }
  15719. var ele ELeData
  15720. err := json.Unmarshal([]byte(json_result), &ele)
  15721. if err != nil {
  15722. utils.ErrorLog("解析失败:%v", err)
  15723. }
  15724. token := ele.Data.EcToken
  15725. token = Remove0000(token)
  15726. 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)
  15727. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15728. var res ResultTwo
  15729. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15730. utils.ErrorLog("解析失败:%v", err)
  15731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15732. return
  15733. }
  15734. if res.Infcode == 0 {
  15735. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15736. if err == gorm.ErrRecordNotFound {
  15737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15738. return
  15739. } else if err != nil {
  15740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15741. return
  15742. } else {
  15743. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15744. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15745. infoStr := string(Iinfos)
  15746. idetinfoStr := string(Idetinfos)
  15747. psn := &models.HisPsn{
  15748. PsnNo: res.Output.Baseinfo.PsnNo,
  15749. PatientId: patient.ID,
  15750. Certno: res.Output.Baseinfo.Certno,
  15751. Gend: res.Output.Baseinfo.Gend,
  15752. Naty: res.Output.Baseinfo.Naty,
  15753. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15754. PsnName: res.Output.Baseinfo.PsnName,
  15755. Idetinfo: idetinfoStr,
  15756. Insuinfo: infoStr,
  15757. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15758. CardInfo: "",
  15759. VerifyNumber: token,
  15760. }
  15761. service.CreateHisPsn(psn)
  15762. var rf []*ResultFive
  15763. json.Unmarshal([]byte(infoStr), &rf)
  15764. var insutypes []*ResultFive
  15765. var insutype string
  15766. var is390 int = 0
  15767. var is310 int = 0
  15768. for _, item := range rf {
  15769. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15770. insutypes = append(insutypes, item)
  15771. }
  15772. }
  15773. if len(insutypes) == 1 {
  15774. insutype = insutypes[0].Insutype
  15775. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15776. } else {
  15777. for _, i := range insutypes {
  15778. if i.Insutype == "390" {
  15779. is390 = 1
  15780. }
  15781. if i.Insutype == "310" {
  15782. is310 = 1
  15783. }
  15784. }
  15785. }
  15786. if is390 == 1 {
  15787. insutype = "390"
  15788. }
  15789. if is310 == 1 {
  15790. insutype = "310"
  15791. }
  15792. if len(insutypes) == 0 {
  15793. insutype = "310"
  15794. }
  15795. c.ServeSuccessJSON(map[string]interface{}{
  15796. "patient": patient,
  15797. "number": token,
  15798. "insutype": insutype,
  15799. })
  15800. }
  15801. } else {
  15802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15803. return
  15804. }
  15805. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15806. type ELeData struct {
  15807. Code string `json:"code"`
  15808. Data struct {
  15809. Aac002 string `json:"aac002"`
  15810. Aaz500 string `json:"aaz500"`
  15811. ActCardNo string `json:"actCardNo"`
  15812. Bab520 string `json:"bab520"`
  15813. Bkz543 string `json:"bkz543"`
  15814. BusinessType string `json:"businessType"`
  15815. CertfCodg string `json:"certfCodg"`
  15816. EcIndexNo string `json:"ecIndexNo"`
  15817. EcToken string `json:"ecToken"`
  15818. ID0000 string `json:"id0000"`
  15819. IDNo string `json:"idNo"`
  15820. IDType string `json:"idType"`
  15821. Idcode string `json:"idcode"`
  15822. IdentityToken string `json:"identity_token"`
  15823. InsuOrg string `json:"insuOrg"`
  15824. OfficeID string `json:"officeId"`
  15825. OfficeName string `json:"officeName"`
  15826. OperatorID string `json:"operatorId"`
  15827. OperatorName string `json:"operatorName"`
  15828. OrgID string `json:"orgId"`
  15829. UserName string `json:"userName"`
  15830. } `json:"data"`
  15831. Infno interface{} `json:"infno"`
  15832. Message string `json:"message"`
  15833. OrgID string `json:"orgId"`
  15834. TransType string `json:"transType"`
  15835. }
  15836. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  15837. outPutInfo = Remove0000(outPutInfo)
  15838. if len(outPutInfo) > 0 {
  15839. var ele ELeData
  15840. err := json.Unmarshal([]byte(outPutInfo), &ele)
  15841. if err != nil {
  15842. utils.ErrorLog("解析失败:%v", err)
  15843. }
  15844. token := ele.Data.EcToken
  15845. fmt.Println(inputInfo)
  15846. fmt.Println(outPutInfo)
  15847. 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)
  15848. saveLog(result, requestLog, "1101", "获取人员信息")
  15849. var dat map[string]interface{}
  15850. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15851. fmt.Println(dat)
  15852. } else {
  15853. fmt.Println(err)
  15854. }
  15855. userJSONBytes, _ := json.Marshal(dat)
  15856. var res ResultTwo
  15857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15858. utils.ErrorLog("解析失败:%v", err)
  15859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15860. return
  15861. }
  15862. res.ErrMsg = errMsgLog
  15863. if res.Infcode == 0 {
  15864. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15865. if err == gorm.ErrRecordNotFound {
  15866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15867. return
  15868. } else if err != nil {
  15869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15870. return
  15871. } else {
  15872. fmt.Println(res)
  15873. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15874. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15875. infoStr := string(Iinfos)
  15876. idetinfoStr := string(Idetinfos)
  15877. psn := &models.HisPsn{
  15878. PsnNo: res.Output.Baseinfo.PsnNo,
  15879. PatientId: patient.ID,
  15880. Certno: res.Output.Baseinfo.Certno,
  15881. Gend: res.Output.Baseinfo.Gend,
  15882. Naty: res.Output.Baseinfo.Naty,
  15883. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15884. PsnName: res.Output.Baseinfo.PsnName,
  15885. Idetinfo: idetinfoStr,
  15886. Insuinfo: infoStr,
  15887. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15888. CardInfo: outPutInfo,
  15889. VerifyNumber: token,
  15890. InsuplcAdmdvs: ele.Data.InsuOrg,
  15891. }
  15892. service.CreateHisPsn(psn)
  15893. var rf []*ResultFive
  15894. json.Unmarshal([]byte(infoStr), &rf)
  15895. var insutypes []*ResultFive
  15896. var insutype string
  15897. var is390 int = 0
  15898. var is310 int = 0
  15899. for _, item := range rf {
  15900. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15901. insutypes = append(insutypes, item)
  15902. }
  15903. }
  15904. if len(insutypes) == 1 {
  15905. insutype = insutypes[0].Insutype
  15906. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15907. } else {
  15908. for _, i := range insutypes {
  15909. if i.Insutype == "390" {
  15910. is390 = 1
  15911. }
  15912. if i.Insutype == "310" {
  15913. is310 = 1
  15914. }
  15915. }
  15916. }
  15917. if is390 == 1 {
  15918. insutype = "390"
  15919. }
  15920. if is310 == 1 {
  15921. insutype = "310"
  15922. }
  15923. if len(insutypes) == 0 {
  15924. insutype = "310"
  15925. }
  15926. c.ServeSuccessJSON(map[string]interface{}{
  15927. "patient": patient,
  15928. "number": token,
  15929. "insutype": insutype,
  15930. })
  15931. }
  15932. } else {
  15933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15934. return
  15935. }
  15936. }
  15937. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15938. var api string
  15939. 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 +
  15940. "&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
  15941. resp, requestErr := http.Get(api)
  15942. if requestErr != nil {
  15943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15944. return
  15945. }
  15946. body, ioErr := ioutil.ReadAll(resp.Body)
  15947. if ioErr != nil {
  15948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15950. return
  15951. }
  15952. var respJSON map[string]interface{}
  15953. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15956. return
  15957. }
  15958. var status string
  15959. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15960. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15961. var token string
  15962. var res ResultTwo //1101结果
  15963. var res10265 ResultTwo10265 //1101结果
  15964. if status == "0" { //读卡成功
  15965. var card_info string //卡信息
  15966. var busi_card_info string
  15967. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15968. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15969. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15970. fmt.Println(card_info)
  15971. fmt.Println(busi_card_info)
  15972. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15973. result, _ := json.Marshal(respJSON)
  15974. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15975. utils.ErrorLog("解析失败:%v", err)
  15976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15977. return
  15978. }
  15979. res.ErrMsg = res10265.ErrMsg
  15980. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15981. res.Infcode = infocode
  15982. res.Output = res10265.Output
  15983. res.InfRefmsgid = res10265.InfRefmsgid
  15984. if res.Infcode == 0 {
  15985. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15986. if err == gorm.ErrRecordNotFound {
  15987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15988. return
  15989. } else if err != nil {
  15990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15991. return
  15992. } else {
  15993. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15994. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15995. infoStr := string(Iinfos)
  15996. idetinfoStr := string(Idetinfos)
  15997. psn := &models.HisPsn{
  15998. PsnNo: res.Output.Baseinfo.PsnNo,
  15999. PatientId: patient.ID,
  16000. Certno: res.Output.Baseinfo.Certno,
  16001. Gend: res.Output.Baseinfo.Gend,
  16002. Naty: res.Output.Baseinfo.Naty,
  16003. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16004. PsnName: res.Output.Baseinfo.PsnName,
  16005. Idetinfo: idetinfoStr,
  16006. Insuinfo: infoStr,
  16007. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16008. CardInfo: card_info,
  16009. VerifyNumber: token,
  16010. }
  16011. var rf []*ResultFive
  16012. json.Unmarshal([]byte(infoStr), &rf)
  16013. var insutypes []*ResultFive
  16014. var insutype string
  16015. var is390 int = 0
  16016. var is310 int = 0
  16017. for _, item := range rf {
  16018. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16019. insutypes = append(insutypes, item)
  16020. }
  16021. }
  16022. if len(insutypes) == 1 {
  16023. insutype = insutypes[0].Insutype
  16024. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16025. } else {
  16026. for _, i := range insutypes {
  16027. if i.Insutype == "390" {
  16028. is390 = 1
  16029. }
  16030. if i.Insutype == "310" {
  16031. is310 = 1
  16032. }
  16033. }
  16034. }
  16035. if is390 == 1 {
  16036. insutype = "390"
  16037. }
  16038. if is310 == 1 {
  16039. insutype = "310"
  16040. }
  16041. if len(insutypes) == 0 {
  16042. insutype = "310"
  16043. }
  16044. service.CreateHisPsn(psn)
  16045. c.ServeSuccessJSON(map[string]interface{}{
  16046. "patient": patient,
  16047. "number": token,
  16048. "insutype": insutype,
  16049. })
  16050. }
  16051. } else {
  16052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16053. return
  16054. }
  16055. } else { //读卡失败
  16056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16057. return
  16058. }
  16059. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16060. res := c.GetoleInfo()
  16061. if res.Infcode == 0 {
  16062. var result string
  16063. if res.Output.MdtrtCertType == "01" {
  16064. 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)
  16065. } else if res.Output.MdtrtCertType == "02" {
  16066. 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)
  16067. } else if res.Output.MdtrtCertType == "03" {
  16068. 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)
  16069. }
  16070. var dat map[string]interface{}
  16071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16072. fmt.Println(dat)
  16073. } else {
  16074. fmt.Println(err)
  16075. }
  16076. userJSONBytes, _ := json.Marshal(dat)
  16077. var res2 ResultTwo
  16078. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16079. utils.ErrorLog("解析失败:%v", err)
  16080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16081. return
  16082. }
  16083. if res2.Infcode == 0 {
  16084. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16085. if err == gorm.ErrRecordNotFound {
  16086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16087. return
  16088. } else if err != nil {
  16089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16090. return
  16091. } else {
  16092. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16093. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16094. infoStr := string(Iinfos)
  16095. idetinfoStr := string(Idetinfos)
  16096. var rf []*ResultFive
  16097. json.Unmarshal([]byte(infoStr), &rf)
  16098. var insutypes []*ResultFive
  16099. var insutype string
  16100. var is390 int = 0
  16101. var is310 int = 0
  16102. //var insuplc_admdvs string
  16103. for _, item := range rf {
  16104. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16105. insutypes = append(insutypes, item)
  16106. }
  16107. }
  16108. if len(insutypes) == 1 {
  16109. insutype = insutypes[0].Insutype
  16110. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16111. } else {
  16112. for _, i := range insutypes {
  16113. if i.Insutype == "390" {
  16114. is390 = 1
  16115. }
  16116. if i.Insutype == "310" {
  16117. is310 = 1
  16118. }
  16119. }
  16120. }
  16121. if is390 == 1 {
  16122. insutype = "390"
  16123. }
  16124. if is310 == 1 {
  16125. insutype = "310"
  16126. }
  16127. if len(insutypes) == 0 {
  16128. insutype = "310"
  16129. }
  16130. psn := &models.HisPsn{
  16131. PsnNo: res2.Output.Baseinfo.PsnNo,
  16132. PatientId: patient.ID,
  16133. Certno: res2.Output.Baseinfo.Certno,
  16134. Gend: res2.Output.Baseinfo.Gend,
  16135. Naty: res2.Output.Baseinfo.Naty,
  16136. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16137. PsnName: res2.Output.Baseinfo.PsnName,
  16138. Idetinfo: idetinfoStr,
  16139. Insuinfo: infoStr,
  16140. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16141. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16142. VerifyNumber: res.Output.EcToken,
  16143. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16144. }
  16145. if res.Output.MdtrtCertType == "01" {
  16146. psn.VerifyNumber = res.Output.EcToken
  16147. //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)
  16148. } else if res.Output.MdtrtCertType == "02" {
  16149. psn.VerifyNumber = res.Output.CardNo
  16150. //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)
  16151. } else if res.Output.MdtrtCertType == "03" {
  16152. psn.VerifyNumber = res.Output.MdtrtCertNo
  16153. //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)
  16154. }
  16155. service.CreateHisPsn(psn)
  16156. var balc float64
  16157. for _, item := range rf {
  16158. if item.Insutype == insutype {
  16159. balc = item.Balc
  16160. }
  16161. }
  16162. c.ServeSuccessJSON(map[string]interface{}{
  16163. "patient": patient,
  16164. "number": res.Output.CardNo,
  16165. "insutype": insutype,
  16166. "blac": balc,
  16167. "desc": idetinfoStr,
  16168. })
  16169. }
  16170. } else {
  16171. c.ServeSuccessJSON(map[string]interface{}{
  16172. "failed_code": -10,
  16173. "msg": res2.ErrMsg,
  16174. })
  16175. }
  16176. } else {
  16177. c.ServeSuccessJSON(map[string]interface{}{
  16178. "failed_code": -10,
  16179. "msg": res.ErrMsg,
  16180. })
  16181. }
  16182. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16183. var res ResultTwo
  16184. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16185. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16186. "&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)
  16187. resp, requestErr := http.Get(api)
  16188. if requestErr != nil {
  16189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16190. return
  16191. }
  16192. body, ioErr := ioutil.ReadAll(resp.Body)
  16193. if ioErr != nil {
  16194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16196. return
  16197. }
  16198. var respJSON map[string]interface{}
  16199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16202. return
  16203. }
  16204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16205. result, _ := json.Marshal(respJSON)
  16206. fmt.Println("log")
  16207. fmt.Println(string(result))
  16208. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16209. utils.ErrorLog("解析失败:%v", err)
  16210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16211. return
  16212. }
  16213. if res.Infcode == 0 {
  16214. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16215. if err == gorm.ErrRecordNotFound {
  16216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16217. return
  16218. } else if err != nil {
  16219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16220. return
  16221. } else {
  16222. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16223. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16224. infoStr := string(Iinfos)
  16225. idetinfoStr := string(Idetinfos)
  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 = "390"
  16258. }
  16259. var insuplc_admdvs string
  16260. for _, item := range rf {
  16261. if item.Insutype == insutype {
  16262. insuplc_admdvs = item.InsuplcAdmdvs
  16263. }
  16264. }
  16265. psn := &models.HisPsn{
  16266. PsnNo: res.Output.Baseinfo.PsnNo,
  16267. PatientId: patient.ID,
  16268. Certno: res.Output.Baseinfo.Certno,
  16269. Gend: res.Output.Baseinfo.Gend,
  16270. Naty: res.Output.Baseinfo.Naty,
  16271. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16272. PsnName: res.Output.Baseinfo.PsnName,
  16273. Idetinfo: idetinfoStr,
  16274. Insuinfo: infoStr,
  16275. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16276. InsuplcAdmdvs: insuplc_admdvs,
  16277. }
  16278. service.CreateHisPsn(psn)
  16279. c.ServeSuccessJSON(map[string]interface{}{
  16280. "patient": patient,
  16281. "number": res.Output.Baseinfo.Certno,
  16282. })
  16283. }
  16284. } else {
  16285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16286. return
  16287. }
  16288. } else {
  16289. type ELeData struct {
  16290. Code string `json:"code"`
  16291. Data struct {
  16292. Aac002 string `json:"aac002"`
  16293. Aaz500 string `json:"aaz500"`
  16294. ActCardNo string `json:"actCardNo"`
  16295. Bab520 string `json:"bab520"`
  16296. Bkz543 string `json:"bkz543"`
  16297. BusinessType string `json:"businessType"`
  16298. CertfCodg string `json:"certfCodg"`
  16299. EcIndexNo string `json:"ecIndexNo"`
  16300. EcToken string `json:"ecToken"`
  16301. ID0000 string `json:"id0000"`
  16302. IDNo string `json:"idNo"`
  16303. IDType string `json:"idType"`
  16304. Idcode string `json:"idcode"`
  16305. IdentityToken string `json:"identity_token"`
  16306. InsuOrg string `json:"insuOrg"`
  16307. OfficeID string `json:"officeId"`
  16308. OfficeName string `json:"officeName"`
  16309. OperatorID string `json:"operatorId"`
  16310. OperatorName string `json:"operatorName"`
  16311. OrgID string `json:"orgId"`
  16312. UserName string `json:"userName"`
  16313. } `json:"data"`
  16314. Infno interface{} `json:"infno"`
  16315. Message string `json:"message"`
  16316. OrgID string `json:"orgId"`
  16317. TransType string `json:"transType"`
  16318. }
  16319. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16320. fmt.Println(result)
  16321. outPutInfo := Remove0000(result)
  16322. fmt.Println(outPutInfo)
  16323. if len(outPutInfo) > 0 {
  16324. var ele ELeData
  16325. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16326. if err != nil {
  16327. utils.ErrorLog("解析失败:%v", err)
  16328. }
  16329. token := ele.Data.EcToken
  16330. fmt.Println(outPutInfo)
  16331. 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)
  16332. saveLog(result, requestLog, "1101", "获取人员信息")
  16333. var dat map[string]interface{}
  16334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16335. fmt.Println(dat)
  16336. } else {
  16337. fmt.Println(err)
  16338. }
  16339. userJSONBytes, _ := json.Marshal(dat)
  16340. var res ResultTwo
  16341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16342. utils.ErrorLog("解析失败:%v", err)
  16343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16344. return
  16345. }
  16346. if res.Infcode == 0 {
  16347. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16348. if err == gorm.ErrRecordNotFound {
  16349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16350. return
  16351. } else if err != nil {
  16352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16353. return
  16354. } else {
  16355. fmt.Println(res)
  16356. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16357. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16358. infoStr := string(Iinfos)
  16359. idetinfoStr := string(Idetinfos)
  16360. psn := &models.HisPsn{
  16361. PsnNo: res.Output.Baseinfo.PsnNo,
  16362. PatientId: patient.ID,
  16363. Certno: res.Output.Baseinfo.Certno,
  16364. Gend: res.Output.Baseinfo.Gend,
  16365. Naty: res.Output.Baseinfo.Naty,
  16366. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16367. PsnName: res.Output.Baseinfo.PsnName,
  16368. Idetinfo: idetinfoStr,
  16369. Insuinfo: infoStr,
  16370. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16371. CardInfo: outPutInfo,
  16372. VerifyNumber: token,
  16373. InsuplcAdmdvs: ele.Data.InsuOrg,
  16374. }
  16375. service.CreateHisPsn(psn)
  16376. var rf []*ResultFive
  16377. json.Unmarshal([]byte(infoStr), &rf)
  16378. var insutypes []*ResultFive
  16379. var insutype string
  16380. var is390 int = 0
  16381. var is310 int = 0
  16382. for _, item := range rf {
  16383. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16384. insutypes = append(insutypes, item)
  16385. }
  16386. }
  16387. if len(insutypes) == 1 {
  16388. insutype = insutypes[0].Insutype
  16389. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16390. } else {
  16391. for _, i := range insutypes {
  16392. if i.Insutype == "390" {
  16393. is390 = 1
  16394. }
  16395. if i.Insutype == "310" {
  16396. is310 = 1
  16397. }
  16398. }
  16399. }
  16400. if is390 == 1 {
  16401. insutype = "390"
  16402. }
  16403. if is310 == 1 {
  16404. insutype = "310"
  16405. }
  16406. if len(insutypes) == 0 {
  16407. insutype = "310"
  16408. }
  16409. c.ServeSuccessJSON(map[string]interface{}{
  16410. "patient": patient,
  16411. "number": token,
  16412. "insutype": insutype,
  16413. })
  16414. }
  16415. } else {
  16416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16417. return
  16418. }
  16419. }
  16420. //fmt.Println(result)
  16421. //
  16422. //if initFlag == 0 {
  16423. // c.TestGetBasBaseInit()
  16424. //}
  16425. //token := c.GetEleBaseInfo()
  16426. //
  16427. //token = Remove0000(token)
  16428. //
  16429. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16430. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16431. ////
  16432. //var res ResultTwo
  16433. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16434. // utils.ErrorLog("解析失败:%v", err)
  16435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16436. // return
  16437. //}
  16438. //
  16439. //if res.Infcode == 0 {
  16440. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16441. // if err == gorm.ErrRecordNotFound {
  16442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16443. // return
  16444. // } else if err != nil {
  16445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16446. // return
  16447. //
  16448. // } else {
  16449. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16450. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16451. // infoStr := string(Iinfos)
  16452. // idetinfoStr := string(Idetinfos)
  16453. //
  16454. //
  16455. //
  16456. //
  16457. // var rf []*ResultFive
  16458. // json.Unmarshal([]byte(infoStr), &rf)
  16459. //
  16460. // var insutypes []*ResultFive
  16461. // var insutype string
  16462. // var is390 int = 0
  16463. // var is310 int = 0
  16464. // var insuplc_admdvs string
  16465. //
  16466. // for _, item := range rf {
  16467. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16468. // insutypes = append(insutypes, item)
  16469. // }
  16470. // }
  16471. //
  16472. // if len(insutypes) == 1 {
  16473. // insutype = insutypes[0].Insutype
  16474. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16475. // } else {
  16476. // for _, i := range insutypes {
  16477. // if i.Insutype == "390" {
  16478. // is390 = 1
  16479. // }
  16480. //
  16481. // if i.Insutype == "310" {
  16482. // is310 = 1
  16483. // }
  16484. // }
  16485. // }
  16486. // if is390 == 1 {
  16487. // insutype = "390"
  16488. // }
  16489. //
  16490. // if is310 == 1 {
  16491. // insutype = "310"
  16492. // }
  16493. // if len(insutypes) == 0 {
  16494. // insutype = "310"
  16495. // }
  16496. // for _, item := range rf {
  16497. // if item.Insutype == insutype {
  16498. // insuplc_admdvs = item.InsuplcAdmdvs
  16499. // }
  16500. // }
  16501. // psn := &models.HisPsn{
  16502. // PsnNo: res.Output.Baseinfo.PsnNo,
  16503. // Age: res.Output.Baseinfo.Age,
  16504. // PatientId: patient.ID,
  16505. // Certno: res.Output.Baseinfo.Certno,
  16506. // Brdy: res.Output.Baseinfo.Brdy,
  16507. // Gend: res.Output.Baseinfo.Gend,
  16508. // Naty: res.Output.Baseinfo.Naty,
  16509. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16510. // PsnName: res.Output.Baseinfo.PsnName,
  16511. // Idetinfo: idetinfoStr,
  16512. // Insuinfo: infoStr,
  16513. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16514. // CardInfo: "",
  16515. // VerifyNumber: token,
  16516. // InsuplcAdmdvs: insuplc_admdvs,
  16517. // }
  16518. // service.CreateHisPsn(psn)
  16519. //
  16520. // c.ServeSuccessJSON(map[string]interface{}{
  16521. // "patient": patient,
  16522. // "number": token,
  16523. // })
  16524. // }
  16525. //} else {
  16526. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16527. // return
  16528. //}
  16529. }
  16530. break
  16531. case 5:
  16532. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16533. var api string
  16534. if miConfig.MdtrtareaAdmvs == "320921" {
  16535. 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 +
  16536. "&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
  16537. fmt.Println(api)
  16538. } else {
  16539. 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 +
  16540. "&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)
  16541. }
  16542. resp, requestErr := http.Get(api)
  16543. if requestErr != nil {
  16544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16545. return
  16546. }
  16547. body, ioErr := ioutil.ReadAll(resp.Body)
  16548. if ioErr != nil {
  16549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16551. return
  16552. }
  16553. var respJSON map[string]interface{}
  16554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16557. return
  16558. }
  16559. var status string
  16560. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16561. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16562. var token string
  16563. var res ResultTwo //1101结果
  16564. var res10265 ResultTwo10265 //1101结果
  16565. if status == "0" { //读卡成功
  16566. var card_info string //卡信息
  16567. //var busi_card_info string
  16568. var auth_info string
  16569. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16570. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16571. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16572. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16573. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16574. result, _ := json.Marshal(respJSON)
  16575. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16576. utils.ErrorLog("解析失败:%v", err)
  16577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16578. return
  16579. }
  16580. res.ErrMsg = res10265.ErrMsg
  16581. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16582. res.Infcode = infocode
  16583. res.Output = res10265.Output
  16584. res.InfRefmsgid = res10265.InfRefmsgid
  16585. if res.Infcode == 0 {
  16586. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16587. if err == gorm.ErrRecordNotFound {
  16588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16589. return
  16590. } else if err != nil {
  16591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16592. return
  16593. } else {
  16594. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16595. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16596. infoStr := string(Iinfos)
  16597. idetinfoStr := string(Idetinfos)
  16598. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16599. psn := &models.HisPsn{
  16600. PsnNo: res.Output.Baseinfo.PsnNo,
  16601. PatientId: patient.ID,
  16602. Certno: res.Output.Baseinfo.Certno,
  16603. Gend: res.Output.Baseinfo.Gend,
  16604. Brdy: b,
  16605. Age: float64(age),
  16606. Naty: res.Output.Baseinfo.Naty,
  16607. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16608. PsnName: res.Output.Baseinfo.PsnName,
  16609. Idetinfo: idetinfoStr,
  16610. Insuinfo: infoStr,
  16611. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16612. CardInfo: card_info,
  16613. VerifyNumber: token,
  16614. AuthInfo: auth_info,
  16615. }
  16616. var rf []*ResultFive
  16617. json.Unmarshal([]byte(infoStr), &rf)
  16618. var insutypes []*ResultFive
  16619. var insutype string
  16620. var is390 int = 0
  16621. var is310 int = 0
  16622. for _, item := range rf {
  16623. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16624. insutypes = append(insutypes, item)
  16625. }
  16626. }
  16627. if len(insutypes) == 1 {
  16628. insutype = insutypes[0].Insutype
  16629. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16630. } else {
  16631. for _, i := range insutypes {
  16632. if i.Insutype == "390" {
  16633. is390 = 1
  16634. }
  16635. if i.Insutype == "310" {
  16636. is310 = 1
  16637. }
  16638. }
  16639. }
  16640. if is390 == 1 {
  16641. insutype = "390"
  16642. }
  16643. if is310 == 1 {
  16644. insutype = "310"
  16645. }
  16646. if len(insutypes) == 0 {
  16647. insutype = "310"
  16648. }
  16649. service.CreateHisPsn(psn)
  16650. c.ServeSuccessJSON(map[string]interface{}{
  16651. "patient": patient,
  16652. "number": token,
  16653. "insutype": insutype,
  16654. })
  16655. }
  16656. } else {
  16657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16658. return
  16659. }
  16660. } else { //读卡失败
  16661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16662. return
  16663. }
  16664. }
  16665. break
  16666. }
  16667. }
  16668. var initFlag int64 = 0
  16669. var initEleFlag int64 = 0
  16670. func (c *HisApiController) TestGetBasBaseInit() {
  16671. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16672. Iinit := DllDef.MustFindProc("Init")
  16673. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16674. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16675. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16676. if ret != 0 {
  16677. fmt.Println("SSCard的报错原因:", err)
  16678. fmt.Println("SSCard的运算结果为:", ret)
  16679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16680. return
  16681. }
  16682. result := int(ret)
  16683. fmt.Println("SSCard的运算结果为1:", result)
  16684. initFlag = 1
  16685. return
  16686. }
  16687. func (c *HisApiController) HandleJiangXiReadCard() {
  16688. fmt.Println("~~~~~~")
  16689. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16690. admin_user_id, _ := c.GetInt64("admin_user_id")
  16691. id_card_type, _ := c.GetInt64("id_card_type")
  16692. //certificates, _ := c.GetInt64("certificates")
  16693. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16694. if initFlag == 0 {
  16695. c.TestGetJiangXiBasBaseInit()
  16696. }
  16697. basStr := c.GetBasBaseInfo()
  16698. if len(basStr) == 0 {
  16699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16700. return
  16701. }
  16702. fmt.Println(basStr)
  16703. bas := strings.Split(basStr, "|")
  16704. basNumber := bas[1]
  16705. fmt.Println(basNumber)
  16706. card_sn := bas[3]
  16707. fmt.Println(card_sn)
  16708. 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, "")
  16709. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16710. var dat map[string]interface{}
  16711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16712. fmt.Println(dat)
  16713. } else {
  16714. fmt.Println(err)
  16715. }
  16716. userJSONBytes, _ := json.Marshal(dat)
  16717. var res ResultTwo
  16718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16719. utils.ErrorLog("解析失败:%v", err)
  16720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16721. return
  16722. }
  16723. if res.Infcode == 0 {
  16724. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16725. if err == gorm.ErrRecordNotFound {
  16726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16727. return
  16728. } else if err != nil {
  16729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16730. return
  16731. } else {
  16732. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16733. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16734. infoStr := string(Iinfos)
  16735. idetinfoStr := string(Idetinfos)
  16736. psn := &models.HisPsn{
  16737. PsnNo: res.Output.Baseinfo.PsnNo,
  16738. PatientId: patient.ID,
  16739. Certno: res.Output.Baseinfo.Certno,
  16740. Gend: res.Output.Baseinfo.Gend,
  16741. Naty: res.Output.Baseinfo.Naty,
  16742. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16743. PsnName: res.Output.Baseinfo.PsnName,
  16744. Idetinfo: idetinfoStr,
  16745. Insuinfo: infoStr,
  16746. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16747. CardInfo: basStr,
  16748. VerifyNumber: "",
  16749. }
  16750. service.CreateHisPsn(psn)
  16751. c.ServeSuccessJSON(map[string]interface{}{
  16752. "patient": patient,
  16753. "number": basNumber,
  16754. })
  16755. }
  16756. } else {
  16757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16758. return
  16759. }
  16760. }
  16761. func (c *HisApiController) TestGetHnBasBaseInit() {
  16762. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16763. Iinit := DllDef.MustFindProc("Init")
  16764. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16765. //http://10.77.211.236/CSB/hsa-fsi-1303
  16766. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  16767. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  16768. // 调用 Init 函数
  16769. 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"))))
  16770. //if ret != 0 {
  16771. fmt.Println("SSCard的报错原因:", err)
  16772. fmt.Println("SSCard的运算结果为:", ret)
  16773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16774. // return
  16775. //}
  16776. result := int(ret)
  16777. fmt.Println("SSCard的运算结果为1:", result)
  16778. initFlag = 1
  16779. return
  16780. }
  16781. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  16782. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16783. Iinit := DllDef.MustFindProc("Init")
  16784. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16785. //http://10.77.211.236/CSB/hsa-fsi-1303
  16786. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  16787. if ret != 0 {
  16788. fmt.Println("SSCard的报错原因:", err)
  16789. fmt.Println("SSCard的运算结果为:", ret)
  16790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16791. return
  16792. }
  16793. result := int(ret)
  16794. fmt.Println("SSCard的运算结果为1:", result)
  16795. initFlag = 1
  16796. return
  16797. }
  16798. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  16799. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16800. Iinit := DllDef.MustFindProc("Init")
  16801. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16802. //http://10.77.211.236/CSB/hsa-fsi-1303
  16803. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  16804. if ret != 0 {
  16805. fmt.Println("SSCard的报错原因:", err)
  16806. fmt.Println("SSCard的运算结果为:", ret)
  16807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16808. return
  16809. }
  16810. result := int(ret)
  16811. fmt.Println("SSCard的运算结果为1:", result)
  16812. initFlag = 1
  16813. return
  16814. }
  16815. func (c *HisApiController) GetSFZBaseInfo() string {
  16816. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16817. readCard := DllDef.MustFindProc("ReadSFZ")
  16818. if readCard == nil {
  16819. fmt.Println("readcard is nil")
  16820. readCard = DllDef.MustFindProc("ReadSFZ")
  16821. }
  16822. str := make([]byte, 8096)
  16823. str1 := make([]byte, 8096)
  16824. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  16825. fmt.Println(r)
  16826. return Remove0000(string(str))
  16827. }
  16828. func (c *HisApiController) GetEleBaseInfo() string {
  16829. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16830. readCard := DllDef.MustFindProc("GetQRBase")
  16831. fmt.Println(readCard)
  16832. if readCard == nil {
  16833. fmt.Println("readcard is nil")
  16834. readCard = DllDef.MustFindProc("GetQRBase")
  16835. }
  16836. str := make([]byte, 1024)
  16837. str1 := make([]byte, 1024)
  16838. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  16839. fmt.Println(ret2)
  16840. fmt.Println(string(str1))
  16841. fmt.Println(string(str))
  16842. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16843. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16844. if ret2 != 0 {
  16845. return ""
  16846. }
  16847. return string(str)
  16848. }
  16849. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16850. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16851. readCard := DllDef.MustFindProc("NationEcTrans")
  16852. fmt.Println(readCard)
  16853. fmt.Println("!!!!!")
  16854. pBusiCardInfo := make([]byte, 2048)
  16855. input := make(map[string]interface{})
  16856. inputData := make(map[string]interface{})
  16857. inputData["orgId"] = code
  16858. inputData["businessType"] = "01101"
  16859. inputData["operatorId"] = "1"
  16860. inputData["operatorName"] = "admin"
  16861. inputData["officeId"] = "001"
  16862. inputData["officeName"] = "血透室"
  16863. inputData["deviceType"] = ""
  16864. input["data"] = inputData
  16865. input["orgId"] = code
  16866. input["transType"] = "ec.query"
  16867. bytesData, _ := json.Marshal(input)
  16868. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16869. fmt.Println(ret2)
  16870. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16871. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16872. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  16873. }
  16874. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16875. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16876. readCard := DllDef.MustFindProc("NationEcTrans")
  16877. fmt.Println(readCard)
  16878. fmt.Println("!!!!!")
  16879. pBusiCardInfo := make([]byte, 2048)
  16880. input := make(map[string]interface{})
  16881. inputData := make(map[string]interface{})
  16882. inputData["orgId"] = code
  16883. inputData["businessType"] = "01101"
  16884. inputData["operatorId"] = "9"
  16885. inputData["operatorName"] = "admin"
  16886. inputData["officeId"] = "001"
  16887. inputData["officeName"] = "血透室"
  16888. inputData["deviceType"] = ""
  16889. input["data"] = inputData
  16890. input["orgId"] = code
  16891. input["transType"] = "ec.query"
  16892. bytesData, _ := json.Marshal(input)
  16893. 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])))
  16894. fmt.Println(ret2)
  16895. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16896. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16897. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16898. }
  16899. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  16900. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16901. readCard := DllDef.MustFindProc("NationEcTrans")
  16902. fmt.Println(readCard)
  16903. fmt.Println("!!!!!")
  16904. pBusiCardInfo := make([]byte, 2048)
  16905. input := make(map[string]interface{})
  16906. inputData := make(map[string]interface{})
  16907. inputData["orgId"] = code
  16908. inputData["businessType"] = "01301"
  16909. inputData["operatorId"] = "9"
  16910. inputData["operatorName"] = "admin"
  16911. inputData["officeId"] = "001"
  16912. inputData["officeName"] = "血透室"
  16913. inputData["deviceType"] = ""
  16914. input["data"] = inputData
  16915. input["orgId"] = code
  16916. input["transType"] = "ec.query"
  16917. bytesData, _ := json.Marshal(input)
  16918. 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])))
  16919. fmt.Println(ret2)
  16920. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16921. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16922. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16923. }
  16924. func GetJxEleBaseInfo(org_id int64) string {
  16925. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16926. readCard := DllDef.MustFindProc("NationEcTrans")
  16927. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16928. if readCard == nil {
  16929. fmt.Println("readcard is nil")
  16930. readCard = DllDef.MustFindProc("NationEcTrans")
  16931. }
  16932. str1 := make([]byte, 1024)
  16933. data := make(map[string]interface{})
  16934. inputData := make(map[string]interface{})
  16935. inputData["orgId"] = miConfig.Code
  16936. inputData["businessType"] = "01101"
  16937. inputData["operatorId"] = "test001"
  16938. inputData["operatorName"] = "cn"
  16939. inputData["officeId"] = "32760"
  16940. inputData["officeName"] = "waike"
  16941. inputData["deviceType"] = ""
  16942. data["data"] = inputData
  16943. data["transType"] = "ec.query"
  16944. data["extra "] = ""
  16945. data["orgId"] = miConfig.Code
  16946. bytesData, _ := json.Marshal(data)
  16947. //bytesData, _ := json.Marshal(data)
  16948. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16949. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16950. fmt.Println(ret2)
  16951. fmt.Println(string(str1))
  16952. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16953. if ret2 != 0 {
  16954. return ""
  16955. }
  16956. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16957. }
  16958. //func GetJxEleBaseInfoTWO(org_id int64) string {
  16959. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  16960. // readCard := DllDef.MustFindProc("NationEcTrans")
  16961. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16962. //
  16963. // if readCard == nil {
  16964. // fmt.Println("readcard is nil")
  16965. // readCard = DllDef.MustFindProc("NationEcTrans")
  16966. // }
  16967. // str1 := make([]byte, 1024)
  16968. //
  16969. // data := make(map[string]interface{})
  16970. //
  16971. // inputData := make(map[string]interface{})
  16972. // inputData["orgId"] = miConfig.Code
  16973. // inputData["businessType"] = "01101"
  16974. // inputData["operatorId"] = "test001"
  16975. // inputData["operatorName"] = "cn"
  16976. // inputData["officeId"] = "32760"
  16977. // inputData["officeName"] = "waike"
  16978. // inputData["deviceType"] = ""
  16979. //
  16980. // data["data"] = inputData
  16981. // data["transType"] = "ec.query"
  16982. // data["extra "] = ""
  16983. // data["orgId"] = miConfig.Code
  16984. // bytesData, _ := json.Marshal(data)
  16985. // //bytesData, _ := json.Marshal(data)
  16986. //
  16987. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16988. //
  16989. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16990. // fmt.Println(ret2)
  16991. // fmt.Println(string(str1))
  16992. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16993. //
  16994. // if ret2 != 0 {
  16995. // return ""
  16996. // }
  16997. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16998. //}
  16999. func GetJxEleBaseInitInfo(org_id int64) string {
  17000. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17001. readCard := DllDef.MustFindProc("NationEcTrans")
  17002. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17003. if readCard == nil {
  17004. fmt.Println("readcard is nil")
  17005. readCard = DllDef.MustFindProc("NationEcTrans")
  17006. }
  17007. str1 := make([]byte, 2048)
  17008. data := make(map[string]interface{})
  17009. inputData := make(map[string]interface{})
  17010. inputData["orgId"] = miConfig.Code
  17011. inputData["businessType"] = "01101"
  17012. inputData["operatorId"] = "1"
  17013. inputData["operatorName"] = "huangchuang"
  17014. inputData["officeId"] = "101"
  17015. inputData["officeName"] = "xuetou"
  17016. inputData["deviceType"] = ""
  17017. data["data"] = inputData
  17018. data["transType"] = "ec.query"
  17019. data["orgId"] = miConfig.Code
  17020. bytesData, _ := json.Marshal(data)
  17021. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17022. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17023. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17024. fmt.Println(ret2)
  17025. fmt.Println(string(str1))
  17026. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17027. if ret2 != 0 {
  17028. return ""
  17029. }
  17030. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17031. initEleFlag = 1
  17032. }
  17033. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17034. }
  17035. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17036. // // 构建命令
  17037. // cmd := exec.Command("python", "b.py")
  17038. //
  17039. // // 执行命令并等待完成
  17040. // output, err := cmd.CombinedOutput()
  17041. // if err != nil {
  17042. // fmt.Println("Error executing Python script:", err)
  17043. // return
  17044. // }
  17045. //
  17046. // // 打印Python脚本的输出
  17047. // fmt.Println(string(output))
  17048. //}
  17049. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17050. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17051. readCard := DllDef.MustFindProc("gxyb_call")
  17052. if readCard == nil {
  17053. fmt.Println("readcard is nil")
  17054. readCard = DllDef.MustFindProc("gxyb_call")
  17055. }
  17056. str := make([]byte, 1024)
  17057. str1 := make([]byte, 1024)
  17058. //data := make(map[string]interface{})
  17059. currentTime := time.Now()
  17060. // 格式化时间为 "YYYYMMDDHH24MISS"
  17061. formattedTime := currentTime.Format("20060102150405")
  17062. inputData := make(map[string]interface{})
  17063. inputData2 := make(map[string]interface{})
  17064. inputData["transNo"] = "1401"
  17065. inputData["transType"] = "passwordCheck"
  17066. inputData["timestamp"] = formattedTime
  17067. inputData2["fixmedinsCode"] = code
  17068. inputData2["psnNo"] = ""
  17069. inputData["data"] = inputData2
  17070. jsonBytes, err := json.Marshal(inputData)
  17071. if err != nil {
  17072. fmt.Println("Error encoding map to JSON:", err)
  17073. }
  17074. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17075. fmt.Println(string(str1))
  17076. fmt.Println(string(str))
  17077. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17078. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17079. if ret2 != 0 {
  17080. return ""
  17081. }
  17082. return string(str)
  17083. }
  17084. func (c *HisApiController) GetoleInfo() Response {
  17085. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17086. defer ole.CoUninitialize()
  17087. // Replace with the ProgID or CLSID of your COM object
  17088. progID := "YinHai.XJ.Actual.Interface.New"
  17089. // Create COM object
  17090. unknown, err := oleutil.CreateObject(progID)
  17091. if err != nil {
  17092. fmt.Println("Unable to create COM object:", err)
  17093. }
  17094. defer unknown.Release()
  17095. // Query for the IDispatch interface
  17096. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17097. if err != nil {
  17098. fmt.Println("Unable to get IDispatch interface:", err)
  17099. }
  17100. defer dispatch.Release()
  17101. // Prepare parameters
  17102. transNo := "1401"
  17103. transType := "passwordCheck"
  17104. timestamp := time.Now().Unix()
  17105. fixmedinsCode := "H45072101171"
  17106. psnNo := ""
  17107. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17108. result2 := ""
  17109. // Call COM object's method using the IDispatch interface
  17110. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17111. fmt.Println(resulr)
  17112. fmt.Println(result2)
  17113. if err != nil {
  17114. fmt.Println("调用COM对象方法失败:", err)
  17115. }
  17116. var response Response
  17117. err2 := json.Unmarshal([]byte(result2), &response)
  17118. if err2 != nil {
  17119. fmt.Println("解析JSON失败:", err)
  17120. }
  17121. return response
  17122. }
  17123. func (c *HisApiController) GetBasBaseInfo() string {
  17124. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17125. readCard := DllDef.MustFindProc("ReadCardBas")
  17126. if readCard == nil {
  17127. fmt.Println("readcard is nil")
  17128. readCard = DllDef.MustFindProc("ReadCardBas")
  17129. }
  17130. str := make([]byte, 1024)
  17131. str1 := make([]byte, 1024)
  17132. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17133. fmt.Println(string(str1))
  17134. fmt.Println(string(str))
  17135. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17136. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17137. if ret2 != 0 {
  17138. return ""
  17139. }
  17140. return string(str)
  17141. }
  17142. type Program struct {
  17143. FunctionID string `xml:"function_id"`
  17144. CardInfo string `xml:"cardinfo"`
  17145. User string `xml:"user"`
  17146. }
  17147. func (c *HisApiController) GetBasBaseInfo1111() string {
  17148. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17149. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17150. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17151. if readCard == nil {
  17152. fmt.Println("readcard is nil")
  17153. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17154. }
  17155. if readCard2 == nil {
  17156. fmt.Println("readcard is nil")
  17157. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17158. }
  17159. str := make([]byte, 1024)
  17160. str1 := make([]byte, 1024)
  17161. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17162. str3 := make([]byte, 1024)
  17163. str4 := make([]byte, 1024)
  17164. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17165. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17166. //if err != nil {
  17167. // fmt.Println("Error opening file:", err)
  17168. //}
  17169. //defer file.Close()
  17170. //
  17171. //var lastProgram Program
  17172. //scanner := bufio.NewScanner(file)
  17173. //inProgram := false
  17174. //
  17175. //for scanner.Scan() {
  17176. // line := scanner.Text()
  17177. // if strings.Contains(line, "<program>") {
  17178. // inProgram = true
  17179. // programXML := "<program>"
  17180. // for scanner.Scan() {
  17181. // line = scanner.Text()
  17182. // programXML += line
  17183. // if strings.Contains(line, "</program>") {
  17184. // programXML += "</program>"
  17185. // break
  17186. // }
  17187. // }
  17188. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17189. // // 解析成功,更新最后的 Program
  17190. // }
  17191. // inProgram = false
  17192. // }
  17193. //}
  17194. //
  17195. // fmt.Println("Error reading file:", inProgram)
  17196. //
  17197. //if err := scanner.Err(); err != nil {
  17198. // fmt.Println("Error reading file:", err)
  17199. //}
  17200. // 输出最后一次的 Program
  17201. //fmt.Printf("最后一次的 <program>:\n")
  17202. //fmt.Printf("<program>\n")
  17203. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17204. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17205. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17206. //fmt.Printf("</program>\n")
  17207. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17208. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17209. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17210. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17211. return ConvertToString(string(str), "gbk", "utf-8")
  17212. }
  17213. func (c *HisApiController) GetBasBaseInfo22222() string {
  17214. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17215. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17216. if readCard == nil {
  17217. fmt.Println("readcard is nil")
  17218. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17219. }
  17220. str := make([]byte, 1024)
  17221. str1 := make([]byte, 1024)
  17222. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17223. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17224. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17225. //if err != nil {
  17226. // fmt.Println("Error opening file:", err)
  17227. //}
  17228. //defer file.Close()
  17229. //
  17230. //var lastProgram Program
  17231. //scanner := bufio.NewScanner(file)
  17232. //inProgram := false
  17233. //
  17234. //for scanner.Scan() {
  17235. // line := scanner.Text()
  17236. // if strings.Contains(line, "<program>") {
  17237. // inProgram = true
  17238. // programXML := "<program>"
  17239. // for scanner.Scan() {
  17240. // line = scanner.Text()
  17241. // programXML += line
  17242. // if strings.Contains(line, "</program>") {
  17243. // programXML += "</program>"
  17244. // break
  17245. // }
  17246. // }
  17247. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17248. // // 解析成功,更新最后的 Program
  17249. // }
  17250. // inProgram = false
  17251. // }
  17252. //}
  17253. //
  17254. // fmt.Println("Error reading file:", inProgram)
  17255. //
  17256. //if err := scanner.Err(); err != nil {
  17257. // fmt.Println("Error reading file:", err)
  17258. //}
  17259. // 输出最后一次的 Program
  17260. //fmt.Printf("最后一次的 <program>:\n")
  17261. //fmt.Printf("<program>\n")
  17262. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17263. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17264. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17265. //fmt.Printf("</program>\n")
  17266. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17267. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17268. return ConvertToString(string(str1), "gbk", "utf-8")
  17269. }
  17270. func (c *HisApiController) GetahBasBaseInfo() string {
  17271. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17272. readCard := DllDef.MustFindProc("iReadCardBas")
  17273. if readCard == nil {
  17274. fmt.Println("readcard is nil")
  17275. readCard = DllDef.MustFindProc("iReadCardBas")
  17276. }
  17277. //str := make([]byte, 1024)
  17278. str1 := make([]byte, 1024)
  17279. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17280. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17281. //if err != nil {
  17282. // fmt.Println("Error opening file:", err)
  17283. //}
  17284. //defer file.Close()
  17285. //
  17286. //var lastProgram Program
  17287. //scanner := bufio.NewScanner(file)
  17288. //inProgram := false
  17289. //
  17290. //for scanner.Scan() {
  17291. // line := scanner.Text()
  17292. // if strings.Contains(line, "<program>") {
  17293. // inProgram = true
  17294. // programXML := "<program>"
  17295. // for scanner.Scan() {
  17296. // line = scanner.Text()
  17297. // programXML += line
  17298. // if strings.Contains(line, "</program>") {
  17299. // programXML += "</program>"
  17300. // break
  17301. // }
  17302. // }
  17303. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17304. // // 解析成功,更新最后的 Program
  17305. // }
  17306. // inProgram = false
  17307. // }
  17308. //}
  17309. //
  17310. // fmt.Println("Error reading file:", inProgram)
  17311. //
  17312. //if err := scanner.Err(); err != nil {
  17313. // fmt.Println("Error reading file:", err)
  17314. //}
  17315. // 输出最后一次的 Program
  17316. //fmt.Printf("最后一次的 <program>:\n")
  17317. //fmt.Printf("<program>\n")
  17318. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17319. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17320. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17321. //fmt.Printf("</program>\n")
  17322. fmt.Println(string(str1))
  17323. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17324. if ret2 != 0 {
  17325. return ""
  17326. }
  17327. return string(str1)
  17328. }
  17329. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17330. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17331. readCard := DllDef.MustFindProc("read_cardinfo")
  17332. if readCard == nil {
  17333. fmt.Println("readcard is nil")
  17334. readCard = DllDef.MustFindProc("read_cardinfo")
  17335. }
  17336. str := make([]byte, 1024) //卡号
  17337. str1 := make([]byte, 1024) //卡识别码
  17338. str2 := make([]byte, 1024) //身份证号
  17339. str3 := make([]byte, 1024) //姓名
  17340. str4 := make([]byte, 1024) //错误信息
  17341. 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])))
  17342. fmt.Println(string(str1))
  17343. fmt.Println(string(str))
  17344. fmt.Println(string(str2))
  17345. fmt.Println(string(str3))
  17346. fmt.Println(string(str4))
  17347. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17348. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17349. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17350. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17351. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17352. if ret2 != 0 {
  17353. return "", "", "", "", ""
  17354. }
  17355. return string(str), string(str1), string(str2), string(str3), string(str4)
  17356. }
  17357. type CustomFundPay struct {
  17358. FundPayType string `json:"fund_pay_type"`
  17359. FundPayamt float64 `json:"fund_payamt"`
  17360. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17361. }
  17362. //func (c *HisApiController) GetBatchSettleList() {
  17363. // start_time_str := c.GetString("start_time")
  17364. // //end_time_str := c.GetString("end_time")
  17365. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17366. //
  17367. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17368. //
  17369. // for _, item := range orders {
  17370. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17371. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17372. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17373. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17374. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17375. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17376. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17377. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17378. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17379. //
  17380. // if order.ID == 0 {
  17381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17382. // return
  17383. // }
  17384. //
  17385. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17386. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17387. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17388. // //fmt.Println(count)
  17389. // //var zero string
  17390. // //number := count + 1
  17391. // //if number >= 1000 {
  17392. // // zero = "0000" + strconv.FormatInt(number, 10)
  17393. // //} else if number >= 10000 {
  17394. // // zero = "000" + strconv.FormatInt(number, 10)
  17395. // //} else if number >= 100000 {
  17396. // // zero = "00" + strconv.FormatInt(number, 10)
  17397. // //} else if number >= 1000000 {
  17398. // // zero = "0" + strconv.FormatInt(number, 10)
  17399. // //} else {
  17400. // // zero = strconv.FormatInt(number, 10)
  17401. // //}
  17402. // //fmt.Println(zero)
  17403. //
  17404. // struct4101 := service.Struct4101{
  17405. // PsnNo: order.PsnNo,
  17406. // MdtrtId: order.MdtrtId,
  17407. // SetlId: order.SetlId,
  17408. // PsnName: order.PsnName,
  17409. // Gend: order.Gend,
  17410. // Brdy: his.Brdy,
  17411. // Age: his.Age,
  17412. // Naty: order.Naty,
  17413. // PatnCertType: "01",
  17414. // Certno: order.Certno,
  17415. // Prfs: "90",
  17416. // ConerName: roles[0].UserName,
  17417. // PatnRlts: "99",
  17418. // ConerAddr: miConfig.OrgName,
  17419. // ConerTel: admin.Mobile,
  17420. // HiType: order.Insutype,
  17421. // Insuplc: miConfig.InsuplcAdmdvs,
  17422. // MaindiagFlag: "1",
  17423. // BillCode: order.SetlId,
  17424. // BillNo: order.SetlId,
  17425. // BizSn: order.Number,
  17426. // PsnSelfPay: order.PsnPartAmt,
  17427. // PsnOwnPay: order.PsnPartAmt,
  17428. // AcctPay: order.AcctPay,
  17429. // PsnCashpay: order.PsnCashPay,
  17430. // HiPaymtd: "1",
  17431. // Hsorg: miConfig.InsuplcAdmdvs,
  17432. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17433. // MedinsFillPsn: curRoles.UserName,
  17434. // MedinsFillDept: miConfig.OrgName,
  17435. // IptMedType: "2",
  17436. // }
  17437. // struct4101.SetlBegnDate = order.SetlTime
  17438. // struct4101.SetlEndDate = order.SetlTime
  17439. // time_arr := strings.Split(order.SetlTime, " ")
  17440. // struct4101.AdmTime = time_arr[0]
  17441. // struct4101.AdmEndTime = time_arr[0]
  17442. //
  17443. // var rf []CustomFundPay
  17444. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17445. //
  17446. // var tempFunPays []service.CustomStruct
  17447. // for _, item := range rf {
  17448. // var tempFunPay service.CustomStruct
  17449. // tempFunPay.FundPayamt = item.FundPayamt
  17450. // tempFunPay.FundPayType = item.FundPayType
  17451. // tempFunPays = append(tempFunPays, tempFunPay)
  17452. // }
  17453. // struct4101.CustomStruct = tempFunPays
  17454. //
  17455. // var tempDiaginfos []service.DiaginfoStructTwo
  17456. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17457. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17458. //
  17459. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17460. // var config []*models.HisXtDiagnoseConfig
  17461. // for _, item := range diagnosis_ids {
  17462. // id, _ := strconv.ParseInt(item, 10, 64)
  17463. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17464. // config = append(config, &diagnosisConfig)
  17465. // }
  17466. //
  17467. // for index, item := range config {
  17468. // if index == 0 {
  17469. // var tempDiaginfo service.DiaginfoStructTwo
  17470. // tempDiaginfo.DiagCode = item.CountryCode
  17471. // tempDiaginfo.DiagName = item.CountryContentName
  17472. // tempDiaginfo.DiagType = "1"
  17473. // tempDiaginfo.MaindiagFlag = "1"
  17474. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17475. // } else {
  17476. // var tempDiaginfo service.DiaginfoStructTwo
  17477. // tempDiaginfo.DiagCode = item.CountryCode
  17478. // tempDiaginfo.DiagName = item.CountryContentName
  17479. // tempDiaginfo.DiagType = "1"
  17480. // tempDiaginfo.MaindiagFlag = "0"
  17481. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17482. // }
  17483. // }
  17484. // struct4101.Diseinfo = tempDiaginfos
  17485. //
  17486. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17487. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17488. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17489. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17490. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17491. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17492. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17493. //
  17494. // var iteminfo service.IteminfoStruct
  17495. //
  17496. // var bedCostTotal float64 = 0 //床位总费
  17497. // var bedCostSelfTotal float64 = 0 //床位自费
  17498. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17499. //
  17500. // var operationCostTotal float64 = 0 //手术费
  17501. // var operationCostSelfTotal float64 = 0 //手术费
  17502. // var operationCostPartSelfTotal float64 = 0 //手术费
  17503. //
  17504. // var otherCostTotal float64 = 0 //其他费用
  17505. // var otherCostSelfTotal float64 = 0 //其他费用
  17506. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17507. //
  17508. // var materialCostTotal float64 = 0 //材料费
  17509. // var materialCostSelfTotal float64 = 0 //材料费
  17510. // var materialCostPartSelfTotal float64 = 0 //材料费
  17511. //
  17512. // var westernMedicineCostTotal float64 = 0 //西药费
  17513. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17514. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17515. //
  17516. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17517. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17518. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17519. //
  17520. // var checkCostTotal float64 = 0 //检查费
  17521. // var checkCostSelfTotal float64 = 0 //检查费
  17522. // var checkCostPartSelfTotal float64 = 0 //检查费
  17523. //
  17524. // var laboratoryCostTotal float64 = 0 //化验费
  17525. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17526. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17527. //
  17528. // var treatCostTotal float64 = 0 //治疗费用
  17529. // var treatCostSelfTotal float64 = 0 //治疗费用
  17530. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17531. //
  17532. // decimal.DivisionPrecision = 2
  17533. //
  17534. // var bed_fulamt_ownpay_amt float64 = 0
  17535. // var operation_fulamt_ownpay_amt float64 = 0
  17536. // var other_fulamt_ownpay_amt float64 = 0
  17537. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17538. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17539. // var check_fulamt_ownpay_amt float64 = 0
  17540. // var material_fulamt_ownpay_amt float64 = 0
  17541. // var laboratory_fulamt_ownpay_amt float64 = 0
  17542. // var treat_fulamt_ownpay_amt float64 = 0
  17543. //
  17544. // var bed_claa_sunmfee float64 = 0
  17545. // var bed_clab_amt float64 = 0
  17546. // var bed_other_amt float64 = 0
  17547. //
  17548. // var operation_claa_sunmfee float64 = 0
  17549. // var operation_clab_amt float64 = 0
  17550. // var operation_other_amt float64 = 0
  17551. //
  17552. // var other_claa_sunmfee float64 = 0
  17553. // var other_clab_amt float64 = 0
  17554. // var other_other_amt float64 = 0
  17555. //
  17556. // var westernMedicine_claa_sunmfee float64 = 0
  17557. // var westernMedicine_clab_amt float64 = 0
  17558. // var westernMedicine_other_amt float64 = 0
  17559. //
  17560. // var chineseTraditional_claa_sunmfee float64 = 0
  17561. // var chineseTraditional_clab_amt float64 = 0
  17562. // var chineseTraditional_other_amt float64 = 0
  17563. //
  17564. // var check_claa_sunmfee float64 = 0
  17565. // var check_clab_amt float64 = 0
  17566. // var check_other_amt float64 = 0
  17567. //
  17568. // var material_claa_sunmfee float64 = 0
  17569. // var material_clab_amt float64 = 0
  17570. // var material_other_amt float64 = 0
  17571. //
  17572. // var laboratory_claa_sunmfee float64 = 0
  17573. // var laboratory_clab_amt float64 = 0
  17574. // var laboratory_other_amt float64 = 0
  17575. //
  17576. // var treat_claa_sunmfee float64 = 0
  17577. // var treat_clab_amt float64 = 0
  17578. // var treat_other_amt float64 = 0
  17579. //
  17580. // for _, item := range order.HisOrderInfo {
  17581. // if item.MedChrgitmType == "01" { //床位费
  17582. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17583. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17584. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17585. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17586. // if item.ChrgitmLv == "1" {
  17587. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17588. // }
  17589. // if item.ChrgitmLv == "2" {
  17590. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17591. //
  17592. // }
  17593. // if item.ChrgitmLv == "3" {
  17594. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17595. // }
  17596. //
  17597. // }
  17598. //
  17599. // if item.MedChrgitmType == "03" { //检查费
  17600. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17601. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17602. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17603. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17604. // if item.ChrgitmLv == "1" {
  17605. //
  17606. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17607. //
  17608. // }
  17609. // if item.ChrgitmLv == "2" {
  17610. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17611. //
  17612. // }
  17613. // if item.ChrgitmLv == "3" {
  17614. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17615. // }
  17616. // }
  17617. //
  17618. // if item.MedChrgitmType == "04" { //化验费
  17619. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17620. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17621. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17622. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17623. // if item.ChrgitmLv == "1" {
  17624. //
  17625. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17626. //
  17627. // }
  17628. // if item.ChrgitmLv == "2" {
  17629. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17630. //
  17631. // }
  17632. // if item.ChrgitmLv == "3" {
  17633. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17634. // }
  17635. // }
  17636. //
  17637. // if item.MedChrgitmType == "05" { //治疗费
  17638. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17639. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17640. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17641. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17642. // if item.ChrgitmLv == "1" {
  17643. //
  17644. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17645. //
  17646. // }
  17647. // if item.ChrgitmLv == "2" {
  17648. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17649. //
  17650. // }
  17651. // if item.ChrgitmLv == "3" {
  17652. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17653. // }
  17654. // }
  17655. //
  17656. // if item.MedChrgitmType == "06" { //手术费
  17657. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17658. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17659. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17660. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17661. //
  17662. // if item.ChrgitmLv == "1" {
  17663. //
  17664. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17665. //
  17666. // }
  17667. // if item.ChrgitmLv == "2" {
  17668. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17669. //
  17670. // }
  17671. // if item.ChrgitmLv == "3" {
  17672. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17673. // }
  17674. // }
  17675. //
  17676. // if item.MedChrgitmType == "08" { //材料费
  17677. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17678. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17679. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17680. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17681. // if item.ChrgitmLv == "1" {
  17682. //
  17683. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17684. //
  17685. // }
  17686. // if item.ChrgitmLv == "2" {
  17687. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17688. //
  17689. // }
  17690. // if item.ChrgitmLv == "3" {
  17691. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17692. // }
  17693. // }
  17694. //
  17695. // if item.MedChrgitmType == "09" { //西药费
  17696. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17697. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17698. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17699. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17700. // if item.ChrgitmLv == "1" {
  17701. //
  17702. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17703. //
  17704. // }
  17705. // if item.ChrgitmLv == "2" {
  17706. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17707. //
  17708. // }
  17709. // if item.ChrgitmLv == "3" {
  17710. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17711. // }
  17712. // }
  17713. //
  17714. // if item.MedChrgitmType == "11" { //中成费
  17715. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17716. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17717. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17718. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17719. // if item.ChrgitmLv == "1" {
  17720. //
  17721. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17722. //
  17723. // }
  17724. // if item.ChrgitmLv == "2" {
  17725. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17726. //
  17727. // }
  17728. // if item.ChrgitmLv == "3" {
  17729. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17730. // }
  17731. // }
  17732. //
  17733. // if item.MedChrgitmType == "14" { //其他费
  17734. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17735. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17736. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17737. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17738. // if item.ChrgitmLv == "1" {
  17739. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17740. //
  17741. // }
  17742. // if item.ChrgitmLv == "2" {
  17743. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17744. //
  17745. // }
  17746. // if item.ChrgitmLv == "3" {
  17747. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17748. // }
  17749. // }
  17750. //
  17751. // }
  17752. //
  17753. // var iteminfoStructs []service.IteminfoStruct
  17754. //
  17755. // if bedCostTotal != 0 {
  17756. // iteminfo.MedChrgitm = "01"
  17757. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17758. // iteminfo.Amt = bedCostTotal
  17759. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  17760. // iteminfo.ClabAmt = bed_clab_amt
  17761. // iteminfo.OthAmt = bed_other_amt
  17762. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17763. // }
  17764. //
  17765. // if checkCostTotal != 0 {
  17766. // iteminfo.MedChrgitm = "03"
  17767. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17768. // iteminfo.Amt = checkCostTotal
  17769. // iteminfo.ClaaSumfee = check_claa_sunmfee
  17770. // iteminfo.ClabAmt = check_clab_amt
  17771. // iteminfo.OthAmt = check_other_amt
  17772. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17773. //
  17774. // }
  17775. //
  17776. // if laboratoryCostTotal != 0 {
  17777. // iteminfo.MedChrgitm = "04"
  17778. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17779. // iteminfo.Amt = laboratoryCostTotal
  17780. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17781. // iteminfo.ClabAmt = laboratory_clab_amt
  17782. // iteminfo.OthAmt = laboratory_other_amt
  17783. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17784. //
  17785. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17786. //
  17787. // }
  17788. //
  17789. // if treatCostTotal != 0 {
  17790. // iteminfo.MedChrgitm = "05"
  17791. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17792. // iteminfo.Amt = treatCostTotal
  17793. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  17794. // iteminfo.ClabAmt = treat_clab_amt
  17795. // iteminfo.OthAmt = treat_other_amt
  17796. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17797. // //(struct4101.IteminfoStruct, iteminfo)
  17798. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17799. // }
  17800. //
  17801. // if operationCostTotal != 0 {
  17802. // iteminfo.MedChrgitm = "06"
  17803. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17804. // iteminfo.Amt = operationCostTotal
  17805. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  17806. // iteminfo.ClabAmt = operation_clab_amt
  17807. // iteminfo.OthAmt = operation_other_amt
  17808. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17809. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17810. // }
  17811. //
  17812. // if materialCostTotal != 0 {
  17813. // iteminfo.MedChrgitm = "08"
  17814. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17815. // iteminfo.Amt = materialCostTotal
  17816. // iteminfo.ClaaSumfee = material_claa_sunmfee
  17817. // iteminfo.ClabAmt = material_clab_amt
  17818. // iteminfo.OthAmt = material_other_amt
  17819. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17820. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17821. // }
  17822. //
  17823. // if westernMedicineCostTotal != 0 {
  17824. // iteminfo.MedChrgitm = "09"
  17825. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17826. // iteminfo.Amt = westernMedicineCostTotal
  17827. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17828. // iteminfo.ClabAmt = westernMedicine_clab_amt
  17829. // iteminfo.OthAmt = westernMedicine_other_amt
  17830. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17831. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17832. //
  17833. // }
  17834. // if chineseTraditionalMedicineCostTotal != 0 {
  17835. // iteminfo.MedChrgitm = "11"
  17836. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17837. // iteminfo.Amt = westernMedicineCostTotal
  17838. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17839. // iteminfo.ClabAmt = westernMedicine_clab_amt
  17840. // iteminfo.OthAmt = westernMedicine_other_amt
  17841. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17842. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17843. //
  17844. // }
  17845. // if otherCostTotal != 0 {
  17846. // iteminfo.MedChrgitm = "14"
  17847. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17848. // iteminfo.Amt = otherCostTotal
  17849. // iteminfo.ClaaSumfee = other_claa_sunmfee
  17850. // iteminfo.ClabAmt = other_clab_amt
  17851. // iteminfo.OthAmt = other_other_amt
  17852. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17853. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17854. //
  17855. // }
  17856. // struct4101.IteminfoStruct = iteminfoStructs
  17857. // struct4101.Ntly = "中国"
  17858. // struct4101.AdmCaty = "A03.06"
  17859. //
  17860. // struct4101.DoctorName = doctor.UserName
  17861. // struct4101.DoctorCode = doctor.DoctorNumber
  17862. //
  17863. // var res ResultSeventeen
  17864. //
  17865. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17866. // struct4101.BillCode = order.Number
  17867. // struct4101.BillNo = order.SetlId
  17868. // var resOther ResultSeventeenOther
  17869. // var pp models.PublicParams
  17870. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17871. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17872. // pp.FixmedinsName = miConfig.OrgName
  17873. // pp.FixmedinsCode = miConfig.Code
  17874. // pp.RequestUrl = miConfig.Url
  17875. // pp.Cainfo = miConfig.Cainfo
  17876. // pp.SecretKey = miConfig.SecretKey
  17877. // pp.AccessKey = miConfig.AccessKey
  17878. // pp.OpterName = curRoles.UserName
  17879. //
  17880. // client := &http.Client{}
  17881. // var req *http.Request
  17882. // data := make(map[string]interface{})
  17883. // data["struct4101"] = struct4101
  17884. // data["pp"] = pp
  17885. // bytesData, _ := json.Marshal(data)
  17886. // if miConfig.MdtrtareaAdmvs == "320921" {
  17887. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17888. // } else {
  17889. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17890. // }
  17891. // resp, _ := client.Do(req)
  17892. // defer resp.Body.Close()
  17893. // body, ioErr := ioutil.ReadAll(resp.Body)
  17894. // if ioErr != nil {
  17895. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17897. // return
  17898. // }
  17899. // var respJSON map[string]interface{}
  17900. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17901. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17903. // return
  17904. // }
  17905. //
  17906. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17907. // userJSONBytes, _ := json.Marshal(respJSON)
  17908. // fmt.Println("log")
  17909. // fmt.Println(string(userJSONBytes))
  17910. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17911. // utils.ErrorLog("解析失败:%v", err)
  17912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17913. // return
  17914. // }
  17915. // res.InfRefmsgid = resOther.InfRefmsgid
  17916. // res.Output = resOther.Output
  17917. // res.ErrMsg = resOther.ErrMsg
  17918. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17919. // res.Infcode = infocode
  17920. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  17921. //
  17922. // var pp models.PublicParams
  17923. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17924. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17925. // pp.FixmedinsName = miConfig.OrgName
  17926. // pp.FixmedinsCode = miConfig.Code
  17927. // pp.RequestUrl = miConfig.Url
  17928. // pp.Cainfo = miConfig.Cainfo
  17929. // pp.SecretKey = miConfig.SecretKey
  17930. // pp.AccessKey = miConfig.AccessKey
  17931. // pp.OpterName = curRoles.UserName
  17932. // result, _ := service.Jxyb4101(struct4101, pp)
  17933. // var dat map[string]interface{}
  17934. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17935. // fmt.Println(dat)
  17936. // } else {
  17937. // fmt.Println(err)
  17938. // }
  17939. // userJSONBytes, _ := json.Marshal(dat)
  17940. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17941. // utils.ErrorLog("解析失败:%v", err)
  17942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17943. // return
  17944. // }
  17945. //
  17946. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  17947. // var pp models.PublicParams
  17948. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17949. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17950. // pp.FixmedinsName = miConfig.OrgName
  17951. // pp.FixmedinsCode = miConfig.Code
  17952. // pp.RequestUrl = miConfig.Url
  17953. // pp.Cainfo = miConfig.Cainfo
  17954. // pp.SecretKey = miConfig.SecretKey
  17955. // pp.AccessKey = miConfig.AccessKey
  17956. // pp.OpterName = curRoles.UserName
  17957. // result, _ := service.Hnyb4101(struct4101, pp)
  17958. // var dat map[string]interface{}
  17959. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17960. // fmt.Println(dat)
  17961. // } else {
  17962. // fmt.Println(err)
  17963. // }
  17964. // userJSONBytes, _ := json.Marshal(dat)
  17965. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17966. // utils.ErrorLog("解析失败:%v", err)
  17967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17968. // return
  17969. // }
  17970. //
  17971. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  17972. // var resOther ResultSeventeenOther
  17973. //
  17974. // var pp models.PublicParams
  17975. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17976. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17977. // pp.FixmedinsName = miConfig.OrgName
  17978. // pp.FixmedinsCode = miConfig.Code
  17979. // pp.RequestUrl = miConfig.Url
  17980. // pp.Cainfo = miConfig.Cainfo
  17981. // pp.SecretKey = miConfig.SecretKey
  17982. // pp.AccessKey = miConfig.AccessKey
  17983. // pp.OpterName = curRoles.UserName
  17984. // client := &http.Client{}
  17985. // var req *http.Request
  17986. // data := make(map[string]interface{})
  17987. // data["struct4101"] = struct4101
  17988. // data["pp"] = pp
  17989. // bytesData, _ := json.Marshal(data)
  17990. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17991. // resp, _ := client.Do(req)
  17992. // defer resp.Body.Close()
  17993. // body, ioErr := ioutil.ReadAll(resp.Body)
  17994. // if ioErr != nil {
  17995. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17996. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17997. // return
  17998. // }
  17999. // var respJSON map[string]interface{}
  18000. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18001. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18002. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18003. // return
  18004. // }
  18005. //
  18006. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18007. // userJSONBytes, _ := json.Marshal(respJSON)
  18008. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18009. // utils.ErrorLog("解析失败:%v", err)
  18010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18011. // return
  18012. // }
  18013. // res.InfRefmsgid = resOther.InfRefmsgid
  18014. // res.Output = resOther.Output
  18015. // res.ErrMsg = resOther.ErrMsg
  18016. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18017. // res.Infcode = infocode
  18018. //
  18019. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18020. // var pp models.PublicParams
  18021. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18022. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18023. // pp.FixmedinsName = miConfig.OrgName
  18024. // pp.FixmedinsCode = miConfig.Code
  18025. // pp.RequestUrl = miConfig.Url
  18026. // pp.Cainfo = miConfig.Cainfo
  18027. // pp.SecretKey = miConfig.SecretKey
  18028. // pp.AccessKey = miConfig.AccessKey
  18029. // pp.OpterName = curRoles.UserName
  18030. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18031. // fmt.Println(requestLog)
  18032. // fmt.Println(errMsgLog)
  18033. //
  18034. // saveLog(result, requestLog, "4101a", "上传清单")
  18035. //
  18036. // var dat map[string]interface{}
  18037. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18038. // fmt.Println(dat)
  18039. // } else {
  18040. // fmt.Println(err)
  18041. // }
  18042. // userJSONBytes, _ := json.Marshal(dat)
  18043. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18044. // utils.ErrorLog("解析失败:%v", err)
  18045. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18046. // return
  18047. // }
  18048. //
  18049. // } else {
  18050. //
  18051. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18052. // var dat map[string]interface{}
  18053. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18054. // fmt.Println(dat)
  18055. // } else {
  18056. // fmt.Println(err)
  18057. // }
  18058. // userJSONBytes, _ := json.Marshal(dat)
  18059. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18060. // utils.ErrorLog("解析失败:%v", err)
  18061. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18062. // return
  18063. // }
  18064. // }
  18065. //
  18066. // if res.Infcode != 0 {
  18067. // adminUser := c.GetAdminUserInfo()
  18068. // errlog := &models.HisOrderError{
  18069. // UserOrgId: adminUser.CurrentOrgId,
  18070. // Ctime: time.Now().Unix(),
  18071. // Mtime: time.Now().Unix(),
  18072. // ErrMsg: res.ErrMsg,
  18073. // Status: 1,
  18074. // PatientId: order.ID,
  18075. // Stage: 10265,
  18076. // }
  18077. // service.CreateErrMsgLog(errlog)
  18078. // continue
  18079. // } else {
  18080. // //order.FaPiaoNumber = zero
  18081. // //order.FaPiaoCode = last_order.FaPiaoCode
  18082. // //service.UpdateOrder(order)
  18083. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18084. // Number: res.Output.SetlListId,
  18085. // Status: 1,
  18086. // Ctime: time.Now().Unix(),
  18087. // Mtime: time.Now().Unix(),
  18088. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18089. // IsUpload: 1,
  18090. // OrderId: order.ID,
  18091. // }
  18092. // service.CreateUploadRecord(hisFundSettleListResult)
  18093. // c.ServeSuccessJSON(map[string]interface{}{
  18094. // "msg": "上传成功",
  18095. // "result": hisFundSettleListResult,
  18096. // })
  18097. // continue
  18098. // }
  18099. // }
  18100. //}
  18101. func (c *HisApiController) GetbatchSettleList() {
  18102. //order_id, _ := c.GetInt64("order_id")
  18103. admin_user_id, _ := c.GetInt64("admin_user_id")
  18104. orders, _ := service.GetAllHisOrderTwo10485()
  18105. for _, item := range orders {
  18106. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18107. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18108. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18109. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18110. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18111. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18112. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18113. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18114. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18115. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18116. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18117. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18118. //fmt.Println(count)
  18119. //var zero string
  18120. //number := count + 1
  18121. //if number >= 1000 {
  18122. // zero = "0000" + strconv.FormatInt(number, 10)
  18123. //} else if number >= 10000 {
  18124. // zero = "000" + strconv.FormatInt(number, 10)
  18125. //} else if number >= 100000 {
  18126. // zero = "00" + strconv.FormatInt(number, 10)
  18127. //} else if number >= 1000000 {
  18128. // zero = "0" + strconv.FormatInt(number, 10)
  18129. //} else {
  18130. // zero = strconv.FormatInt(number, 10)
  18131. //}
  18132. //fmt.Println(zero)
  18133. struct4101 := service.Struct4101{
  18134. PsnNo: order.PsnNo,
  18135. MdtrtId: order.MdtrtId,
  18136. SetlId: order.SetlId,
  18137. PsnName: order.PsnName,
  18138. Gend: order.Gend,
  18139. Brdy: his.Brdy,
  18140. Age: his.Age,
  18141. Naty: order.Naty,
  18142. PatnCertType: "01",
  18143. Certno: order.Certno,
  18144. Prfs: "90",
  18145. ConerName: roles[0].UserName,
  18146. PatnRlts: "99",
  18147. ConerAddr: miConfig.OrgName,
  18148. ConerTel: admin.Mobile,
  18149. HiType: order.Insutype,
  18150. Insuplc: miConfig.InsuplcAdmdvs,
  18151. MaindiagFlag: "1",
  18152. BillCode: order.SetlId,
  18153. BillNo: order.SetlId,
  18154. BizSn: order.Number,
  18155. PsnSelfPay: order.PsnPartAmt,
  18156. PsnOwnPay: order.PsnPartAmt,
  18157. AcctPay: order.AcctPay,
  18158. PsnCashpay: order.PsnCashPay,
  18159. HiPaymtd: "1",
  18160. Hsorg: miConfig.InsuplcAdmdvs,
  18161. HsorgOpter: miConfig.InsuplcAdmdvs,
  18162. MedinsFillPsn: curRoles.UserName,
  18163. MedinsFillDept: miConfig.OrgName,
  18164. IptMedType: "2",
  18165. }
  18166. struct4101.SetlBegnDate = order.SetlTime
  18167. struct4101.SetlEndDate = order.SetlTime
  18168. time_arr := strings.Split(order.SetlTime, " ")
  18169. struct4101.AdmTime = time_arr[0]
  18170. struct4101.AdmEndTime = time_arr[0]
  18171. //var rf []CustomFundPay
  18172. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18173. //
  18174. //var tempFunPays []service.CustomStruct
  18175. //for _, item := range rf {
  18176. // var tempFunPay service.CustomStruct
  18177. // tempFunPay.FundPayamt = item.FundPayamt
  18178. // tempFunPay.FundPayType = item.FundPayType
  18179. // tempFunPays = append(tempFunPays, tempFunPay)
  18180. //}
  18181. //struct4101.CustomStruct = tempFunPays
  18182. var tempDiaginfos []service.DiaginfoStructTwo
  18183. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18184. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18185. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18186. var config []*models.HisXtDiagnoseConfig
  18187. for _, item := range diagnosis_ids {
  18188. id, _ := strconv.ParseInt(item, 10, 64)
  18189. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18190. config = append(config, &diagnosisConfig)
  18191. }
  18192. for index, item := range config {
  18193. if index == 0 {
  18194. var tempDiaginfo service.DiaginfoStructTwo
  18195. tempDiaginfo.DiagCode = item.CountryCode
  18196. tempDiaginfo.DiagName = item.CountryContentName
  18197. tempDiaginfo.DiagType = "1"
  18198. tempDiaginfo.MaindiagFlag = "1"
  18199. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18200. } else {
  18201. var tempDiaginfo service.DiaginfoStructTwo
  18202. tempDiaginfo.DiagCode = item.CountryCode
  18203. tempDiaginfo.DiagName = item.CountryContentName
  18204. tempDiaginfo.DiagType = "1"
  18205. tempDiaginfo.MaindiagFlag = "0"
  18206. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18207. }
  18208. }
  18209. struct4101.Diseinfo = tempDiaginfos
  18210. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18211. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18212. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18213. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18214. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18215. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18216. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18217. var iteminfo service.IteminfoStruct
  18218. var bedCostTotal float64 = 0 //床位总费
  18219. var bedCostSelfTotal float64 = 0 //床位自费
  18220. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18221. var operationCostTotal float64 = 0 //手术费
  18222. var operationCostSelfTotal float64 = 0 //手术费
  18223. var operationCostPartSelfTotal float64 = 0 //手术费
  18224. var otherCostTotal float64 = 0 //其他费用
  18225. var otherCostSelfTotal float64 = 0 //其他费用
  18226. var otherCostPartSelfTotal float64 = 0 //其他费用
  18227. var materialCostTotal float64 = 0 //材料费
  18228. var materialCostSelfTotal float64 = 0 //材料费
  18229. var materialCostPartSelfTotal float64 = 0 //材料费
  18230. var westernMedicineCostTotal float64 = 0 //西药费
  18231. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18232. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18233. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18234. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18235. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18236. var checkCostTotal float64 = 0 //检查费
  18237. var checkCostSelfTotal float64 = 0 //检查费
  18238. var checkCostPartSelfTotal float64 = 0 //检查费
  18239. var laboratoryCostTotal float64 = 0 //化验费
  18240. var laboratoryCostSelfTotal float64 = 0 //化验费
  18241. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18242. var treatCostTotal float64 = 0 //治疗费用
  18243. var treatCostSelfTotal float64 = 0 //治疗费用
  18244. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18245. decimal.DivisionPrecision = 2
  18246. var bed_fulamt_ownpay_amt float64 = 0
  18247. var operation_fulamt_ownpay_amt float64 = 0
  18248. var other_fulamt_ownpay_amt float64 = 0
  18249. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18250. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18251. var check_fulamt_ownpay_amt float64 = 0
  18252. var material_fulamt_ownpay_amt float64 = 0
  18253. var laboratory_fulamt_ownpay_amt float64 = 0
  18254. var treat_fulamt_ownpay_amt float64 = 0
  18255. var bed_claa_sunmfee float64 = 0
  18256. var bed_clab_amt float64 = 0
  18257. var bed_other_amt float64 = 0
  18258. var operation_claa_sunmfee float64 = 0
  18259. var operation_clab_amt float64 = 0
  18260. var operation_other_amt float64 = 0
  18261. var other_claa_sunmfee float64 = 0
  18262. var other_clab_amt float64 = 0
  18263. var other_other_amt float64 = 0
  18264. var westernMedicine_claa_sunmfee float64 = 0
  18265. var westernMedicine_clab_amt float64 = 0
  18266. var westernMedicine_other_amt float64 = 0
  18267. var chineseTraditional_claa_sunmfee float64 = 0
  18268. var chineseTraditional_clab_amt float64 = 0
  18269. var chineseTraditional_other_amt float64 = 0
  18270. var check_claa_sunmfee float64 = 0
  18271. var check_clab_amt float64 = 0
  18272. var check_other_amt float64 = 0
  18273. var material_claa_sunmfee float64 = 0
  18274. var material_clab_amt float64 = 0
  18275. var material_other_amt float64 = 0
  18276. var laboratory_claa_sunmfee float64 = 0
  18277. var laboratory_clab_amt float64 = 0
  18278. var laboratory_other_amt float64 = 0
  18279. var treat_claa_sunmfee float64 = 0
  18280. var treat_clab_amt float64 = 0
  18281. var treat_other_amt float64 = 0
  18282. for _, item := range order.HisOrderInfo {
  18283. if item.MedChrgitmType == "01" { //床位费
  18284. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18285. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18286. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18287. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18288. if item.ChrgitmLv == "1" {
  18289. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18290. }
  18291. if item.ChrgitmLv == "2" {
  18292. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18293. }
  18294. if item.ChrgitmLv == "3" {
  18295. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18296. }
  18297. }
  18298. if item.MedChrgitmType == "03" { //检查费
  18299. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18300. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18301. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18302. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18303. if item.ChrgitmLv == "1" {
  18304. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18305. }
  18306. if item.ChrgitmLv == "2" {
  18307. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18308. }
  18309. if item.ChrgitmLv == "3" {
  18310. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18311. }
  18312. }
  18313. if item.MedChrgitmType == "04" { //化验费
  18314. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18315. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18316. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18317. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18318. if item.ChrgitmLv == "1" {
  18319. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18320. }
  18321. if item.ChrgitmLv == "2" {
  18322. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18323. }
  18324. if item.ChrgitmLv == "3" {
  18325. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18326. }
  18327. }
  18328. if item.MedChrgitmType == "05" { //治疗费
  18329. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18330. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18331. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18332. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18333. if item.ChrgitmLv == "1" {
  18334. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18335. }
  18336. if item.ChrgitmLv == "2" {
  18337. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18338. }
  18339. if item.ChrgitmLv == "3" {
  18340. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18341. }
  18342. }
  18343. if item.MedChrgitmType == "06" { //手术费
  18344. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18345. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18346. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18347. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18348. if item.ChrgitmLv == "1" {
  18349. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18350. }
  18351. if item.ChrgitmLv == "2" {
  18352. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18353. }
  18354. if item.ChrgitmLv == "3" {
  18355. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18356. }
  18357. }
  18358. if item.MedChrgitmType == "08" { //材料费
  18359. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18360. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18361. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18362. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18363. if item.ChrgitmLv == "1" {
  18364. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18365. }
  18366. if item.ChrgitmLv == "2" {
  18367. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18368. }
  18369. if item.ChrgitmLv == "3" {
  18370. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18371. }
  18372. }
  18373. if item.MedChrgitmType == "09" { //西药费
  18374. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18375. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18376. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18377. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18378. if item.ChrgitmLv == "1" {
  18379. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18380. }
  18381. if item.ChrgitmLv == "2" {
  18382. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18383. }
  18384. if item.ChrgitmLv == "3" {
  18385. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18386. }
  18387. }
  18388. if item.MedChrgitmType == "11" { //中成费
  18389. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18390. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18391. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18392. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18393. if item.ChrgitmLv == "1" {
  18394. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18395. }
  18396. if item.ChrgitmLv == "2" {
  18397. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18398. }
  18399. if item.ChrgitmLv == "3" {
  18400. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18401. }
  18402. }
  18403. if item.MedChrgitmType == "14" { //其他费
  18404. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18405. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18406. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18407. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18408. if item.ChrgitmLv == "1" {
  18409. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18410. }
  18411. if item.ChrgitmLv == "2" {
  18412. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18413. }
  18414. if item.ChrgitmLv == "3" {
  18415. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18416. }
  18417. }
  18418. }
  18419. var iteminfoStructs []service.IteminfoStruct
  18420. if bedCostTotal != 0 {
  18421. iteminfo.MedChrgitm = "01"
  18422. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18423. iteminfo.Amt = bedCostTotal
  18424. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18425. iteminfo.ClabAmt = bed_clab_amt
  18426. iteminfo.OthAmt = bed_other_amt
  18427. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18428. }
  18429. if checkCostTotal != 0 {
  18430. iteminfo.MedChrgitm = "03"
  18431. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18432. iteminfo.Amt = checkCostTotal
  18433. iteminfo.ClaaSumfee = check_claa_sunmfee
  18434. iteminfo.ClabAmt = check_clab_amt
  18435. iteminfo.OthAmt = check_other_amt
  18436. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18437. }
  18438. if laboratoryCostTotal != 0 {
  18439. iteminfo.MedChrgitm = "04"
  18440. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18441. iteminfo.Amt = laboratoryCostTotal
  18442. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18443. iteminfo.ClabAmt = laboratory_clab_amt
  18444. iteminfo.OthAmt = laboratory_other_amt
  18445. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18446. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18447. }
  18448. if treatCostTotal != 0 {
  18449. iteminfo.MedChrgitm = "05"
  18450. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18451. iteminfo.Amt = treatCostTotal
  18452. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18453. iteminfo.ClabAmt = treat_clab_amt
  18454. iteminfo.OthAmt = treat_other_amt
  18455. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18456. //(struct4101.IteminfoStruct, iteminfo)
  18457. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18458. }
  18459. if operationCostTotal != 0 {
  18460. iteminfo.MedChrgitm = "06"
  18461. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18462. iteminfo.Amt = operationCostTotal
  18463. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18464. iteminfo.ClabAmt = operation_clab_amt
  18465. iteminfo.OthAmt = operation_other_amt
  18466. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18467. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18468. }
  18469. if materialCostTotal != 0 {
  18470. iteminfo.MedChrgitm = "08"
  18471. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18472. iteminfo.Amt = materialCostTotal
  18473. iteminfo.ClaaSumfee = material_claa_sunmfee
  18474. iteminfo.ClabAmt = material_clab_amt
  18475. iteminfo.OthAmt = material_other_amt
  18476. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18477. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18478. }
  18479. if westernMedicineCostTotal != 0 {
  18480. iteminfo.MedChrgitm = "09"
  18481. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18482. iteminfo.Amt = westernMedicineCostTotal
  18483. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18484. iteminfo.ClabAmt = westernMedicine_clab_amt
  18485. iteminfo.OthAmt = westernMedicine_other_amt
  18486. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18487. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18488. }
  18489. if chineseTraditionalMedicineCostTotal != 0 {
  18490. iteminfo.MedChrgitm = "11"
  18491. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18492. iteminfo.Amt = westernMedicineCostTotal
  18493. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18494. iteminfo.ClabAmt = westernMedicine_clab_amt
  18495. iteminfo.OthAmt = westernMedicine_other_amt
  18496. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18497. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18498. }
  18499. if otherCostTotal != 0 {
  18500. iteminfo.MedChrgitm = "14"
  18501. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18502. iteminfo.Amt = otherCostTotal
  18503. iteminfo.ClaaSumfee = other_claa_sunmfee
  18504. iteminfo.ClabAmt = other_clab_amt
  18505. iteminfo.OthAmt = other_other_amt
  18506. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18507. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18508. }
  18509. struct4101.IteminfoStruct = iteminfoStructs
  18510. struct4101.Ntly = "中国"
  18511. struct4101.AdmCaty = "A03.06"
  18512. struct4101.DoctorName = doctor.UserName
  18513. struct4101.DoctorCode = doctor.DoctorNumber
  18514. var res ResultSeventeen
  18515. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18516. struct4101.BillCode = order.Number
  18517. struct4101.BillNo = order.SetlId
  18518. var resOther ResultSeventeenOther
  18519. var pp models.PublicParams
  18520. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18521. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18522. pp.FixmedinsName = miConfig.OrgName
  18523. pp.FixmedinsCode = miConfig.Code
  18524. pp.RequestUrl = miConfig.Url
  18525. pp.Cainfo = miConfig.Cainfo
  18526. pp.SecretKey = miConfig.SecretKey
  18527. pp.AccessKey = miConfig.AccessKey
  18528. pp.OpterName = curRoles.UserName
  18529. client := &http.Client{}
  18530. var req *http.Request
  18531. data := make(map[string]interface{})
  18532. data["struct4101"] = struct4101
  18533. data["pp"] = pp
  18534. bytesData, _ := json.Marshal(data)
  18535. if miConfig.MdtrtareaAdmvs == "320921" {
  18536. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18537. } else {
  18538. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18539. }
  18540. resp, _ := client.Do(req)
  18541. defer resp.Body.Close()
  18542. body, ioErr := ioutil.ReadAll(resp.Body)
  18543. if ioErr != nil {
  18544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18546. return
  18547. }
  18548. var respJSON map[string]interface{}
  18549. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18552. return
  18553. }
  18554. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18555. userJSONBytes, _ := json.Marshal(respJSON)
  18556. fmt.Println("log")
  18557. fmt.Println(string(userJSONBytes))
  18558. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18559. utils.ErrorLog("解析失败:%v", err)
  18560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18561. return
  18562. }
  18563. res.InfRefmsgid = resOther.InfRefmsgid
  18564. res.Output = resOther.Output
  18565. res.ErrMsg = resOther.ErrMsg
  18566. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18567. res.Infcode = infocode
  18568. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18569. var pp models.PublicParams
  18570. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18571. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18572. pp.FixmedinsName = miConfig.OrgName
  18573. pp.FixmedinsCode = miConfig.Code
  18574. pp.RequestUrl = miConfig.Url
  18575. pp.Cainfo = miConfig.Cainfo
  18576. pp.SecretKey = miConfig.SecretKey
  18577. pp.AccessKey = miConfig.AccessKey
  18578. pp.OpterName = curRoles.UserName
  18579. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18580. result, _ := service.Jxyb4101(struct4101, pp)
  18581. var dat map[string]interface{}
  18582. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18583. fmt.Println(dat)
  18584. } else {
  18585. fmt.Println(err)
  18586. }
  18587. userJSONBytes, _ := json.Marshal(dat)
  18588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18589. utils.ErrorLog("解析失败:%v", err)
  18590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18591. return
  18592. }
  18593. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18594. var pp models.PublicParams
  18595. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18596. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18597. pp.FixmedinsName = miConfig.OrgName
  18598. pp.FixmedinsCode = miConfig.Code
  18599. pp.RequestUrl = miConfig.Url
  18600. pp.Cainfo = miConfig.Cainfo
  18601. pp.SecretKey = miConfig.SecretKey
  18602. pp.AccessKey = miConfig.AccessKey
  18603. pp.OpterName = curRoles.UserName
  18604. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18605. result, _ := service.Jxyb4101(struct4101, pp)
  18606. var dat map[string]interface{}
  18607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18608. fmt.Println(dat)
  18609. } else {
  18610. fmt.Println(err)
  18611. }
  18612. userJSONBytes, _ := json.Marshal(dat)
  18613. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18614. utils.ErrorLog("解析失败:%v", err)
  18615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18616. return
  18617. }
  18618. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18619. var pp models.PublicParams
  18620. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18621. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18622. pp.FixmedinsName = miConfig.OrgName
  18623. pp.FixmedinsCode = miConfig.Code
  18624. pp.RequestUrl = miConfig.Url
  18625. pp.Cainfo = miConfig.Cainfo
  18626. pp.SecretKey = miConfig.SecretKey
  18627. pp.AccessKey = miConfig.AccessKey
  18628. pp.OpterName = curRoles.UserName
  18629. result, _ := service.Hnyb4101(struct4101, pp)
  18630. var dat map[string]interface{}
  18631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18632. fmt.Println(dat)
  18633. } else {
  18634. fmt.Println(err)
  18635. }
  18636. userJSONBytes, _ := json.Marshal(dat)
  18637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18638. utils.ErrorLog("解析失败:%v", err)
  18639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18640. return
  18641. }
  18642. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18643. var resOther ResultSeventeenOther
  18644. var pp models.PublicParams
  18645. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18646. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18647. pp.FixmedinsName = miConfig.OrgName
  18648. pp.FixmedinsCode = miConfig.Code
  18649. pp.RequestUrl = miConfig.Url
  18650. pp.Cainfo = miConfig.Cainfo
  18651. pp.SecretKey = miConfig.SecretKey
  18652. pp.AccessKey = miConfig.AccessKey
  18653. pp.OpterName = curRoles.UserName
  18654. client := &http.Client{}
  18655. var req *http.Request
  18656. data := make(map[string]interface{})
  18657. data["struct4101"] = struct4101
  18658. data["pp"] = pp
  18659. bytesData, _ := json.Marshal(data)
  18660. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18661. resp, _ := client.Do(req)
  18662. defer resp.Body.Close()
  18663. body, ioErr := ioutil.ReadAll(resp.Body)
  18664. if ioErr != nil {
  18665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18667. return
  18668. }
  18669. var respJSON map[string]interface{}
  18670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18673. return
  18674. }
  18675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18676. userJSONBytes, _ := json.Marshal(respJSON)
  18677. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18678. utils.ErrorLog("解析失败:%v", err)
  18679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18680. return
  18681. }
  18682. res.InfRefmsgid = resOther.InfRefmsgid
  18683. res.Output = resOther.Output
  18684. res.ErrMsg = resOther.ErrMsg
  18685. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18686. res.Infcode = infocode
  18687. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18688. var pp models.PublicParams
  18689. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18690. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18691. pp.FixmedinsName = miConfig.OrgName
  18692. pp.FixmedinsCode = miConfig.Code
  18693. pp.RequestUrl = miConfig.Url
  18694. pp.Cainfo = miConfig.Cainfo
  18695. pp.SecretKey = miConfig.SecretKey
  18696. pp.AccessKey = miConfig.AccessKey
  18697. pp.OpterName = curRoles.UserName
  18698. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18699. fmt.Println(requestLog)
  18700. fmt.Println(errMsgLog)
  18701. saveLog(result, requestLog, "4101a", "上传清单")
  18702. var dat map[string]interface{}
  18703. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18704. fmt.Println(dat)
  18705. } else {
  18706. fmt.Println(err)
  18707. }
  18708. userJSONBytes, _ := json.Marshal(dat)
  18709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18710. utils.ErrorLog("解析失败:%v", err)
  18711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18712. return
  18713. }
  18714. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18715. var pp models.PublicParams
  18716. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18717. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18718. pp.FixmedinsName = miConfig.OrgName
  18719. pp.FixmedinsCode = miConfig.Code
  18720. pp.RequestUrl = miConfig.Url
  18721. pp.Cainfo = miConfig.Cainfo
  18722. pp.SecretKey = miConfig.SecretKey
  18723. pp.AccessKey = miConfig.AccessKey
  18724. pp.OpterName = curRoles.UserName
  18725. client := &http.Client{}
  18726. var req *http.Request
  18727. data := make(map[string]interface{})
  18728. data["struct4101"] = struct4101
  18729. data["pp"] = pp
  18730. bytesData, _ := json.Marshal(data)
  18731. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18732. resp, _ := client.Do(req)
  18733. defer resp.Body.Close()
  18734. body, ioErr := ioutil.ReadAll(resp.Body)
  18735. if ioErr != nil {
  18736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18738. return
  18739. }
  18740. var respJSON map[string]interface{}
  18741. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18744. return
  18745. }
  18746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18747. userJSONBytes, _ := json.Marshal(respJSON)
  18748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18749. utils.ErrorLog("解析失败:%v", err)
  18750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18751. return
  18752. }
  18753. } else {
  18754. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18755. var dat map[string]interface{}
  18756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18757. fmt.Println(dat)
  18758. } else {
  18759. fmt.Println(err)
  18760. }
  18761. userJSONBytes, _ := json.Marshal(dat)
  18762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18763. utils.ErrorLog("解析失败:%v", err)
  18764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18765. return
  18766. }
  18767. }
  18768. if res.Infcode != 0 {
  18769. errlog := &models.HisOrderError{
  18770. UserOrgId: order.UserOrgId,
  18771. Ctime: time.Now().Unix(),
  18772. Mtime: time.Now().Unix(),
  18773. ErrMsg: res.ErrMsg + "解析失败",
  18774. Status: 1,
  18775. PatientId: order.ID,
  18776. Stage: 10485,
  18777. }
  18778. service.CreateErrMsgLog(errlog)
  18779. continue
  18780. //c.ServeSuccessJSON(map[string]interface{}{
  18781. // "failed_code": -10,
  18782. // "msg": res.ErrMsg,
  18783. //})
  18784. } else {
  18785. //order.FaPiaoNumber = zero
  18786. //order.FaPiaoCode = last_order.FaPiaoCode
  18787. //service.UpdateOrder(order)
  18788. hisFundSettleListResult := &models.HisFundSettleListResult{
  18789. Number: res.Output.SetlListId,
  18790. Status: 1,
  18791. Ctime: time.Now().Unix(),
  18792. Mtime: time.Now().Unix(),
  18793. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18794. IsUpload: 1,
  18795. OrderId: order.ID,
  18796. }
  18797. service.CreateUploadRecord(hisFundSettleListResult)
  18798. continue
  18799. }
  18800. }
  18801. }
  18802. func (c *HisApiController) GetSettleList() {
  18803. order_id, _ := c.GetInt64("order_id")
  18804. admin_user_id, _ := c.GetInt64("admin_user_id")
  18805. order, _ := service.GetHisOrderByIDTwo(order_id)
  18806. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18807. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18808. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18809. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18810. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18811. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18812. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18813. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18814. if order.ID == 0 {
  18815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18816. return
  18817. }
  18818. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18819. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18820. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18821. //fmt.Println(count)
  18822. //var zero string
  18823. //number := count + 1
  18824. //if number >= 1000 {
  18825. // zero = "0000" + strconv.FormatInt(number, 10)
  18826. //} else if number >= 10000 {
  18827. // zero = "000" + strconv.FormatInt(number, 10)
  18828. //} else if number >= 100000 {
  18829. // zero = "00" + strconv.FormatInt(number, 10)
  18830. //} else if number >= 1000000 {
  18831. // zero = "0" + strconv.FormatInt(number, 10)
  18832. //} else {
  18833. // zero = strconv.FormatInt(number, 10)
  18834. //}
  18835. //fmt.Println(zero)
  18836. struct4101 := service.Struct4101{
  18837. PsnNo: order.PsnNo,
  18838. MdtrtId: order.MdtrtId,
  18839. SetlId: order.SetlId,
  18840. PsnName: order.PsnName,
  18841. Gend: order.Gend,
  18842. Brdy: his.Brdy,
  18843. Age: his.Age,
  18844. Naty: order.Naty,
  18845. PatnCertType: "01",
  18846. Certno: order.Certno,
  18847. Prfs: "90",
  18848. ConerName: roles[0].UserName,
  18849. PatnRlts: "99",
  18850. ConerAddr: miConfig.OrgName,
  18851. ConerTel: admin.Mobile,
  18852. HiType: order.Insutype,
  18853. Insuplc: miConfig.InsuplcAdmdvs,
  18854. MaindiagFlag: "1",
  18855. BillCode: order.SetlId,
  18856. BillNo: order.SetlId,
  18857. BizSn: order.Number,
  18858. PsnSelfPay: order.PsnPartAmt,
  18859. PsnOwnPay: order.PsnPartAmt,
  18860. AcctPay: order.AcctPay,
  18861. PsnCashpay: order.PsnCashPay,
  18862. HiPaymtd: "1",
  18863. Hsorg: miConfig.InsuplcAdmdvs,
  18864. HsorgOpter: miConfig.InsuplcAdmdvs,
  18865. MedinsFillPsn: curRoles.UserName,
  18866. MedinsFillDept: miConfig.OrgName,
  18867. IptMedType: "2",
  18868. }
  18869. struct4101.SetlBegnDate = order.SetlTime
  18870. struct4101.SetlEndDate = order.SetlTime
  18871. time_arr := strings.Split(order.SetlTime, " ")
  18872. struct4101.AdmTime = time_arr[0]
  18873. struct4101.AdmEndTime = time_arr[0]
  18874. //
  18875. //var rf []CustomFundPay
  18876. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18877. //
  18878. //var tempFunPays []service.CustomStruct
  18879. //for _, item := range rf {
  18880. // var tempFunPay service.CustomStruct
  18881. // tempFunPay.FundPayamt = item.FundPayamt
  18882. // tempFunPay.FundPayType = item.FundPayType
  18883. // tempFunPays = append(tempFunPays, tempFunPay)
  18884. //}
  18885. //struct4101.CustomStruct = tempFunPays
  18886. var tempDiaginfos []service.DiaginfoStructTwo
  18887. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18888. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18889. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  18890. var config []*models.HisXtDiagnoseConfig
  18891. for _, item := range diagnosis_ids {
  18892. id, _ := strconv.ParseInt(item, 10, 64)
  18893. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18894. config = append(config, &diagnosisConfig)
  18895. }
  18896. if miConfig.Code == "H15049901371" {
  18897. //for _, item := range config {
  18898. // if item.ID == 138 {
  18899. diagnosisConfig, _ := service.FindDiagnoseById(138)
  18900. var tempDiaginfo service.DiaginfoStructTwo
  18901. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  18902. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  18903. tempDiaginfo.DiagType = "1"
  18904. tempDiaginfo.MaindiagFlag = "1"
  18905. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18906. //}
  18907. //}
  18908. for _, item := range config {
  18909. if item.ID != 138 {
  18910. var tempDiaginfo service.DiaginfoStructTwo
  18911. tempDiaginfo.DiagCode = item.CountryCode
  18912. tempDiaginfo.DiagName = item.CountryContentName
  18913. tempDiaginfo.DiagType = "1"
  18914. tempDiaginfo.MaindiagFlag = "0"
  18915. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18916. }
  18917. }
  18918. } else {
  18919. for index, item := range config {
  18920. if index == 0 {
  18921. var tempDiaginfo service.DiaginfoStructTwo
  18922. tempDiaginfo.DiagCode = item.CountryCode
  18923. tempDiaginfo.DiagName = item.CountryContentName
  18924. tempDiaginfo.DiagType = "1"
  18925. tempDiaginfo.MaindiagFlag = "1"
  18926. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18927. } else {
  18928. var tempDiaginfo service.DiaginfoStructTwo
  18929. tempDiaginfo.DiagCode = item.CountryCode
  18930. tempDiaginfo.DiagName = item.CountryContentName
  18931. tempDiaginfo.DiagType = "1"
  18932. tempDiaginfo.MaindiagFlag = "0"
  18933. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18934. }
  18935. }
  18936. }
  18937. struct4101.Diseinfo = tempDiaginfos
  18938. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18939. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18940. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18941. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18942. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18943. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18944. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18945. var iteminfo service.IteminfoStruct
  18946. var bedCostTotal float64 = 0 //床位总费
  18947. var bedCostSelfTotal float64 = 0 //床位自费
  18948. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18949. var operationCostTotal float64 = 0 //手术费
  18950. var operationCostSelfTotal float64 = 0 //手术费
  18951. var operationCostPartSelfTotal float64 = 0 //手术费
  18952. var otherCostTotal float64 = 0 //其他费用
  18953. var otherCostSelfTotal float64 = 0 //其他费用
  18954. var otherCostPartSelfTotal float64 = 0 //其他费用
  18955. var materialCostTotal float64 = 0 //材料费
  18956. var materialCostSelfTotal float64 = 0 //材料费
  18957. var materialCostPartSelfTotal float64 = 0 //材料费
  18958. var westernMedicineCostTotal float64 = 0 //西药费
  18959. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18960. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18961. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18962. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18963. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18964. var checkCostTotal float64 = 0 //检查费
  18965. var checkCostSelfTotal float64 = 0 //检查费
  18966. var checkCostPartSelfTotal float64 = 0 //检查费
  18967. var laboratoryCostTotal float64 = 0 //化验费
  18968. var laboratoryCostSelfTotal float64 = 0 //化验费
  18969. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18970. var treatCostTotal float64 = 0 //治疗费用
  18971. var treatCostSelfTotal float64 = 0 //治疗费用
  18972. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18973. decimal.DivisionPrecision = 2
  18974. var bed_fulamt_ownpay_amt float64 = 0
  18975. var operation_fulamt_ownpay_amt float64 = 0
  18976. var other_fulamt_ownpay_amt float64 = 0
  18977. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18978. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18979. var check_fulamt_ownpay_amt float64 = 0
  18980. var material_fulamt_ownpay_amt float64 = 0
  18981. var laboratory_fulamt_ownpay_amt float64 = 0
  18982. var treat_fulamt_ownpay_amt float64 = 0
  18983. var bed_claa_sunmfee float64 = 0
  18984. var bed_clab_amt float64 = 0
  18985. var bed_other_amt float64 = 0
  18986. var operation_claa_sunmfee float64 = 0
  18987. var operation_clab_amt float64 = 0
  18988. var operation_other_amt float64 = 0
  18989. var other_claa_sunmfee float64 = 0
  18990. var other_clab_amt float64 = 0
  18991. var other_other_amt float64 = 0
  18992. var westernMedicine_claa_sunmfee float64 = 0
  18993. var westernMedicine_clab_amt float64 = 0
  18994. var westernMedicine_other_amt float64 = 0
  18995. var chineseTraditional_claa_sunmfee float64 = 0
  18996. var chineseTraditional_clab_amt float64 = 0
  18997. var chineseTraditional_other_amt float64 = 0
  18998. var check_claa_sunmfee float64 = 0
  18999. var check_clab_amt float64 = 0
  19000. var check_other_amt float64 = 0
  19001. var material_claa_sunmfee float64 = 0
  19002. var material_clab_amt float64 = 0
  19003. var material_other_amt float64 = 0
  19004. var laboratory_claa_sunmfee float64 = 0
  19005. var laboratory_clab_amt float64 = 0
  19006. var laboratory_other_amt float64 = 0
  19007. var treat_claa_sunmfee float64 = 0
  19008. var treat_clab_amt float64 = 0
  19009. var treat_other_amt float64 = 0
  19010. for _, item := range order.HisOrderInfo {
  19011. if item.MedChrgitmType == "01" { //床位费
  19012. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19013. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19014. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19015. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19016. if item.ChrgitmLv == "1" {
  19017. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19018. }
  19019. if item.ChrgitmLv == "2" {
  19020. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19021. }
  19022. if item.ChrgitmLv == "3" {
  19023. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19024. }
  19025. }
  19026. if item.MedChrgitmType == "03" { //检查费
  19027. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19028. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19029. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19030. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19031. if item.ChrgitmLv == "1" {
  19032. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19033. }
  19034. if item.ChrgitmLv == "2" {
  19035. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19036. }
  19037. if item.ChrgitmLv == "3" {
  19038. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19039. }
  19040. }
  19041. if item.MedChrgitmType == "04" { //化验费
  19042. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19043. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19044. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19045. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19046. if item.ChrgitmLv == "1" {
  19047. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19048. }
  19049. if item.ChrgitmLv == "2" {
  19050. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19051. }
  19052. if item.ChrgitmLv == "3" {
  19053. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19054. }
  19055. }
  19056. if item.MedChrgitmType == "05" { //治疗费
  19057. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19058. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19059. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19060. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19061. if item.ChrgitmLv == "1" {
  19062. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19063. }
  19064. if item.ChrgitmLv == "2" {
  19065. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19066. }
  19067. if item.ChrgitmLv == "3" {
  19068. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19069. }
  19070. }
  19071. if item.MedChrgitmType == "06" { //手术费
  19072. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19073. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19074. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19075. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19076. if item.ChrgitmLv == "1" {
  19077. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19078. }
  19079. if item.ChrgitmLv == "2" {
  19080. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19081. }
  19082. if item.ChrgitmLv == "3" {
  19083. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19084. }
  19085. }
  19086. if item.MedChrgitmType == "08" { //材料费
  19087. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19088. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19089. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19090. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19091. if item.ChrgitmLv == "1" {
  19092. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19093. }
  19094. if item.ChrgitmLv == "2" {
  19095. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19096. }
  19097. if item.ChrgitmLv == "3" {
  19098. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19099. }
  19100. }
  19101. if item.MedChrgitmType == "09" { //西药费
  19102. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19103. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19104. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19105. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19106. if item.ChrgitmLv == "1" {
  19107. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19108. }
  19109. if item.ChrgitmLv == "2" {
  19110. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19111. }
  19112. if item.ChrgitmLv == "3" {
  19113. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19114. }
  19115. }
  19116. if item.MedChrgitmType == "11" { //中成费
  19117. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19118. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19119. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19120. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19121. if item.ChrgitmLv == "1" {
  19122. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19123. }
  19124. if item.ChrgitmLv == "2" {
  19125. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19126. }
  19127. if item.ChrgitmLv == "3" {
  19128. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19129. }
  19130. }
  19131. if item.MedChrgitmType == "14" { //其他费
  19132. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19133. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19134. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19135. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19136. if item.ChrgitmLv == "1" {
  19137. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19138. }
  19139. if item.ChrgitmLv == "2" {
  19140. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19141. }
  19142. if item.ChrgitmLv == "3" {
  19143. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19144. }
  19145. }
  19146. }
  19147. var iteminfoStructs []service.IteminfoStruct
  19148. if bedCostTotal != 0 {
  19149. iteminfo.MedChrgitm = "01"
  19150. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19151. iteminfo.Amt = bedCostTotal
  19152. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19153. iteminfo.ClabAmt = bed_clab_amt
  19154. iteminfo.OthAmt = bed_other_amt
  19155. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19156. }
  19157. if checkCostTotal != 0 {
  19158. iteminfo.MedChrgitm = "03"
  19159. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19160. iteminfo.Amt = checkCostTotal
  19161. iteminfo.ClaaSumfee = check_claa_sunmfee
  19162. iteminfo.ClabAmt = check_clab_amt
  19163. iteminfo.OthAmt = check_other_amt
  19164. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19165. }
  19166. if laboratoryCostTotal != 0 {
  19167. iteminfo.MedChrgitm = "04"
  19168. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19169. iteminfo.Amt = laboratoryCostTotal
  19170. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19171. iteminfo.ClabAmt = laboratory_clab_amt
  19172. iteminfo.OthAmt = laboratory_other_amt
  19173. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19174. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19175. }
  19176. if treatCostTotal != 0 {
  19177. iteminfo.MedChrgitm = "05"
  19178. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19179. iteminfo.Amt = treatCostTotal
  19180. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19181. iteminfo.ClabAmt = treat_clab_amt
  19182. iteminfo.OthAmt = treat_other_amt
  19183. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19184. //(struct4101.IteminfoStruct, iteminfo)
  19185. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19186. }
  19187. if operationCostTotal != 0 {
  19188. iteminfo.MedChrgitm = "06"
  19189. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19190. iteminfo.Amt = operationCostTotal
  19191. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19192. iteminfo.ClabAmt = operation_clab_amt
  19193. iteminfo.OthAmt = operation_other_amt
  19194. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19195. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19196. }
  19197. if materialCostTotal != 0 {
  19198. iteminfo.MedChrgitm = "08"
  19199. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19200. iteminfo.Amt = materialCostTotal
  19201. iteminfo.ClaaSumfee = material_claa_sunmfee
  19202. iteminfo.ClabAmt = material_clab_amt
  19203. iteminfo.OthAmt = material_other_amt
  19204. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19205. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19206. }
  19207. if westernMedicineCostTotal != 0 {
  19208. iteminfo.MedChrgitm = "09"
  19209. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19210. iteminfo.Amt = westernMedicineCostTotal
  19211. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19212. iteminfo.ClabAmt = westernMedicine_clab_amt
  19213. iteminfo.OthAmt = westernMedicine_other_amt
  19214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19215. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19216. }
  19217. if chineseTraditionalMedicineCostTotal != 0 {
  19218. iteminfo.MedChrgitm = "11"
  19219. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19220. iteminfo.Amt = westernMedicineCostTotal
  19221. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19222. iteminfo.ClabAmt = westernMedicine_clab_amt
  19223. iteminfo.OthAmt = westernMedicine_other_amt
  19224. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19225. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19226. }
  19227. if otherCostTotal != 0 {
  19228. iteminfo.MedChrgitm = "14"
  19229. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19230. iteminfo.Amt = otherCostTotal
  19231. iteminfo.ClaaSumfee = other_claa_sunmfee
  19232. iteminfo.ClabAmt = other_clab_amt
  19233. iteminfo.OthAmt = other_other_amt
  19234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19236. }
  19237. struct4101.IteminfoStruct = iteminfoStructs
  19238. struct4101.Ntly = "中国"
  19239. struct4101.AdmCaty = "A03.06"
  19240. struct4101.DoctorName = doctor.UserName
  19241. struct4101.DoctorCode = doctor.DoctorNumber
  19242. var res ResultSeventeen
  19243. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19244. struct4101.BillCode = order.Number
  19245. struct4101.BillNo = order.SetlId
  19246. var resOther ResultSeventeenOther
  19247. var pp models.PublicParams
  19248. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19249. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19250. pp.FixmedinsName = miConfig.OrgName
  19251. pp.FixmedinsCode = miConfig.Code
  19252. pp.RequestUrl = miConfig.Url
  19253. pp.Cainfo = miConfig.Cainfo
  19254. pp.SecretKey = miConfig.SecretKey
  19255. pp.AccessKey = miConfig.AccessKey
  19256. pp.OpterName = curRoles.UserName
  19257. client := &http.Client{}
  19258. var req *http.Request
  19259. data := make(map[string]interface{})
  19260. data["struct4101"] = struct4101
  19261. data["pp"] = pp
  19262. bytesData, _ := json.Marshal(data)
  19263. if miConfig.MdtrtareaAdmvs == "320921" {
  19264. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19265. } else {
  19266. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19267. }
  19268. resp, _ := client.Do(req)
  19269. defer resp.Body.Close()
  19270. body, ioErr := ioutil.ReadAll(resp.Body)
  19271. if ioErr != nil {
  19272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19274. return
  19275. }
  19276. var respJSON map[string]interface{}
  19277. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19280. return
  19281. }
  19282. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19283. userJSONBytes, _ := json.Marshal(respJSON)
  19284. fmt.Println("log")
  19285. fmt.Println(string(userJSONBytes))
  19286. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19287. utils.ErrorLog("解析失败:%v", err)
  19288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19289. return
  19290. }
  19291. res.InfRefmsgid = resOther.InfRefmsgid
  19292. res.Output = resOther.Output
  19293. res.ErrMsg = resOther.ErrMsg
  19294. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19295. res.Infcode = infocode
  19296. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19297. var pp models.PublicParams
  19298. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19299. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19300. pp.FixmedinsName = miConfig.OrgName
  19301. pp.FixmedinsCode = miConfig.Code
  19302. pp.RequestUrl = miConfig.Url
  19303. pp.Cainfo = miConfig.Cainfo
  19304. pp.SecretKey = miConfig.SecretKey
  19305. pp.AccessKey = miConfig.AccessKey
  19306. pp.OpterName = curRoles.UserName
  19307. result, _ := service.Jxyb4101(struct4101, pp)
  19308. var dat map[string]interface{}
  19309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19310. fmt.Println(dat)
  19311. } else {
  19312. fmt.Println(err)
  19313. }
  19314. userJSONBytes, _ := json.Marshal(dat)
  19315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19316. utils.ErrorLog("解析失败:%v", err)
  19317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19318. return
  19319. }
  19320. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19321. var pp models.PublicParams
  19322. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19323. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19324. pp.FixmedinsName = miConfig.OrgName
  19325. pp.FixmedinsCode = miConfig.Code
  19326. pp.RequestUrl = miConfig.Url
  19327. pp.Cainfo = miConfig.Cainfo
  19328. pp.SecretKey = miConfig.SecretKey
  19329. pp.AccessKey = miConfig.AccessKey
  19330. pp.OpterName = curRoles.UserName
  19331. result, _ := service.Jxyb4101(struct4101, pp)
  19332. var dat map[string]interface{}
  19333. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19334. fmt.Println(dat)
  19335. } else {
  19336. fmt.Println(err)
  19337. }
  19338. userJSONBytes, _ := json.Marshal(dat)
  19339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19340. utils.ErrorLog("解析失败:%v", err)
  19341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19342. return
  19343. }
  19344. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19345. var pp models.PublicParams
  19346. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19347. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19348. pp.FixmedinsName = miConfig.OrgName
  19349. pp.FixmedinsCode = miConfig.Code
  19350. pp.RequestUrl = miConfig.Url
  19351. pp.Cainfo = miConfig.Cainfo
  19352. pp.SecretKey = miConfig.SecretKey
  19353. pp.AccessKey = miConfig.AccessKey
  19354. pp.OpterName = curRoles.UserName
  19355. result, _ := service.Hnyb4101(struct4101, pp)
  19356. var dat map[string]interface{}
  19357. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19358. fmt.Println(dat)
  19359. } else {
  19360. fmt.Println(err)
  19361. }
  19362. userJSONBytes, _ := json.Marshal(dat)
  19363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19364. utils.ErrorLog("解析失败:%v", err)
  19365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19366. return
  19367. }
  19368. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19369. var resOther ResultSeventeenOther
  19370. var pp models.PublicParams
  19371. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19372. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19373. pp.FixmedinsName = miConfig.OrgName
  19374. pp.FixmedinsCode = miConfig.Code
  19375. pp.RequestUrl = miConfig.Url
  19376. pp.Cainfo = miConfig.Cainfo
  19377. pp.SecretKey = miConfig.SecretKey
  19378. pp.AccessKey = miConfig.AccessKey
  19379. pp.OpterName = curRoles.UserName
  19380. client := &http.Client{}
  19381. var req *http.Request
  19382. data := make(map[string]interface{})
  19383. data["struct4101"] = struct4101
  19384. data["pp"] = pp
  19385. bytesData, _ := json.Marshal(data)
  19386. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19387. resp, _ := client.Do(req)
  19388. defer resp.Body.Close()
  19389. body, ioErr := ioutil.ReadAll(resp.Body)
  19390. if ioErr != nil {
  19391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19393. return
  19394. }
  19395. var respJSON map[string]interface{}
  19396. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19399. return
  19400. }
  19401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19402. userJSONBytes, _ := json.Marshal(respJSON)
  19403. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19404. utils.ErrorLog("解析失败:%v", err)
  19405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19406. return
  19407. }
  19408. res.InfRefmsgid = resOther.InfRefmsgid
  19409. res.Output = resOther.Output
  19410. res.ErrMsg = resOther.ErrMsg
  19411. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19412. res.Infcode = infocode
  19413. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19414. var pp models.PublicParams
  19415. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19416. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19417. pp.FixmedinsName = miConfig.OrgName
  19418. pp.FixmedinsCode = miConfig.Code
  19419. pp.RequestUrl = miConfig.Url
  19420. pp.Cainfo = miConfig.Cainfo
  19421. pp.SecretKey = miConfig.SecretKey
  19422. pp.AccessKey = miConfig.AccessKey
  19423. pp.OpterName = curRoles.UserName
  19424. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19425. fmt.Println(requestLog)
  19426. fmt.Println(errMsgLog)
  19427. saveLog(result, requestLog, "4101a", "上传清单")
  19428. var dat map[string]interface{}
  19429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19430. fmt.Println(dat)
  19431. } else {
  19432. fmt.Println(err)
  19433. }
  19434. userJSONBytes, _ := json.Marshal(dat)
  19435. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19436. utils.ErrorLog("解析失败:%v", err)
  19437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19438. return
  19439. }
  19440. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19441. var pp models.PublicParams
  19442. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19443. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19444. pp.FixmedinsName = miConfig.OrgName
  19445. pp.FixmedinsCode = miConfig.Code
  19446. pp.RequestUrl = miConfig.Url
  19447. pp.Cainfo = miConfig.Cainfo
  19448. pp.SecretKey = miConfig.SecretKey
  19449. pp.AccessKey = miConfig.AccessKey
  19450. pp.OpterName = curRoles.UserName
  19451. client := &http.Client{}
  19452. var req *http.Request
  19453. data := make(map[string]interface{})
  19454. data["struct4101"] = struct4101
  19455. data["pp"] = pp
  19456. bytesData, _ := json.Marshal(data)
  19457. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19458. resp, _ := client.Do(req)
  19459. defer resp.Body.Close()
  19460. body, ioErr := ioutil.ReadAll(resp.Body)
  19461. if ioErr != nil {
  19462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19464. return
  19465. }
  19466. var respJSON map[string]interface{}
  19467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19470. return
  19471. }
  19472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19473. userJSONBytes, _ := json.Marshal(respJSON)
  19474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19475. utils.ErrorLog("解析失败:%v", err)
  19476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19477. return
  19478. }
  19479. } else {
  19480. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19481. var dat map[string]interface{}
  19482. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19483. fmt.Println(dat)
  19484. } else {
  19485. fmt.Println(err)
  19486. }
  19487. userJSONBytes, _ := json.Marshal(dat)
  19488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19489. utils.ErrorLog("解析失败:%v", err)
  19490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19491. return
  19492. }
  19493. }
  19494. if res.Infcode != 0 {
  19495. c.ServeSuccessJSON(map[string]interface{}{
  19496. "failed_code": -10,
  19497. "msg": res.ErrMsg,
  19498. })
  19499. return
  19500. } else {
  19501. //order.FaPiaoNumber = zero
  19502. //order.FaPiaoCode = last_order.FaPiaoCode
  19503. //service.UpdateOrder(order)
  19504. hisFundSettleListResult := &models.HisFundSettleListResult{
  19505. Number: res.Output.SetlListId,
  19506. Status: 1,
  19507. Ctime: time.Now().Unix(),
  19508. Mtime: time.Now().Unix(),
  19509. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19510. IsUpload: 1,
  19511. OrderId: order_id,
  19512. }
  19513. service.CreateUploadRecord(hisFundSettleListResult)
  19514. c.ServeSuccessJSON(map[string]interface{}{
  19515. "msg": "上传成功",
  19516. "result": hisFundSettleListResult,
  19517. })
  19518. return
  19519. }
  19520. }
  19521. func (c *HisApiController) GetSettleListHospital() {
  19522. order_id, _ := c.GetInt64("order_id")
  19523. admin_user_id, _ := c.GetInt64("admin_user_id")
  19524. order, _ := service.GetHisOrderByIDTwo(order_id)
  19525. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19526. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19527. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19528. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19529. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19531. if order.ID == 0 {
  19532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19533. return
  19534. }
  19535. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19536. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19537. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19538. fmt.Println(count)
  19539. var zero string
  19540. number := count + 1
  19541. if number >= 1000 {
  19542. zero = "0000" + strconv.FormatInt(number, 10)
  19543. } else if number >= 10000 {
  19544. zero = "000" + strconv.FormatInt(number, 10)
  19545. } else if number >= 100000 {
  19546. zero = "00" + strconv.FormatInt(number, 10)
  19547. } else if number >= 1000000 {
  19548. zero = "0" + strconv.FormatInt(number, 10)
  19549. } else {
  19550. zero = strconv.FormatInt(number, 10)
  19551. }
  19552. fmt.Println(zero)
  19553. struct4101 := service.Struct4101{
  19554. PsnNo: order.PsnNo,
  19555. MdtrtId: order.MdtrtId,
  19556. SetlId: order.SetlId,
  19557. PsnName: order.PsnName,
  19558. Gend: order.Gend,
  19559. Brdy: his.Brdy,
  19560. Age: int64(order.Age),
  19561. Naty: order.Naty,
  19562. PatnCertType: "01",
  19563. Certno: order.Certno,
  19564. Prfs: "90",
  19565. ConerName: roles[0].UserName,
  19566. PatnRlts: "99",
  19567. ConerAddr: miConfig.OrgName,
  19568. ConerTel: admin.Mobile,
  19569. HiType: order.Insutype,
  19570. Insuplc: miConfig.InsuplcAdmdvs,
  19571. MaindiagFlag: "1",
  19572. BillCode: order.SetlId,
  19573. BillNo: order.SetlId,
  19574. BizSn: order.Number,
  19575. PsnSelfPay: order.PsnPartAmt,
  19576. PsnOwnPay: order.PsnPartAmt,
  19577. AcctPay: order.AcctPay,
  19578. PsnCashpay: order.PsnCashPay,
  19579. HiPaymtd: "1",
  19580. Hsorg: miConfig.InsuplcAdmdvs,
  19581. HsorgOpter: miConfig.InsuplcAdmdvs,
  19582. MedinsFillPsn: curRoles.UserName,
  19583. MedinsFillDept: depart.Name,
  19584. IptMedType: "2",
  19585. AdmTime: his.InHosptialTime,
  19586. AdmEndTime: his.OutHosptialTime,
  19587. }
  19588. struct4101.SetlBegnDate = order.SetlTime
  19589. struct4101.SetlEndDate = order.SetlTime
  19590. //var rf []CustomFundPay
  19591. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19592. //
  19593. //var tempFunPays []service.CustomStruct
  19594. //for _, item := range rf {
  19595. // var tempFunPay service.CustomStruct
  19596. // tempFunPay.FundPayamt = item.FundPayamt
  19597. // tempFunPay.FundPayType = item.FundPayType
  19598. // tempFunPays = append(tempFunPays, tempFunPay)
  19599. //}
  19600. //struct4101.CustomStruct = tempFunPays
  19601. var tempDiaginfos []service.DiaginfoStructTwo
  19602. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19603. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19604. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19605. //for _, item := range infos {
  19606. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19607. //}
  19608. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19609. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19610. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19611. fmt.Println(diagnosis_ids_arr)
  19612. if order.UserOrgId == 10210 {
  19613. var diagnosis_ids_arr_two []int64
  19614. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19615. var config []*models.HisXtDiagnoseConfig
  19616. for _, id := range diagnosis_ids_arr_two {
  19617. //id, _ := strconv.ParseInt(item, 10, 64)
  19618. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19619. if diagnosisConfig.ID > 0 {
  19620. config = append(config, &diagnosisConfig)
  19621. }
  19622. }
  19623. for index, item := range config {
  19624. if item.ID > 0 {
  19625. if index == 0 {
  19626. var tempDiaginfo service.DiaginfoStructTwo
  19627. tempDiaginfo.DiagCode = item.CountryCode
  19628. tempDiaginfo.DiagName = item.CountryContentName
  19629. tempDiaginfo.DiagType = "1"
  19630. tempDiaginfo.MaindiagFlag = "1"
  19631. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19632. } else {
  19633. var tempDiaginfo service.DiaginfoStructTwo
  19634. tempDiaginfo.DiagCode = item.CountryCode
  19635. tempDiaginfo.DiagName = item.CountryContentName
  19636. tempDiaginfo.DiagType = "1"
  19637. tempDiaginfo.MaindiagFlag = "0"
  19638. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19639. }
  19640. }
  19641. }
  19642. struct4101.Diseinfo = tempDiaginfos
  19643. } else {
  19644. var config []*models.HisXtDiagnoseConfig
  19645. for _, item := range diagnosis_ids_arr {
  19646. id, _ := strconv.ParseInt(item, 10, 64)
  19647. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19648. if diagnosisConfig.ID > 0 {
  19649. config = append(config, &diagnosisConfig)
  19650. }
  19651. }
  19652. for index, item := range config {
  19653. if item.ID > 0 {
  19654. if index == 0 {
  19655. var tempDiaginfo service.DiaginfoStructTwo
  19656. tempDiaginfo.DiagCode = item.CountryCode
  19657. tempDiaginfo.DiagName = item.CountryContentName
  19658. tempDiaginfo.DiagType = "1"
  19659. tempDiaginfo.MaindiagFlag = "1"
  19660. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19661. } else {
  19662. var tempDiaginfo service.DiaginfoStructTwo
  19663. tempDiaginfo.DiagCode = item.CountryCode
  19664. tempDiaginfo.DiagName = item.CountryContentName
  19665. tempDiaginfo.DiagType = "1"
  19666. tempDiaginfo.MaindiagFlag = "0"
  19667. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19668. }
  19669. }
  19670. }
  19671. struct4101.Diseinfo = tempDiaginfos
  19672. }
  19673. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19674. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19675. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19676. tempOpspdiseinfo2.OprnOprtCode = ""
  19677. tempOpspdiseinfo2.OprnOprtName = ""
  19678. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19679. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19680. var iteminfo service.IteminfoStruct
  19681. var bedCostTotal float64 = 0 //床位总费
  19682. var bedCostSelfTotal float64 = 0 //床位自费
  19683. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19684. var operationCostTotal float64 = 0 //手术费
  19685. var operationCostSelfTotal float64 = 0 //手术费
  19686. var operationCostPartSelfTotal float64 = 0 //手术费
  19687. var otherCostTotal float64 = 0 //其他费用
  19688. var otherCostSelfTotal float64 = 0 //其他费用
  19689. var otherCostPartSelfTotal float64 = 0 //其他费用
  19690. var materialCostTotal float64 = 0 //材料费
  19691. var materialCostSelfTotal float64 = 0 //材料费
  19692. var materialCostPartSelfTotal float64 = 0 //材料费
  19693. var westernMedicineCostTotal float64 = 0 //西药费
  19694. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19695. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19696. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19697. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19698. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19699. var checkCostTotal float64 = 0 //检查费
  19700. var checkCostSelfTotal float64 = 0 //检查费
  19701. var checkCostPartSelfTotal float64 = 0 //检查费
  19702. var laboratoryCostTotal float64 = 0 //化验费
  19703. var laboratoryCostSelfTotal float64 = 0 //化验费
  19704. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19705. var treatCostTotal float64 = 0 //治疗费用
  19706. var treatCostSelfTotal float64 = 0 //治疗费用
  19707. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19708. decimal.DivisionPrecision = 2
  19709. var bed_fulamt_ownpay_amt float64 = 0
  19710. var operation_fulamt_ownpay_amt float64 = 0
  19711. var other_fulamt_ownpay_amt float64 = 0
  19712. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19713. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19714. var check_fulamt_ownpay_amt float64 = 0
  19715. var material_fulamt_ownpay_amt float64 = 0
  19716. var laboratory_fulamt_ownpay_amt float64 = 0
  19717. var treat_fulamt_ownpay_amt float64 = 0
  19718. var bed_claa_sunmfee float64 = 0
  19719. var bed_clab_amt float64 = 0
  19720. var bed_other_amt float64 = 0
  19721. var operation_claa_sunmfee float64 = 0
  19722. var operation_clab_amt float64 = 0
  19723. var operation_other_amt float64 = 0
  19724. var other_claa_sunmfee float64 = 0
  19725. var other_clab_amt float64 = 0
  19726. var other_other_amt float64 = 0
  19727. var westernMedicine_claa_sunmfee float64 = 0
  19728. var westernMedicine_clab_amt float64 = 0
  19729. var westernMedicine_other_amt float64 = 0
  19730. var chineseTraditional_claa_sunmfee float64 = 0
  19731. var chineseTraditional_clab_amt float64 = 0
  19732. var chineseTraditional_other_amt float64 = 0
  19733. var check_claa_sunmfee float64 = 0
  19734. var check_clab_amt float64 = 0
  19735. var check_other_amt float64 = 0
  19736. var material_claa_sunmfee float64 = 0
  19737. var material_clab_amt float64 = 0
  19738. var material_other_amt float64 = 0
  19739. var laboratory_claa_sunmfee float64 = 0
  19740. var laboratory_clab_amt float64 = 0
  19741. var laboratory_other_amt float64 = 0
  19742. var treat_claa_sunmfee float64 = 0
  19743. var treat_clab_amt float64 = 0
  19744. var treat_other_amt float64 = 0
  19745. for _, item := range order.HisOrderInfo {
  19746. if item.MedChrgitmType == "01" { //床位费
  19747. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19748. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19749. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19750. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19751. if item.ChrgitmLv == "1" {
  19752. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19753. }
  19754. if item.ChrgitmLv == "2" {
  19755. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19756. }
  19757. if item.ChrgitmLv == "3" {
  19758. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19759. }
  19760. }
  19761. if item.MedChrgitmType == "03" { //检查费
  19762. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19763. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19764. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19765. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19766. if item.ChrgitmLv == "1" {
  19767. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19768. }
  19769. if item.ChrgitmLv == "2" {
  19770. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19771. }
  19772. if item.ChrgitmLv == "3" {
  19773. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19774. }
  19775. }
  19776. if item.MedChrgitmType == "04" { //化验费
  19777. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19778. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19779. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19780. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19781. if item.ChrgitmLv == "1" {
  19782. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19783. }
  19784. if item.ChrgitmLv == "2" {
  19785. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19786. }
  19787. if item.ChrgitmLv == "3" {
  19788. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19789. }
  19790. }
  19791. if item.MedChrgitmType == "05" { //治疗费
  19792. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19793. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19794. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19795. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19796. if item.ChrgitmLv == "1" {
  19797. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19798. }
  19799. if item.ChrgitmLv == "2" {
  19800. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19801. }
  19802. if item.ChrgitmLv == "3" {
  19803. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19804. }
  19805. }
  19806. if item.MedChrgitmType == "06" { //手术费
  19807. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19808. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19809. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19810. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19811. if item.ChrgitmLv == "1" {
  19812. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19813. }
  19814. if item.ChrgitmLv == "2" {
  19815. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19816. }
  19817. if item.ChrgitmLv == "3" {
  19818. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19819. }
  19820. }
  19821. if item.MedChrgitmType == "08" { //材料费
  19822. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19823. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19824. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19825. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19826. if item.ChrgitmLv == "1" {
  19827. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19828. }
  19829. if item.ChrgitmLv == "2" {
  19830. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19831. }
  19832. if item.ChrgitmLv == "3" {
  19833. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19834. }
  19835. }
  19836. if item.MedChrgitmType == "09" { //西药费
  19837. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19838. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19839. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19840. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19841. if item.ChrgitmLv == "1" {
  19842. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19843. }
  19844. if item.ChrgitmLv == "2" {
  19845. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19846. }
  19847. if item.ChrgitmLv == "3" {
  19848. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19849. }
  19850. }
  19851. if item.MedChrgitmType == "11" { //中成费
  19852. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19853. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19854. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19855. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19856. if item.ChrgitmLv == "1" {
  19857. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19858. }
  19859. if item.ChrgitmLv == "2" {
  19860. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19861. }
  19862. if item.ChrgitmLv == "3" {
  19863. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19864. }
  19865. }
  19866. if item.MedChrgitmType == "14" { //其他费
  19867. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19868. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19869. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19870. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19871. if item.ChrgitmLv == "1" {
  19872. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19873. }
  19874. if item.ChrgitmLv == "2" {
  19875. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19876. }
  19877. if item.ChrgitmLv == "3" {
  19878. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19879. }
  19880. }
  19881. }
  19882. var iteminfoStructs []service.IteminfoStruct
  19883. if bedCostTotal != 0 {
  19884. iteminfo.MedChrgitm = "01"
  19885. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19886. iteminfo.Amt = bedCostTotal
  19887. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19888. iteminfo.ClabAmt = bed_clab_amt
  19889. iteminfo.OthAmt = bed_other_amt
  19890. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19891. }
  19892. if checkCostTotal != 0 {
  19893. iteminfo.MedChrgitm = "03"
  19894. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19895. iteminfo.Amt = checkCostTotal
  19896. iteminfo.ClaaSumfee = check_claa_sunmfee
  19897. iteminfo.ClabAmt = check_clab_amt
  19898. iteminfo.OthAmt = check_other_amt
  19899. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19900. }
  19901. if laboratoryCostTotal != 0 {
  19902. iteminfo.MedChrgitm = "04"
  19903. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19904. iteminfo.Amt = laboratoryCostTotal
  19905. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19906. iteminfo.ClabAmt = laboratory_clab_amt
  19907. iteminfo.OthAmt = laboratory_other_amt
  19908. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19909. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19910. }
  19911. if treatCostTotal != 0 {
  19912. iteminfo.MedChrgitm = "05"
  19913. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19914. iteminfo.Amt = treatCostTotal
  19915. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19916. iteminfo.ClabAmt = treat_clab_amt
  19917. iteminfo.OthAmt = treat_other_amt
  19918. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19919. //(struct4101.IteminfoStruct, iteminfo)
  19920. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19921. }
  19922. if operationCostTotal != 0 {
  19923. iteminfo.MedChrgitm = "06"
  19924. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19925. iteminfo.Amt = operationCostTotal
  19926. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19927. iteminfo.ClabAmt = operation_clab_amt
  19928. iteminfo.OthAmt = operation_other_amt
  19929. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19930. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19931. }
  19932. if materialCostTotal != 0 {
  19933. iteminfo.MedChrgitm = "08"
  19934. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19935. iteminfo.Amt = materialCostTotal
  19936. iteminfo.ClaaSumfee = material_claa_sunmfee
  19937. iteminfo.ClabAmt = material_clab_amt
  19938. iteminfo.OthAmt = material_other_amt
  19939. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19940. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19941. }
  19942. if westernMedicineCostTotal != 0 {
  19943. iteminfo.MedChrgitm = "09"
  19944. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19945. iteminfo.Amt = westernMedicineCostTotal
  19946. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19947. iteminfo.ClabAmt = westernMedicine_clab_amt
  19948. iteminfo.OthAmt = westernMedicine_other_amt
  19949. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19950. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19951. }
  19952. if chineseTraditionalMedicineCostTotal != 0 {
  19953. iteminfo.MedChrgitm = "11"
  19954. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19955. iteminfo.Amt = westernMedicineCostTotal
  19956. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19957. iteminfo.ClabAmt = westernMedicine_clab_amt
  19958. iteminfo.OthAmt = westernMedicine_other_amt
  19959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19960. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19961. }
  19962. if otherCostTotal != 0 {
  19963. iteminfo.MedChrgitm = "14"
  19964. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19965. iteminfo.Amt = otherCostTotal
  19966. iteminfo.ClaaSumfee = other_claa_sunmfee
  19967. iteminfo.ClabAmt = other_clab_amt
  19968. iteminfo.OthAmt = other_other_amt
  19969. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19970. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19971. }
  19972. struct4101.IteminfoStruct = iteminfoStructs
  19973. struct4101.Ntly = "中国"
  19974. struct4101.AdmCaty = "A03.06"
  19975. var resOther ResultSeventeenOther
  19976. var res ResultSeventeen
  19977. if miConfig.MdtrtareaAdmvs == "150499" {
  19978. var pp models.PublicParams
  19979. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19980. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19981. pp.FixmedinsName = miConfig.OrgName
  19982. pp.FixmedinsCode = miConfig.Code
  19983. pp.RequestUrl = miConfig.Url
  19984. pp.Cainfo = miConfig.Cainfo
  19985. pp.SecretKey = miConfig.SecretKey
  19986. pp.AccessKey = miConfig.AccessKey
  19987. pp.OpterName = curRoles.UserName
  19988. client := &http.Client{}
  19989. var req *http.Request
  19990. data := make(map[string]interface{})
  19991. data["struct4101"] = struct4101
  19992. data["pp"] = pp
  19993. bytesData, _ := json.Marshal(data)
  19994. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19995. resp, _ := client.Do(req)
  19996. defer resp.Body.Close()
  19997. body, ioErr := ioutil.ReadAll(resp.Body)
  19998. if ioErr != nil {
  19999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20001. return
  20002. }
  20003. var respJSON map[string]interface{}
  20004. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20007. return
  20008. }
  20009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20010. userJSONBytes, _ := json.Marshal(respJSON)
  20011. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20012. utils.ErrorLog("解析失败:%v", err)
  20013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20014. return
  20015. }
  20016. res.InfRefmsgid = resOther.InfRefmsgid
  20017. res.Output = resOther.Output
  20018. res.ErrMsg = resOther.ErrMsg
  20019. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20020. res.Infcode = infocode
  20021. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20022. var pp models.PublicParams
  20023. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20024. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20025. pp.FixmedinsName = miConfig.OrgName
  20026. pp.FixmedinsCode = miConfig.Code
  20027. pp.RequestUrl = miConfig.Url
  20028. pp.Cainfo = miConfig.Cainfo
  20029. pp.SecretKey = miConfig.SecretKey
  20030. pp.AccessKey = miConfig.AccessKey
  20031. pp.OpterName = curRoles.UserName
  20032. result, _ := service.Jxyb4101(struct4101, pp)
  20033. var dat map[string]interface{}
  20034. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20035. fmt.Println(dat)
  20036. } else {
  20037. fmt.Println(err)
  20038. }
  20039. userJSONBytes, _ := json.Marshal(dat)
  20040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20041. utils.ErrorLog("解析失败:%v", err)
  20042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20043. return
  20044. }
  20045. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20046. var pp models.PublicParams
  20047. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20048. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20049. pp.FixmedinsName = miConfig.OrgName
  20050. pp.FixmedinsCode = miConfig.Code
  20051. pp.RequestUrl = miConfig.Url
  20052. pp.Cainfo = miConfig.Cainfo
  20053. pp.SecretKey = miConfig.SecretKey
  20054. pp.AccessKey = miConfig.AccessKey
  20055. pp.OpterName = curRoles.UserName
  20056. result, _ := service.Jxyb4101(struct4101, pp)
  20057. var dat map[string]interface{}
  20058. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20059. fmt.Println(dat)
  20060. } else {
  20061. fmt.Println(err)
  20062. }
  20063. userJSONBytes, _ := json.Marshal(dat)
  20064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20065. utils.ErrorLog("解析失败:%v", err)
  20066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20067. return
  20068. }
  20069. } else {
  20070. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20071. var dat map[string]interface{}
  20072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20073. fmt.Println(dat)
  20074. } else {
  20075. fmt.Println(err)
  20076. }
  20077. userJSONBytes, _ := json.Marshal(dat)
  20078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20079. utils.ErrorLog("解析失败:%v", err)
  20080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20081. return
  20082. }
  20083. }
  20084. if res.Infcode != 0 {
  20085. c.ServeSuccessJSON(map[string]interface{}{
  20086. "failed_code": -10,
  20087. "msg": res.ErrMsg,
  20088. })
  20089. return
  20090. } else {
  20091. if miConfig.MdtrtareaAdmvs != "150499" {
  20092. order.FaPiaoNumber = zero
  20093. order.FaPiaoCode = last_order.FaPiaoCode
  20094. service.UpdateOrder(order)
  20095. }
  20096. hisFundSettleListResult := &models.HisFundSettleListResult{
  20097. Number: res.Output.SetlListId,
  20098. Status: 1,
  20099. Ctime: time.Now().Unix(),
  20100. Mtime: time.Now().Unix(),
  20101. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20102. IsUpload: 1,
  20103. OrderId: order_id,
  20104. }
  20105. service.CreateUploadRecord(hisFundSettleListResult)
  20106. c.ServeSuccessJSON(map[string]interface{}{
  20107. "msg": "上传成功",
  20108. "result": hisFundSettleListResult,
  20109. })
  20110. return
  20111. }
  20112. }
  20113. //func (c *HisApiController) GetBatchSettleList() {
  20114. // orders, _ := service.GetAllHisOrder(10106)
  20115. // for _, item := range orders {
  20116. // order_id := item.ID
  20117. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20118. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20119. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20120. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20121. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20122. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20123. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20124. //
  20125. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20126. //
  20127. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20128. //
  20129. // if order.ID == 0 {
  20130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20131. // return
  20132. // }
  20133. // if his.BalanceAccountsType == 2 {
  20134. // continue
  20135. // }
  20136. // struct4101 := service.Struct4101{
  20137. // PsnNo: order.PsnNo,
  20138. // MdtrtId: order.MdtrtId,
  20139. // SetlId: order.SetlId,
  20140. // PsnName: order.PsnName,
  20141. // Gend: order.Gend,
  20142. // Brdy: his.Brdy,
  20143. // Age: his.Age,
  20144. // Naty: order.Naty,
  20145. // PatnCertType: "01",
  20146. // Certno: order.Certno,
  20147. // Prfs: "90",
  20148. // ConerName: roles[0].UserName,
  20149. // PatnRlts: "99",
  20150. // ConerAddr: miConfig.OrgName,
  20151. // ConerTel: admin.Mobile,
  20152. // HiType: order.Insutype,
  20153. // Insuplc: his.InsuplcAdmdvs,
  20154. // MaindiagFlag: "1",
  20155. // BillCode: order.SetlId,
  20156. // BillNo: order.SetlId,
  20157. // BizSn: order.Number,
  20158. // PsnSelfPay: order.PsnPartAmt,
  20159. // PsnOwnPay: order.PsnPartAmt,
  20160. // AcctPay: order.AcctPay,
  20161. // PsnCashpay: order.PsnCashPay,
  20162. // HiPaymtd: "1",
  20163. // Hsorg: his.InsuplcAdmdvs,
  20164. // HsorgOpter: his.InsuplcAdmdvs,
  20165. // MedinsFillPsn: curRoles.UserName,
  20166. // MedinsFillDept: depart.Name,
  20167. // IptMedType: "2",
  20168. // }
  20169. // struct4101.SetlBegnDate = order.SetlTime
  20170. // struct4101.SetlEndDate = order.SetlTime
  20171. // //if order.SettleType == 1 {
  20172. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20173. // // dateStr := t.Format("2006-01-02")
  20174. // // struct4101.SetlBegnDate = dateStr
  20175. // // struct4101.SetlEndDate = dateStr
  20176. // //} else {
  20177. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20178. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20179. // // dateStartStr := t.Format("2006-01-02")
  20180. // // dateEndStr := t2.Format("2006-01-02")
  20181. // // struct4101.SetlBegnDate = dateStartStr
  20182. // // struct4101.SetlEndDate = dateEndStr
  20183. // //}
  20184. //
  20185. // var rf []CustomFundPay
  20186. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20187. //
  20188. // var tempFunPays []service.CustomStruct
  20189. // var tempFunPay610100 service.CustomStruct
  20190. //
  20191. // for _, item := range rf {
  20192. // if item.FundPayType == "610100" {
  20193. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20194. // tempFunPay610100.FundPayType = item.FundPayType
  20195. // } else {
  20196. // var tempFunPay service.CustomStruct
  20197. // tempFunPay.FundPayamt = item.FundPayamt
  20198. // tempFunPay.FundPayType = item.FundPayType
  20199. // tempFunPays = append(tempFunPays, tempFunPay)
  20200. // }
  20201. // }
  20202. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20203. // struct4101.CustomStruct = tempFunPays
  20204. //
  20205. // var tempDiaginfos []service.DiaginfoStructTwo
  20206. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20207. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20208. //
  20209. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20210. // var config []*models.HisXtDiagnoseConfig
  20211. // for _, item := range diagnosis_ids {
  20212. // id, _ := strconv.ParseInt(item, 10, 64)
  20213. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20214. // config = append(config, &diagnosisConfig)
  20215. // }
  20216. //
  20217. // for index, item := range config {
  20218. // if index == 0 {
  20219. // var tempDiaginfo service.DiaginfoStructTwo
  20220. // tempDiaginfo.DiagCode = item.CountryCode
  20221. // tempDiaginfo.DiagName = item.CountryContentName
  20222. // tempDiaginfo.DiagType = "1"
  20223. // tempDiaginfo.MaindiagFlag = "1"
  20224. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20225. // } else {
  20226. //
  20227. // var tempDiaginfo service.DiaginfoStructTwo
  20228. // tempDiaginfo.DiagCode = item.CountryCode
  20229. // tempDiaginfo.DiagName = item.CountryContentName
  20230. // tempDiaginfo.DiagType = "2"
  20231. // tempDiaginfo.MaindiagFlag = "0"
  20232. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20233. // }
  20234. // }
  20235. // struct4101.Diseinfo = tempDiaginfos
  20236. //
  20237. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20238. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20239. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20240. // tempOpspdiseinfo2.OprnOprtCode = ""
  20241. // tempOpspdiseinfo2.OprnOprtName = ""
  20242. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20243. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20244. //
  20245. // var iteminfo service.IteminfoStruct
  20246. //
  20247. // var bedCostTotal float64 = 0 //床位总费
  20248. // var bedCostSelfTotal float64 = 0 //床位自费
  20249. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20250. //
  20251. // var examineCostTotal float64 = 0 //诊查总费
  20252. // var examineCostSelfTotal float64 = 0 //诊查自费
  20253. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20254. //
  20255. // var nursingCostTotal float64 = 0 //护理总费
  20256. // var nursingCostSelfTotal float64 = 0 //护理自费
  20257. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20258. //
  20259. // var chineseMedicineCostTotal float64 = 0 //中成药
  20260. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20261. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20262. //
  20263. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20264. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20265. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20266. //
  20267. // var registerCostTotal float64 = 0 //一般诊疗费
  20268. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20269. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20270. //
  20271. // var operationCostTotal float64 = 0 //手术费
  20272. // var operationCostSelfTotal float64 = 0 //手术费
  20273. // var operationCostPartSelfTotal float64 = 0 //手术费
  20274. //
  20275. // var otherCostTotal float64 = 0 //其他费用
  20276. // var otherCostSelfTotal float64 = 0 //其他费用
  20277. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20278. //
  20279. // var materialCostTotal float64 = 0 //材料费
  20280. // var materialCostSelfTotal float64 = 0 //材料费
  20281. // var materialCostPartSelfTotal float64 = 0 //材料费
  20282. //
  20283. // var westernMedicineCostTotal float64 = 0 //西药费
  20284. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20285. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20286. //
  20287. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20288. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20289. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20290. //
  20291. // var checkCostTotal float64 = 0 //检查费
  20292. // var checkCostSelfTotal float64 = 0 //检查费
  20293. // var checkCostPartSelfTotal float64 = 0 //检查费
  20294. //
  20295. // var laboratoryCostTotal float64 = 0 //化验费
  20296. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20297. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20298. //
  20299. // var treatCostTotal float64 = 0 //治疗费用
  20300. // var treatCostSelfTotal float64 = 0 //治疗费用
  20301. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20302. //
  20303. // decimal.DivisionPrecision = 2
  20304. //
  20305. // var bed_fulamt_ownpay_amt float64 = 0
  20306. //
  20307. // var examine_fulamt_ownpay_amt float64 = 0
  20308. //
  20309. // var nursing_fulamt_ownpay_amt float64 = 0
  20310. //
  20311. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20312. //
  20313. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20314. //
  20315. // var register_fulamt_ownpay_amt float64 = 0
  20316. //
  20317. // var operation_fulamt_ownpay_amt float64 = 0
  20318. // var other_fulamt_ownpay_amt float64 = 0
  20319. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20320. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20321. // var check_fulamt_ownpay_amt float64 = 0
  20322. // var material_fulamt_ownpay_amt float64 = 0
  20323. // var laboratory_fulamt_ownpay_amt float64 = 0
  20324. // var treat_fulamt_ownpay_amt float64 = 0
  20325. //
  20326. // var bed_claa_sunmfee float64 = 0
  20327. // var bed_clab_amt float64 = 0
  20328. // var bed_other_amt float64 = 0
  20329. //
  20330. // var examine_claa_sunmfee float64 = 0
  20331. // var examine_clab_amt float64 = 0
  20332. // var examine_other_amt float64 = 0
  20333. //
  20334. // var nursing_claa_sunmfee float64 = 0
  20335. // var nursing_clab_amt float64 = 0
  20336. // var nursing_other_amt float64 = 0
  20337. //
  20338. // var chinese_medicine_claa_sunmfee float64 = 0
  20339. // var chinese_medicine_clab_amt float64 = 0
  20340. // var chinese_medicine_other_amt float64 = 0
  20341. //
  20342. // var commonly_treatment_claa_sunmfee float64 = 0
  20343. // var commonly_treatment_clab_amt float64 = 0
  20344. // var commonly_treatment_other_amt float64 = 0
  20345. //
  20346. // var operation_claa_sunmfee float64 = 0
  20347. // var operation_clab_amt float64 = 0
  20348. // var operation_other_amt float64 = 0
  20349. //
  20350. // var other_claa_sunmfee float64 = 0
  20351. // var other_clab_amt float64 = 0
  20352. // var other_other_amt float64 = 0
  20353. //
  20354. // var westernMedicine_claa_sunmfee float64 = 0
  20355. // var westernMedicine_clab_amt float64 = 0
  20356. // var westernMedicine_other_amt float64 = 0
  20357. //
  20358. // var chineseTraditional_claa_sunmfee float64 = 0
  20359. // var chineseTraditional_clab_amt float64 = 0
  20360. // var chineseTraditional_other_amt float64 = 0
  20361. //
  20362. // var check_claa_sunmfee float64 = 0
  20363. // var check_clab_amt float64 = 0
  20364. // var check_other_amt float64 = 0
  20365. //
  20366. // var material_claa_sunmfee float64 = 0
  20367. // var material_clab_amt float64 = 0
  20368. // var material_other_amt float64 = 0
  20369. //
  20370. // var laboratory_claa_sunmfee float64 = 0
  20371. // var laboratory_clab_amt float64 = 0
  20372. // var laboratory_other_amt float64 = 0
  20373. //
  20374. // var treat_claa_sunmfee float64 = 0
  20375. // var treat_clab_amt float64 = 0
  20376. // var treat_other_amt float64 = 0
  20377. //
  20378. // var register_claa_sunmfee float64 = 0
  20379. // var register_clab_amt float64 = 0
  20380. // var register_other_amt float64 = 0
  20381. //
  20382. // for _, item := range order.HisOrderInfo {
  20383. // if item.MedChrgitmType == "01" { //床位费
  20384. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20385. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20386. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20387. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20388. // if item.ChrgitmLv == "1" {
  20389. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20390. // }
  20391. // if item.ChrgitmLv == "2" {
  20392. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20393. //
  20394. // }
  20395. // if item.ChrgitmLv == "3" {
  20396. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20397. // }
  20398. //
  20399. // }
  20400. //
  20401. // if item.MedChrgitmType == "02" { //诊查
  20402. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20403. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20404. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20405. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20406. // if item.ChrgitmLv == "1" {
  20407. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20408. // }
  20409. // if item.ChrgitmLv == "2" {
  20410. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20411. //
  20412. // }
  20413. // if item.ChrgitmLv == "3" {
  20414. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20415. // }
  20416. //
  20417. // }
  20418. //
  20419. // if item.MedChrgitmType == "03" { //检查费
  20420. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20421. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20422. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20423. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20424. // if item.ChrgitmLv == "1" {
  20425. //
  20426. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20427. //
  20428. // }
  20429. // if item.ChrgitmLv == "2" {
  20430. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20431. //
  20432. // }
  20433. // if item.ChrgitmLv == "3" {
  20434. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20435. // }
  20436. // }
  20437. //
  20438. // if item.MedChrgitmType == "04" { //化验费
  20439. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20440. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20441. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20442. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20443. // if item.ChrgitmLv == "1" {
  20444. //
  20445. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20446. //
  20447. // }
  20448. // if item.ChrgitmLv == "2" {
  20449. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20450. //
  20451. // }
  20452. // if item.ChrgitmLv == "3" {
  20453. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20454. // }
  20455. // }
  20456. //
  20457. // if item.MedChrgitmType == "05" { //治疗费
  20458. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20459. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20460. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20461. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20462. // if item.ChrgitmLv == "1" {
  20463. //
  20464. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20465. //
  20466. // }
  20467. // if item.ChrgitmLv == "2" {
  20468. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20469. //
  20470. // }
  20471. // if item.ChrgitmLv == "3" {
  20472. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20473. // }
  20474. // }
  20475. //
  20476. // if item.MedChrgitmType == "06" { //手术费
  20477. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20478. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20479. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20480. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20481. //
  20482. // if item.ChrgitmLv == "1" {
  20483. //
  20484. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20485. //
  20486. // }
  20487. // if item.ChrgitmLv == "2" {
  20488. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20489. //
  20490. // }
  20491. // if item.ChrgitmLv == "3" {
  20492. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20493. // }
  20494. // }
  20495. //
  20496. // if item.MedChrgitmType == "07" { //手术费
  20497. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20498. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20499. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20500. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20501. //
  20502. // if item.ChrgitmLv == "1" {
  20503. //
  20504. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20505. //
  20506. // }
  20507. // if item.ChrgitmLv == "2" {
  20508. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20509. //
  20510. // }
  20511. // if item.ChrgitmLv == "3" {
  20512. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20513. // }
  20514. // }
  20515. //
  20516. // if item.MedChrgitmType == "08" { //材料费
  20517. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20518. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20519. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20520. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20521. // if item.ChrgitmLv == "1" {
  20522. //
  20523. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20524. //
  20525. // }
  20526. // if item.ChrgitmLv == "2" {
  20527. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20528. //
  20529. // }
  20530. // if item.ChrgitmLv == "3" {
  20531. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20532. // }
  20533. // }
  20534. // if item.MedChrgitmType == "09" { //西药费
  20535. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20536. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20537. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20538. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20539. // if item.ChrgitmLv == "1" {
  20540. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20541. // }
  20542. // if item.ChrgitmLv == "2" {
  20543. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20544. // }
  20545. // if item.ChrgitmLv == "3" {
  20546. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20547. // }
  20548. // }
  20549. // if item.MedChrgitmType == "10" { //中药饮片
  20550. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20551. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20552. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20553. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20554. // if item.ChrgitmLv == "1" {
  20555. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20556. // }
  20557. // if item.ChrgitmLv == "2" {
  20558. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20559. // }
  20560. // if item.ChrgitmLv == "3" {
  20561. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20562. // }
  20563. // }
  20564. //
  20565. // if item.MedChrgitmType == "11" { //中成费
  20566. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20567. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20568. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20569. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20570. // if item.ChrgitmLv == "1" {
  20571. //
  20572. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20573. //
  20574. // }
  20575. // if item.ChrgitmLv == "2" {
  20576. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20577. //
  20578. // }
  20579. // if item.ChrgitmLv == "3" {
  20580. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20581. // }
  20582. // }
  20583. //
  20584. // if item.MedChrgitmType == "12" { //中成费
  20585. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20586. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20587. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20588. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20589. // if item.ChrgitmLv == "1" {
  20590. //
  20591. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20592. //
  20593. // }
  20594. // if item.ChrgitmLv == "2" {
  20595. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20596. //
  20597. // }
  20598. // if item.ChrgitmLv == "3" {
  20599. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20600. // }
  20601. // }
  20602. //
  20603. // if item.MedChrgitmType == "13" { //中成费
  20604. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20605. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20606. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20607. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20608. // if item.ChrgitmLv == "1" {
  20609. //
  20610. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20611. //
  20612. // }
  20613. // if item.ChrgitmLv == "2" {
  20614. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20615. //
  20616. // }
  20617. // if item.ChrgitmLv == "3" {
  20618. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20619. // }
  20620. // }
  20621. //
  20622. // if item.MedChrgitmType == "14" { //其他费
  20623. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20624. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20625. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20626. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20627. // if item.ChrgitmLv == "1" {
  20628. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20629. //
  20630. // }
  20631. // if item.ChrgitmLv == "2" {
  20632. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20633. //
  20634. // }
  20635. // if item.ChrgitmLv == "3" {
  20636. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20637. // }
  20638. // }
  20639. //
  20640. // }
  20641. //
  20642. // var iteminfoStructs []service.IteminfoStruct
  20643. //
  20644. // if bedCostTotal != 0 {
  20645. // iteminfo.MedChrgitm = "01"
  20646. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20647. // iteminfo.Amt = bedCostTotal
  20648. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20649. // iteminfo.ClabAmt = bed_clab_amt
  20650. // iteminfo.OthAmt = bed_other_amt
  20651. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20652. // }
  20653. //
  20654. // if examineCostTotal != 0 {
  20655. // iteminfo.MedChrgitm = "02"
  20656. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20657. // iteminfo.Amt = examineCostTotal
  20658. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20659. // iteminfo.ClabAmt = examine_clab_amt
  20660. // iteminfo.OthAmt = examine_other_amt
  20661. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20662. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20663. // }
  20664. //
  20665. // if checkCostTotal != 0 {
  20666. // iteminfo.MedChrgitm = "03"
  20667. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20668. // iteminfo.Amt = checkCostTotal
  20669. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20670. // iteminfo.ClabAmt = check_clab_amt
  20671. // iteminfo.OthAmt = check_other_amt
  20672. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20673. //
  20674. // }
  20675. //
  20676. // if laboratoryCostTotal != 0 {
  20677. // iteminfo.MedChrgitm = "04"
  20678. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20679. // iteminfo.Amt = laboratoryCostTotal
  20680. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20681. // iteminfo.ClabAmt = laboratory_clab_amt
  20682. // iteminfo.OthAmt = laboratory_other_amt
  20683. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20684. //
  20685. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20686. //
  20687. // }
  20688. //
  20689. // if treatCostTotal != 0 {
  20690. // iteminfo.MedChrgitm = "05"
  20691. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20692. // iteminfo.Amt = treatCostTotal
  20693. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20694. // iteminfo.ClabAmt = treat_clab_amt
  20695. // iteminfo.OthAmt = treat_other_amt
  20696. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20697. // //(struct4101.IteminfoStruct, iteminfo)
  20698. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20699. // }
  20700. //
  20701. // if operationCostTotal != 0 {
  20702. // iteminfo.MedChrgitm = "06"
  20703. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20704. // iteminfo.Amt = operationCostTotal
  20705. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20706. // iteminfo.ClabAmt = operation_clab_amt
  20707. // iteminfo.OthAmt = operation_other_amt
  20708. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20709. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20710. // }
  20711. //
  20712. // if nursingCostTotal != 0 {
  20713. // iteminfo.MedChrgitm = "07"
  20714. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20715. // iteminfo.Amt = nursingCostTotal
  20716. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20717. // iteminfo.ClabAmt = nursing_clab_amt
  20718. // iteminfo.OthAmt = nursing_other_amt
  20719. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20720. // }
  20721. //
  20722. // if materialCostTotal != 0 {
  20723. // iteminfo.MedChrgitm = "08"
  20724. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20725. // iteminfo.Amt = materialCostTotal
  20726. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20727. // iteminfo.ClabAmt = material_clab_amt
  20728. // iteminfo.OthAmt = material_other_amt
  20729. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20730. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20731. // }
  20732. //
  20733. // if westernMedicineCostTotal != 0 {
  20734. // iteminfo.MedChrgitm = "09"
  20735. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20736. // iteminfo.Amt = westernMedicineCostTotal
  20737. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20738. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20739. // iteminfo.OthAmt = westernMedicine_other_amt
  20740. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20741. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20742. //
  20743. // }
  20744. //
  20745. // if chineseMedicineCostTotal != 0 {
  20746. // iteminfo.MedChrgitm = "10"
  20747. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  20748. // iteminfo.Amt = chineseMedicineCostTotal
  20749. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  20750. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  20751. // iteminfo.OthAmt = chinese_medicine_other_amt
  20752. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20753. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20754. //
  20755. // }
  20756. //
  20757. // if chineseTraditionalMedicineCostTotal != 0 {
  20758. // iteminfo.MedChrgitm = "11"
  20759. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20760. // iteminfo.Amt = westernMedicineCostTotal
  20761. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20762. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20763. // iteminfo.OthAmt = westernMedicine_other_amt
  20764. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20765. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20766. //
  20767. // }
  20768. //
  20769. // if commonlyTreatmentCostTotal != 0 {
  20770. // iteminfo.MedChrgitm = "12"
  20771. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  20772. // iteminfo.Amt = commonlyTreatmentCostTotal
  20773. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  20774. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  20775. // iteminfo.OthAmt = commonly_treatment_other_amt
  20776. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20777. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20778. //
  20779. // }
  20780. //
  20781. // if registerCostTotal != 0 {
  20782. // iteminfo.MedChrgitm = "13"
  20783. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  20784. // iteminfo.Amt = registerCostTotal
  20785. // iteminfo.ClaaSumfee = register_claa_sunmfee
  20786. // iteminfo.ClabAmt = register_clab_amt
  20787. // iteminfo.OthAmt = register_other_amt
  20788. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20789. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20790. //
  20791. // }
  20792. //
  20793. // if otherCostTotal != 0 {
  20794. // iteminfo.MedChrgitm = "14"
  20795. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20796. // iteminfo.Amt = otherCostTotal
  20797. // iteminfo.ClaaSumfee = other_claa_sunmfee
  20798. // iteminfo.ClabAmt = other_clab_amt
  20799. // iteminfo.OthAmt = other_other_amt
  20800. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20801. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20802. //
  20803. // }
  20804. // struct4101.IteminfoStruct = iteminfoStructs
  20805. // time_arr := strings.Split(order.SetlTime, " ")
  20806. // struct4101.AdmTime = time_arr[0]
  20807. // struct4101.AdmEndTime = time_arr[0]
  20808. //
  20809. // struct4101.DoctorName = doctor.UserName
  20810. // struct4101.DoctorCode = doctor.DoctorNumber
  20811. //
  20812. // struct4101.Ntly = "中国"
  20813. // struct4101.AdmCaty = "A03.06"
  20814. // var res ResultSeventeen
  20815. // if miConfig.MdtrtareaAdmvs == "421300" {
  20816. // data := make(map[string]interface{})
  20817. // data["struct4101"] = struct4101
  20818. // data["secret_key"] = miConfig.SecretKey
  20819. // data["org_name"] = miConfig.OrgName
  20820. // data["opera"] = curRoles.UserName
  20821. // data["code"] = miConfig.Code
  20822. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  20823. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20824. //
  20825. // client := &http.Client{}
  20826. // bytesData, _ := json.Marshal(data)
  20827. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  20828. // resp, _ := client.Do(req)
  20829. // defer resp.Body.Close()
  20830. // body, ioErr := ioutil.ReadAll(resp.Body)
  20831. // if ioErr != nil {
  20832. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20834. // return
  20835. // }
  20836. // var respJSON map[string]interface{}
  20837. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20838. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20840. // return
  20841. // }
  20842. //
  20843. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20844. // userJSONBytes, _ := json.Marshal(respJSON)
  20845. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20846. // utils.ErrorLog("解析失败:%v", err)
  20847. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20848. // adminUser := c.GetAdminUserInfo()
  20849. // errlog := &models.HisOrderError{
  20850. // UserOrgId: adminUser.CurrentOrgId,
  20851. // Ctime: time.Now().Unix(),
  20852. // Mtime: time.Now().Unix(),
  20853. // ErrMsg: res.ErrMsg + "解析失败",
  20854. // Status: 1,
  20855. // PatientId: order_id,
  20856. // Stage: 10088,
  20857. // }
  20858. // service.CreateErrMsgLog(errlog)
  20859. // continue
  20860. // }
  20861. //
  20862. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  20863. // data := make(map[string]interface{})
  20864. // data["struct4101"] = struct4101
  20865. // data["secret_key"] = miConfig.SecretKey
  20866. // data["org_name"] = miConfig.OrgName
  20867. // data["opera"] = curRoles.UserName
  20868. // data["code"] = miConfig.Code
  20869. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  20870. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20871. //
  20872. // client := &http.Client{}
  20873. // bytesData, _ := json.Marshal(data)
  20874. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  20875. // resp, _ := client.Do(req)
  20876. // defer resp.Body.Close()
  20877. // body, ioErr := ioutil.ReadAll(resp.Body)
  20878. // if ioErr != nil {
  20879. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20881. // return
  20882. // }
  20883. // var respJSON map[string]interface{}
  20884. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20885. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20887. // return
  20888. // }
  20889. //
  20890. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20891. // userJSONBytes, _ := json.Marshal(respJSON)
  20892. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20893. // utils.ErrorLog("解析失败:%v", err)
  20894. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20895. // adminUser := c.GetAdminUserInfo()
  20896. // errlog := &models.HisOrderError{
  20897. // UserOrgId: adminUser.CurrentOrgId,
  20898. // Ctime: time.Now().Unix(),
  20899. // Mtime: time.Now().Unix(),
  20900. // ErrMsg: res.ErrMsg + "解析失败",
  20901. // Status: 1,
  20902. // PatientId: order_id,
  20903. // Stage: 10088,
  20904. // }
  20905. // service.CreateErrMsgLog(errlog)
  20906. // continue
  20907. // }
  20908. //
  20909. // } else {
  20910. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  20911. // fmt.Println(result)
  20912. //
  20913. // var dat map[string]interface{}
  20914. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20915. // fmt.Println(dat)
  20916. // } else {
  20917. // fmt.Println(err)
  20918. // }
  20919. // userJSONBytes, _ := json.Marshal(dat)
  20920. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20921. // utils.ErrorLog("解析失败:%v", err)
  20922. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20923. // adminUser := c.GetAdminUserInfo()
  20924. // errlog := &models.HisOrderError{
  20925. // UserOrgId: adminUser.CurrentOrgId,
  20926. // Ctime: time.Now().Unix(),
  20927. // Mtime: time.Now().Unix(),
  20928. // ErrMsg: res.ErrMsg + "解析失败",
  20929. // Status: 1,
  20930. // PatientId: order_id,
  20931. // Stage: 10106,
  20932. // }
  20933. // service.CreateErrMsgLog(errlog)
  20934. // continue
  20935. // }
  20936. // }
  20937. //
  20938. // if res.Infcode != 0 {
  20939. // adminUser := c.GetAdminUserInfo()
  20940. // errlog := &models.HisOrderError{
  20941. // UserOrgId: adminUser.CurrentOrgId,
  20942. // Ctime: time.Now().Unix(),
  20943. // Mtime: time.Now().Unix(),
  20944. // ErrMsg: res.ErrMsg,
  20945. // Status: 1,
  20946. // PatientId: order_id,
  20947. // Stage: 10106,
  20948. // }
  20949. // service.CreateErrMsgLog(errlog)
  20950. // continue
  20951. // } else {
  20952. // hisFundSettleListResult := &models.HisFundSettleListResult{
  20953. // Number: res.Output.SetlListId,
  20954. // Status: 1,
  20955. // Ctime: time.Now().Unix(),
  20956. // Mtime: time.Now().Unix(),
  20957. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20958. // IsUpload: 1,
  20959. // OrderId: order_id,
  20960. // }
  20961. // service.CreateUploadRecord(hisFundSettleListResult)
  20962. // continue
  20963. // }
  20964. // }
  20965. //}
  20966. func (c *HisApiController) GetOrgInfo() {
  20967. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  20968. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  20969. }
  20970. func (c *HisApiController) GetHisPatientInfo() {
  20971. medical_insurance_card := c.GetString("medical_insurance_card")
  20972. id_card_type, _ := c.GetInt64("id_card_type")
  20973. id_card := c.GetString("id_card")
  20974. adminInfo := c.GetAdminUserInfo()
  20975. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  20976. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  20977. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  20978. IdCardNo := ""
  20979. if id_card_type == 1 {
  20980. IdCardNo = medical_insurance_card
  20981. } else if id_card_type == 2 {
  20982. IdCardNo = id_card
  20983. }
  20984. if config.IsOpen == 1 {
  20985. 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
  20986. resp, requestErr := http.Get(api)
  20987. if requestErr != nil {
  20988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20989. return
  20990. }
  20991. defer resp.Body.Close()
  20992. body, ioErr := ioutil.ReadAll(resp.Body)
  20993. if ioErr != nil {
  20994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20996. return
  20997. }
  20998. var respJSON map[string]interface{}
  20999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21002. return
  21003. }
  21004. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21005. userJSONBytes, _ := json.Marshal(userJSON)
  21006. var res ResultTwo
  21007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21008. utils.ErrorLog("解析失败:%v", err)
  21009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21010. return
  21011. }
  21012. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21013. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21014. infoStr := string(Iinfos)
  21015. idetinfoStr := string(Idetinfos)
  21016. if res.Infcode == 0 {
  21017. his := models.VMHisPatient{
  21018. Status: 1,
  21019. Ctime: time.Now().Unix(),
  21020. Mtime: time.Now().Unix(),
  21021. PsnNo: res.Output.Baseinfo.PsnNo,
  21022. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21023. Certno: res.Output.Baseinfo.Certno,
  21024. PsnName: res.Output.Baseinfo.PsnName,
  21025. Gend: res.Output.Baseinfo.Gend,
  21026. Naty: res.Output.Baseinfo.Naty,
  21027. Iinfo: infoStr,
  21028. Idetinfo: idetinfoStr,
  21029. UserOrgId: adminInfo.CurrentOrgId,
  21030. IsReturn: 1,
  21031. IdCardType: id_card_type,
  21032. }
  21033. c.ServeSuccessJSON(map[string]interface{}{
  21034. "info": his,
  21035. })
  21036. } else {
  21037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21038. return
  21039. }
  21040. }
  21041. }
  21042. //func GetBasBaseInfo() (jsonStr string, err error) {
  21043. //
  21044. // handle := syscall.NewLazyDLL("SSCard.dll")
  21045. // add := handle.NewProc("ReadCardBas")
  21046. // str := make([]byte, 1024)
  21047. // str1 := make([]byte, 1024)
  21048. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21049. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21050. //
  21051. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21052. //
  21053. // fmt.Println("> Add(4,5)的结果为:", ret)
  21054. // handle.Release()
  21055. //
  21056. // return "", nil
  21057. //
  21058. //}
  21059. //func GetQRBaseInfo() (jsonStr string, err error) {
  21060. // handle := syscall.LoadDLL("SSCard.dll")
  21061. // ReadCardBas := handle.FindProc("GetQRBase")
  21062. //
  21063. // str := make([]byte, 256)
  21064. // str1 := make([]byte, 256)
  21065. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21066. //
  21067. // fmt.Println(string(str))
  21068. // fmt.Println(r)
  21069. // return string(str), nil
  21070. //}
  21071. //func CardInit() int {
  21072. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21073. // add := DllTestDef.MustFindProc("Init")
  21074. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21075. // if err != nil {
  21076. // fmt.Println("SSCard的运算结果为:", ret)
  21077. // }
  21078. // result := int(ret)
  21079. // return result
  21080. //}
  21081. //func CardInit() int {
  21082. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21083. // if err != nil {
  21084. // fmt.Println("SSCard的运算结果为:", ret)
  21085. // }
  21086. // fmt.Println(err)
  21087. // result := int(ret)
  21088. // return result
  21089. //}
  21090. func IntPtr(n int) uintptr {
  21091. return uintptr(n)
  21092. }
  21093. func StrPtr(s string) uintptr {
  21094. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21095. }
  21096. type Result2001 struct {
  21097. Cainfo interface{} `json:"cainfo"`
  21098. ErrMsg string `json:"err_msg"`
  21099. InfRefmsgid string `json:"inf_refmsgid"`
  21100. Infcode int64 `json:"infcode"`
  21101. Output struct {
  21102. Trtinfo struct {
  21103. PsnNo string `json:"psn_no"`
  21104. TrtChkType string `json:"trt_chk_type"`
  21105. FundPayType string `json:"fund_pay_type"`
  21106. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21107. Begndate string `json:"begndate"`
  21108. Enddate string `json:"enddate"`
  21109. TrtChkRslt string `json:"trt_chk_rslt"`
  21110. } `json:"trtinfo"`
  21111. } `json:"output"`
  21112. RefmsgTime string `json:"refmsg_time"`
  21113. RespondTime string `json:"respond_time"`
  21114. Signtype interface{} `json:"signtype"`
  21115. WarnMsg interface{} `json:"warn_msg"`
  21116. }
  21117. type Result2001Org10265 struct {
  21118. Cainfo interface{} `json:"cainfo"`
  21119. ErrMsg string `json:"err_msg"`
  21120. InfRefmsgid string `json:"inf_refmsgid"`
  21121. Infcode string `json:"infcode"`
  21122. Output struct {
  21123. Trtinfo struct {
  21124. PsnNo string `json:"psn_no"`
  21125. TrtChkType string `json:"trt_chk_type"`
  21126. FundPayType string `json:"fund_pay_type"`
  21127. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21128. Begndate string `json:"begndate"`
  21129. Enddate string `json:"enddate"`
  21130. TrtChkRslt string `json:"trt_chk_rslt"`
  21131. } `json:"trtinfo"`
  21132. } `json:"output"`
  21133. RefmsgTime string `json:"refmsg_time"`
  21134. RespondTime string `json:"respond_time"`
  21135. Signtype interface{} `json:"signtype"`
  21136. WarnMsg interface{} `json:"warn_msg"`
  21137. }
  21138. type ResultTwo struct {
  21139. ErrMsg string `json:"err_msg"`
  21140. InfRefmsgid string `json:"inf_refmsgid"`
  21141. Infcode int64 `json:"infcode"`
  21142. Output struct {
  21143. Baseinfo struct {
  21144. //Brdy string `json:"brdy"`
  21145. Certno string `json:"certno"`
  21146. Gend string `json:"gend"`
  21147. Naty string `json:"naty"`
  21148. PsnCertType string `json:"psn_cert_type"`
  21149. PsnName string `json:"psn_name"`
  21150. PsnNo string `json:"psn_no"`
  21151. } `json:"baseinfo"`
  21152. Idetinfo []interface{} `json:"idetinfo"`
  21153. Iinfo []struct {
  21154. Balc float64 `json:"balc"`
  21155. CvlservFlag string `json:"cvlserv_flag"`
  21156. EmpName string `json:"emp_name"`
  21157. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21158. Insutype string `json:"insutype"`
  21159. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21160. //PausInsuDate string `json:"paus_insu_date"`
  21161. //PsnInsuDate string `json:"psn_insu_date"`
  21162. PsnInsuStas string `json:"psn_insu_stas"`
  21163. PsnType string `json:"psn_type"`
  21164. } `json:"insuinfo"`
  21165. } `json:"output"`
  21166. RefmsgTime string `json:"refmsg_time"`
  21167. RespondTime string `json:"respond_time"`
  21168. Signtype interface{} `json:"signtype"`
  21169. WarnInfo interface{} `json:"warn_info"`
  21170. }
  21171. type ResultTwo10265 struct {
  21172. ErrMsg string `json:"err_msg"`
  21173. InfRefmsgid string `json:"inf_refmsgid"`
  21174. Infcode string `json:"infcode"`
  21175. Output struct {
  21176. Baseinfo struct {
  21177. //Brdy string `json:"brdy"`
  21178. Certno string `json:"certno"`
  21179. Gend string `json:"gend"`
  21180. Naty string `json:"naty"`
  21181. PsnCertType string `json:"psn_cert_type"`
  21182. PsnName string `json:"psn_name"`
  21183. PsnNo string `json:"psn_no"`
  21184. } `json:"baseinfo"`
  21185. Idetinfo []interface{} `json:"idetinfo"`
  21186. Iinfo []struct {
  21187. Balc float64 `json:"balc"`
  21188. CvlservFlag string `json:"cvlserv_flag"`
  21189. EmpName string `json:"emp_name"`
  21190. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21191. Insutype string `json:"insutype"`
  21192. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21193. PsnInsuStas string `json:"psn_insu_stas"`
  21194. PsnType string `json:"psn_type"`
  21195. } `json:"insuinfo"`
  21196. } `json:"output"`
  21197. RefmsgTime string `json:"refmsg_time"`
  21198. RespondTime string `json:"respond_time"`
  21199. Signtype interface{} `json:"signtype"`
  21200. WarnInfo interface{} `json:"warn_info"`
  21201. }
  21202. type ResultThree struct {
  21203. Cainfo interface{} `json:"cainfo"`
  21204. ErrMsg string `json:"err_msg"`
  21205. InfRefmsgid string `json:"inf_refmsgid"`
  21206. Infcode int64 `json:"infcode"`
  21207. Output struct {
  21208. Data struct {
  21209. IptOtpNo string `json:"ipt_otp_no"`
  21210. MdtrtID string `json:"mdtrt_id"`
  21211. PsnNo string `json:"psn_no"`
  21212. } `json:"data"`
  21213. } `json:"output"`
  21214. RefmsgTime string `json:"refmsg_time"`
  21215. RespondTime string `json:"respond_time"`
  21216. Signtype interface{} `json:"signtype"`
  21217. WarnMsg interface{} `json:"warn_msg"`
  21218. }
  21219. type ResultThree10265 struct {
  21220. Cainfo interface{} `json:"cainfo"`
  21221. ErrMsg string `json:"err_msg"`
  21222. InfRefmsgid string `json:"inf_refmsgid"`
  21223. Infcode string `json:"infcode"`
  21224. Output struct {
  21225. Data struct {
  21226. IptOtpNo string `json:"ipt_otp_no"`
  21227. MdtrtID string `json:"mdtrt_id"`
  21228. PsnNo string `json:"psn_no"`
  21229. } `json:"data"`
  21230. } `json:"output"`
  21231. RefmsgTime string `json:"refmsg_time"`
  21232. RespondTime string `json:"respond_time"`
  21233. Signtype interface{} `json:"signtype"`
  21234. WarnMsg interface{} `json:"warn_msg"`
  21235. }
  21236. type ResultFour struct {
  21237. Cainfo string `json:"cainfo"`
  21238. ErrMsg string `json:"err_msg"`
  21239. InfRefmsgid string `json:"inf_refmsgid"`
  21240. Infcode int64 `json:"infcode"`
  21241. Output struct {
  21242. Result []struct {
  21243. BasMednFlag string `json:"bas_medn_flag"`
  21244. ChldMedcFlag string `json:"chld_medc_flag"`
  21245. ChrgitmLv string `json:"chrgitm_lv"`
  21246. Cnt float64 `json:"cnt"`
  21247. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21248. DrtReimFlag string `json:"drt_reim_flag"`
  21249. FeedetlSn string `json:"feedetl_sn"`
  21250. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21251. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21252. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21253. ListSpItemFlag string `json:"list_sp_item_flag"`
  21254. LmtUsedFlag string `json:"lmt_used_flag"`
  21255. MedChrgitmType string `json:"med_chrgitm_type"`
  21256. Memo string `json:"memo"`
  21257. OverlmtAmt float64 `json:"overlmt_amt"`
  21258. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21259. Pric float64 `json:"pric"`
  21260. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21261. SelfpayProp float64 `json:"selfpay_prop"`
  21262. } `json:"result"`
  21263. } `json:"output"`
  21264. RefmsgTime string `json:"refmsg_time"`
  21265. RespondTime string `json:"respond_time"`
  21266. Signtype string `json:"signtype"`
  21267. WarnMsg string `json:"warn_msg"`
  21268. }
  21269. type ResultFour10265 struct {
  21270. Cainfo string `json:"cainfo"`
  21271. ErrMsg string `json:"err_msg"`
  21272. InfRefmsgid string `json:"inf_refmsgid"`
  21273. Infcode string `json:"infcode"`
  21274. Output struct {
  21275. Result []struct {
  21276. BasMednFlag string `json:"bas_medn_flag"`
  21277. ChldMedcFlag string `json:"chld_medc_flag"`
  21278. ChrgitmLv string `json:"chrgitm_lv"`
  21279. Cnt float64 `json:"cnt"`
  21280. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21281. DrtReimFlag string `json:"drt_reim_flag"`
  21282. FeedetlSn string `json:"feedetl_sn"`
  21283. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21284. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21285. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21286. ListSpItemFlag string `json:"list_sp_item_flag"`
  21287. LmtUsedFlag string `json:"lmt_used_flag"`
  21288. MedChrgitmType string `json:"med_chrgitm_type"`
  21289. Memo string `json:"memo"`
  21290. OverlmtAmt float64 `json:"overlmt_amt"`
  21291. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21292. Pric float64 `json:"pric"`
  21293. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21294. SelfpayProp float64 `json:"selfpay_prop"`
  21295. } `json:"result"`
  21296. } `json:"output"`
  21297. RefmsgTime string `json:"refmsg_time"`
  21298. RespondTime string `json:"respond_time"`
  21299. Signtype string `json:"signtype"`
  21300. WarnMsg string `json:"warn_msg"`
  21301. }
  21302. type ResultMemo struct {
  21303. InsuAdmdvs string `json:"insuAdmdvs"`
  21304. }
  21305. // [{"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}]
  21306. type ResultIDInfo struct {
  21307. Begntime string `json:"begntime"`
  21308. Endtime string `json:"endtime"`
  21309. Memo string `json:"memo"`
  21310. }
  21311. type ResultFive struct {
  21312. Balc float64 `json:"balc"`
  21313. CvlservFlag string `json:"cvlserv_flag"`
  21314. EmpName string `json:"emp_name"`
  21315. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21316. Insutype string `json:"insutype"`
  21317. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21318. PausInsuDate string `json:"paus_insu_date"`
  21319. PsnInsuDate string `json:"psn_insu_date"`
  21320. PsnInsuStas string `json:"psn_insu_stas"`
  21321. PsnType string `json:"psn_type"`
  21322. }
  21323. type ResultSix struct {
  21324. Cainfo interface{} `json:"cainfo"`
  21325. ErrMsg string `json:"err_msg"`
  21326. InfRefmsgid string `json:"inf_refmsgid"`
  21327. Infcode int64 `json:"infcode"`
  21328. Output struct {
  21329. } `json:"output"`
  21330. RefmsgTime string `json:"refmsg_time"`
  21331. RespondTime string `json:"respond_time"`
  21332. Signtype interface{} `json:"signtype"`
  21333. WarnMsg interface{} `json:"warn_msg"`
  21334. }
  21335. type FJ3507Result struct {
  21336. Cainfo interface{} `json:"cainfo"`
  21337. ErrMsg string `json:"err_msg"`
  21338. InfRefmsgid string `json:"inf_refmsgid"`
  21339. Infcode int64 `json:"infcode"`
  21340. Output struct {
  21341. retRslt string `json:"retRslt"`
  21342. msgRslt string `json:"msgRslt"`
  21343. } `json:"output"`
  21344. RefmsgTime string `json:"refmsg_time"`
  21345. RespondTime string `json:"respond_time"`
  21346. Signtype interface{} `json:"signtype"`
  21347. WarnMsg interface{} `json:"warn_msg"`
  21348. }
  21349. type FJ3507ResultFor10188 struct {
  21350. Cainfo interface{} `json:"cainfo"`
  21351. ErrMsg string `json:"err_msg"`
  21352. InfRefmsgid string `json:"inf_refmsgid"`
  21353. Infcode string `json:"infcode"`
  21354. RefmsgTime string `json:"refmsg_time"`
  21355. RespondTime string `json:"respond_time"`
  21356. Signtype interface{} `json:"signtype"`
  21357. WarnMsg interface{} `json:"warn_msg"`
  21358. }
  21359. type Result2406 struct {
  21360. Cainfo interface{} `json:"cainfo"`
  21361. ErrMsg string `json:"err_msg"`
  21362. InfRefmsgid string `json:"inf_refmsgid"`
  21363. Infcode int64 `json:"infcode"`
  21364. Output struct {
  21365. Result struct {
  21366. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21367. } `json:"result"`
  21368. } `json:"output"`
  21369. RefmsgTime string `json:"refmsg_time"`
  21370. RespondTime string `json:"respond_time"`
  21371. Signtype interface{} `json:"signtype"`
  21372. WarnMsg interface{} `json:"warn_msg"`
  21373. }
  21374. type GZResultSix struct {
  21375. Cainfo interface{} `json:"cainfo"`
  21376. ErrMsg string `json:"err_msg"`
  21377. InfRefmsgid string `json:"inf_refmsgid"`
  21378. Infcode int64 `json:"infcode"`
  21379. Output string `json:"output"`
  21380. RefmsgTime string `json:"refmsg_time"`
  21381. RespondTime string `json:"respond_time"`
  21382. Signtype interface{} `json:"signtype"`
  21383. WarnMsg interface{} `json:"warn_msg"`
  21384. }
  21385. type ResultSix10265 struct {
  21386. Cainfo interface{} `json:"cainfo"`
  21387. ErrMsg string `json:"err_msg"`
  21388. InfRefmsgid string `json:"inf_refmsgid"`
  21389. Infcode string `json:"infcode"`
  21390. Output struct {
  21391. } `json:"output"`
  21392. RefmsgTime string `json:"refmsg_time"`
  21393. RespondTime string `json:"respond_time"`
  21394. Signtype interface{} `json:"signtype"`
  21395. WarnMsg interface{} `json:"warn_msg"`
  21396. }
  21397. type ResultSeven struct {
  21398. Cainfo string `json:"cainfo"`
  21399. ErrMsg string `json:"err_msg"`
  21400. InfRefmsgid string `json:"inf_refmsgid"`
  21401. Infcode int64 `json:"infcode"`
  21402. Output struct {
  21403. Setlinfo struct {
  21404. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21405. AcctPay float64 `json:"acct_pay"`
  21406. ActPayDedc float64 `json:"act_pay_dedc"`
  21407. Age float64 `json:"age"`
  21408. Balc float64 `json:"balc"`
  21409. Certno string `json:"certno"`
  21410. ClrOptins string `json:"clr_optins"`
  21411. ClrType string `json:"clr_type"`
  21412. ClrWay string `json:"clr_way"`
  21413. CvlservFlag string `json:"cvlserv_flag"`
  21414. CvlservPay float64 `json:"cvlserv_pay"`
  21415. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21416. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21417. Gend string `json:"gend"`
  21418. HifesPay float64 `json:"hifes_pay"`
  21419. HifmiPay float64 `json:"hifmi_pay"`
  21420. HifpPay float64 `json:"hifp_pay"`
  21421. HospPartAmt float64 `json:"hosp_part_amt"`
  21422. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21423. Insutype string `json:"insutype"`
  21424. MafPay float64 `json:"maf_pay"`
  21425. MdtrtCertType string `json:"mdtrt_cert_type"`
  21426. HifobPay float64 `json:"hifob_pay"`
  21427. MdtrtID string `json:"mdtrt_id"`
  21428. MedType string `json:"med_type"`
  21429. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21430. MedinsSetlID string `json:"medins_setl_id"`
  21431. Naty string `json:"naty"`
  21432. OthPay float64 `json:"oth_pay"`
  21433. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21434. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21435. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21436. PsnCashPay float64 `json:"psn_cash_pay"`
  21437. PsnCertType string `json:"psn_cert_type"`
  21438. PsnName string `json:"psn_name"`
  21439. PsnNo string `json:"psn_no"`
  21440. PsnPartAmt float64 `json:"psn_part_amt"`
  21441. PsnType string `json:"psn_type"`
  21442. SetlID string `json:"setl_id"`
  21443. SetlTime string `json:"setl_time"`
  21444. } `json:"setlinfo"`
  21445. Setldetail interface{} `json:"setldetail"`
  21446. } `json:"output"`
  21447. RefmsgTime string `json:"refmsg_time"`
  21448. RespondTime string `json:"respond_time"`
  21449. Signtype interface{} `json:"signtype"`
  21450. WarnMsg interface{} `json:"warn_msg"`
  21451. }
  21452. type ResultSevenAH struct {
  21453. Cainfo string `json:"cainfo"`
  21454. ErrMsg string `json:"err_msg"`
  21455. InfRefmsgid string `json:"inf_refmsgid"`
  21456. Infcode int64 `json:"infcode"`
  21457. Output struct {
  21458. Setlinfo struct {
  21459. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21460. AcctPay float64 `json:"acct_pay"`
  21461. ActPayDedc float64 `json:"act_pay_dedc"`
  21462. Age float64 `json:"age"`
  21463. Balc float64 `json:"balc"`
  21464. Certno string `json:"certno"`
  21465. ClrOptins string `json:"clr_optins"`
  21466. ClrType string `json:"clr_type"`
  21467. ClrWay string `json:"clr_way"`
  21468. CvlservFlag string `json:"cvlserv_flag"`
  21469. CvlservPay float64 `json:"cvlserv_pay"`
  21470. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21471. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21472. Gend string `json:"gend"`
  21473. HifesPay float64 `json:"hifes_pay"`
  21474. HifmiPay float64 `json:"hifmi_pay"`
  21475. HifpPay float64 `json:"hifp_pay"`
  21476. HospPartAmt float64 `json:"hosp_part_amt"`
  21477. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21478. Insutype string `json:"insutype"`
  21479. MafPay float64 `json:"maf_pay"`
  21480. MdtrtCertType string `json:"mdtrt_cert_type"`
  21481. HifobPay float64 `json:"hifob_pay"`
  21482. MdtrtID string `json:"mdtrt_id"`
  21483. MedType string `json:"med_type"`
  21484. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21485. MedinsSetlID string `json:"medins_setl_id"`
  21486. Naty string `json:"naty"`
  21487. OthPay float64 `json:"oth_pay"`
  21488. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21489. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21490. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21491. PsnCashPay float64 `json:"psn_cash_pay"`
  21492. PsnCertType string `json:"psn_cert_type"`
  21493. PsnName string `json:"psn_name"`
  21494. PsnNo string `json:"psn_no"`
  21495. PsnPartAmt float64 `json:"psn_part_amt"`
  21496. PsnType string `json:"psn_type"`
  21497. SetlID string `json:"setl_id"`
  21498. SetlTime int64 `json:"setl_time"`
  21499. } `json:"setlinfo"`
  21500. Setldetail interface{} `json:"setldetail"`
  21501. } `json:"output"`
  21502. RefmsgTime string `json:"refmsg_time"`
  21503. RespondTime string `json:"respond_time"`
  21504. Signtype interface{} `json:"signtype"`
  21505. WarnMsg interface{} `json:"warn_msg"`
  21506. }
  21507. type ResultSeven10265 struct {
  21508. Cainfo string `json:"cainfo"`
  21509. ErrMsg string `json:"err_msg"`
  21510. InfRefmsgid string `json:"inf_refmsgid"`
  21511. Infcode string `json:"infcode"`
  21512. Output struct {
  21513. Setlinfo struct {
  21514. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21515. AcctPay float64 `json:"acct_pay"`
  21516. ActPayDedc float64 `json:"act_pay_dedc"`
  21517. Age float64 `json:"age"`
  21518. Balc float64 `json:"balc"`
  21519. Certno string `json:"certno"`
  21520. ClrOptins string `json:"clr_optins"`
  21521. ClrType string `json:"clr_type"`
  21522. ClrWay string `json:"clr_way"`
  21523. CvlservFlag string `json:"cvlserv_flag"`
  21524. CvlservPay float64 `json:"cvlserv_pay"`
  21525. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21526. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21527. Gend string `json:"gend"`
  21528. HifesPay float64 `json:"hifes_pay"`
  21529. HifmiPay float64 `json:"hifmi_pay"`
  21530. HifpPay float64 `json:"hifp_pay"`
  21531. HospPartAmt float64 `json:"hosp_part_amt"`
  21532. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21533. Insutype string `json:"insutype"`
  21534. MafPay float64 `json:"maf_pay"`
  21535. MdtrtCertType string `json:"mdtrt_cert_type"`
  21536. HifobPay float64 `json:"hifob_pay"`
  21537. MdtrtID string `json:"mdtrt_id"`
  21538. MedType string `json:"med_type"`
  21539. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21540. MedinsSetlID string `json:"medins_setl_id"`
  21541. Naty string `json:"naty"`
  21542. OthPay float64 `json:"oth_pay"`
  21543. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21544. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21545. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21546. PsnCashPay float64 `json:"psn_cash_pay"`
  21547. PsnCertType string `json:"psn_cert_type"`
  21548. PsnName string `json:"psn_name"`
  21549. PsnNo string `json:"psn_no"`
  21550. PsnPartAmt float64 `json:"psn_part_amt"`
  21551. PsnType string `json:"psn_type"`
  21552. SetlID string `json:"setl_id"`
  21553. SetlTime string `json:"setl_time"`
  21554. } `json:"setlinfo"`
  21555. Setldetail interface{} `json:"setldetail"`
  21556. } `json:"output"`
  21557. RefmsgTime string `json:"refmsg_time"`
  21558. RespondTime string `json:"respond_time"`
  21559. Signtype interface{} `json:"signtype"`
  21560. WarnMsg interface{} `json:"warn_msg"`
  21561. }
  21562. type ResultSeven10265Two struct {
  21563. Cainfo string `json:"cainfo"`
  21564. ErrMsg string `json:"err_msg"`
  21565. InfRefmsgid string `json:"inf_refmsgid"`
  21566. Infcode string `json:"infcode"`
  21567. Output struct {
  21568. Setlinfo struct {
  21569. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21570. AcctPay float64 `json:"acct_pay"`
  21571. ActPayDedc float64 `json:"act_pay_dedc"`
  21572. Age float64 `json:"age"`
  21573. Balc float64 `json:"balc"`
  21574. Certno string `json:"certno"`
  21575. ClrOptins string `json:"clr_optins"`
  21576. ClrType string `json:"clr_type"`
  21577. ClrWay string `json:"clr_way"`
  21578. CvlservFlag string `json:"cvlserv_flag"`
  21579. CvlservPay float64 `json:"cvlserv_pay"`
  21580. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21581. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21582. Gend string `json:"gend"`
  21583. HifesPay float64 `json:"hifes_pay"`
  21584. HifmiPay float64 `json:"hifmi_pay"`
  21585. HifpPay float64 `json:"hifp_pay"`
  21586. HospPartAmt string `json:"hosp_part_amt"`
  21587. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21588. Insutype string `json:"insutype"`
  21589. MafPay float64 `json:"maf_pay"`
  21590. MdtrtCertType string `json:"mdtrt_cert_type"`
  21591. HifobPay float64 `json:"hifob_pay"`
  21592. MdtrtID string `json:"mdtrt_id"`
  21593. MedType string `json:"med_type"`
  21594. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21595. MedinsSetlID string `json:"medins_setl_id"`
  21596. Naty string `json:"naty"`
  21597. OthPay float64 `json:"oth_pay"`
  21598. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21599. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21600. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21601. PsnCashPay float64 `json:"psn_cash_pay"`
  21602. PsnCertType string `json:"psn_cert_type"`
  21603. PsnName string `json:"psn_name"`
  21604. PsnNo string `json:"psn_no"`
  21605. PsnPartAmt float64 `json:"psn_part_amt"`
  21606. PsnType string `json:"psn_type"`
  21607. SetlID string `json:"setl_id"`
  21608. SetlTime string `json:"setl_time"`
  21609. } `json:"setlinfo"`
  21610. Setldetail interface{} `json:"setldetail"`
  21611. } `json:"output"`
  21612. RefmsgTime string `json:"refmsg_time"`
  21613. RespondTime string `json:"respond_time"`
  21614. Signtype interface{} `json:"signtype"`
  21615. WarnMsg interface{} `json:"warn_msg"`
  21616. }
  21617. type GZResultSeven10265Two struct {
  21618. Cainfo string `json:"cainfo"`
  21619. ErrMsg string `json:"err_msg"`
  21620. InfRefmsgid string `json:"inf_refmsgid"`
  21621. Infcode int64 `json:"infcode"`
  21622. Output struct {
  21623. Setlinfo struct {
  21624. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21625. AcctPay float64 `json:"acct_pay"`
  21626. ActPayDedc float64 `json:"act_pay_dedc"`
  21627. Age float64 `json:"age"`
  21628. Balc float64 `json:"balc"`
  21629. Certno string `json:"certno"`
  21630. ClrOptins string `json:"clr_optins"`
  21631. ClrType string `json:"clr_type"`
  21632. ClrWay string `json:"clr_way"`
  21633. CvlservFlag string `json:"cvlserv_flag"`
  21634. CvlservPay float64 `json:"cvlserv_pay"`
  21635. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21636. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21637. Gend string `json:"gend"`
  21638. HifesPay float64 `json:"hifes_pay"`
  21639. HifmiPay float64 `json:"hifmi_pay"`
  21640. HifpPay float64 `json:"hifp_pay"`
  21641. HospPartAmt float64 `json:"hosp_part_amt"`
  21642. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21643. Insutype string `json:"insutype"`
  21644. MafPay float64 `json:"maf_pay"`
  21645. MdtrtCertType string `json:"mdtrt_cert_type"`
  21646. HifobPay float64 `json:"hifob_pay"`
  21647. MdtrtID string `json:"mdtrt_id"`
  21648. MedType string `json:"med_type"`
  21649. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21650. MedinsSetlID string `json:"medins_setl_id"`
  21651. Naty string `json:"naty"`
  21652. OthPay float64 `json:"oth_pay"`
  21653. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21654. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21655. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21656. PsnCashPay float64 `json:"psn_cash_pay"`
  21657. PsnCertType string `json:"psn_cert_type"`
  21658. PsnName string `json:"psn_name"`
  21659. PsnNo string `json:"psn_no"`
  21660. PsnPartAmt float64 `json:"psn_part_amt"`
  21661. PsnType string `json:"psn_type"`
  21662. SetlID string `json:"setl_id"`
  21663. SetlTime string `json:"setl_time"`
  21664. } `json:"setlinfo"`
  21665. Setldetail interface{} `json:"setldetail"`
  21666. } `json:"output"`
  21667. RefmsgTime string `json:"refmsg_time"`
  21668. RespondTime string `json:"respond_time"`
  21669. Signtype interface{} `json:"signtype"`
  21670. WarnMsg interface{} `json:"warn_msg"`
  21671. }
  21672. type ResultEight struct {
  21673. Cainfo string `json:"cainfo"`
  21674. ErrMsg string `json:"err_msg"`
  21675. InfRefmsgid string `json:"inf_refmsgid"`
  21676. Infcode int64 `json:"infcode"`
  21677. Output struct {
  21678. Stmtinfo struct {
  21679. SetlOptins string `json:"setl_optins"`
  21680. StmtRslt string `json:"stmt_rslt"`
  21681. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21682. } `json:"stmtinfo"`
  21683. } `json:"output"`
  21684. RefmsgTime string `json:"refmsg_time"`
  21685. RespondTime string `json:"respond_time"`
  21686. Signtype interface{} `json:"signtype"`
  21687. WarnMsg interface{} `json:"warn_msg"`
  21688. }
  21689. type ResultEightFor10188 struct {
  21690. Cainfo string `json:"cainfo"`
  21691. ErrMsg string `json:"err_msg"`
  21692. InfRefmsgid string `json:"inf_refmsgid"`
  21693. Infcode string `json:"infcode"`
  21694. Output struct {
  21695. Stmtinfo struct {
  21696. SetlOptins string `json:"setl_optins"`
  21697. StmtRslt string `json:"stmt_rslt"`
  21698. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21699. } `json:"stmtinfo"`
  21700. } `json:"output"`
  21701. RefmsgTime string `json:"refmsg_time"`
  21702. RespondTime string `json:"respond_time"`
  21703. Signtype interface{} `json:"signtype"`
  21704. WarnMsg interface{} `json:"warn_msg"`
  21705. }
  21706. type ResultNine struct {
  21707. Cainfo string `json:"cainfo"`
  21708. ErrMsg string `json:"err_msg"`
  21709. InfRefmsgid string `json:"inf_refmsgid"`
  21710. Infcode int64 `json:"infcode"`
  21711. Output struct {
  21712. FileQuryNo string `json:"file_qury_no"`
  21713. } `json:"output"`
  21714. RefmsgTime string `json:"refmsg_time"`
  21715. RespondTime string `json:"respond_time"`
  21716. Signtype interface{} `json:"signtype"`
  21717. WarnMsg interface{} `json:"warn_msg"`
  21718. }
  21719. type ResultTen struct {
  21720. Cainfo string `json:"cainfo"`
  21721. ErrMsg string `json:"err_msg"`
  21722. InfRefmsgid string `json:"inf_refmsgid"`
  21723. Infcode int64 `json:"infcode"`
  21724. Output struct {
  21725. Fileinfo struct {
  21726. DldEndtime string `json:"dld_endtime"`
  21727. FileQuryNo string `json:"file_qury_no"`
  21728. Filename string `json:"filename"`
  21729. } `json:"fileinfo"`
  21730. } `json:"output"`
  21731. RefmsgTime string `json:"refmsg_time"`
  21732. RespondTime string `json:"respond_time"`
  21733. Signtype interface{} `json:"signtype"`
  21734. WarnMsg interface{} `json:"warn_msg"`
  21735. }
  21736. type Result5262 struct {
  21737. ErrMsg string `json:"err_msg"`
  21738. InfRefmsgid string `json:"inf_refmsgid"`
  21739. Infcode int64 `json:"infcode"`
  21740. Output struct {
  21741. PageInfo struct {
  21742. Size int `json:"size"`
  21743. RecordCounts int `json:"record_counts"`
  21744. } `json:"page_info"`
  21745. Idetinfo []interface{} `json:"idetinfo"`
  21746. Result []struct {
  21747. SetlID string `json:"setl_id"`
  21748. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21749. MdtrtID string `json:"mdtrt_id"`
  21750. InitSetlID string `json:"init_setl_id,omitempty"`
  21751. PsnNo string `json:"psn_no"`
  21752. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21753. PsnName string `json:"psn_name"`
  21754. PsnCertType string `json:"psn_cert_type"`
  21755. Certno string `json:"certno"`
  21756. Gend string `json:"gend,omitempty"`
  21757. Naty string `json:"naty,omitempty"`
  21758. Brdy string `json:"brdy,omitempty"`
  21759. Age float64 `json:"age,omitempty"`
  21760. Insutype string `json:"insutype,omitempty"`
  21761. PsnType string `json:"psn_type"`
  21762. CvlservFlag string `json:"cvlserv_flag"`
  21763. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21764. SpPsnType string `json:"sp_psn_type,omitempty"`
  21765. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21766. ClctGrde string `json:"clct_grde,omitempty"`
  21767. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21768. NwbFlag string `json:"nwb_flag,omitempty"`
  21769. InsuAdmdvs string `json:"insu_admdvs"`
  21770. EmpNo string `json:"emp_no,omitempty"`
  21771. EmpName string `json:"emp_name,omitempty"`
  21772. EmpType string `json:"emp_type,omitempty"`
  21773. EconType string `json:"econ_type,omitempty"`
  21774. AfilIndu string `json:"afil_indu,omitempty"`
  21775. AfilRlts string `json:"afil_rlts,omitempty"`
  21776. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21777. PayLoc string `json:"pay_loc,omitempty"`
  21778. FixmedinsCode string `json:"fixmedins_code"`
  21779. FixmedinsName string `json:"fixmedins_name"`
  21780. HospLv string `json:"hosp_lv,omitempty"`
  21781. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21782. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21783. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21784. Begndate string `json:"begndate"`
  21785. Enddate string `json:"enddate"`
  21786. SetlTime string `json:"setl_time"`
  21787. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21788. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21789. MedType string `json:"med_type"`
  21790. SetlType string `json:"setl_type,omitempty"`
  21791. ClrType string `json:"clr_type,omitempty"`
  21792. ClrWay string `json:"clr_way,omitempty"`
  21793. PsnSetlway string `json:"psn_setlway,omitempty"`
  21794. ClrOptins string `json:"clr_optins,omitempty"`
  21795. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21796. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21797. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21798. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21799. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21800. DedcStd float64 `json:"dedc_std,omitempty"`
  21801. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21802. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21803. HifpPay float64 `json:"hifp_pay,omitempty"`
  21804. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21805. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21806. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21807. HifesPay float64 `json:"hifes_pay,omitempty"`
  21808. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  21809. HifobPay float64 `json:"hifob_pay,omitempty"`
  21810. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  21811. MafPay float64 `json:"maf_pay,omitempty"`
  21812. OthfundPay float64 `json:"othfund_pay,omitempty"`
  21813. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  21814. PsnPay float64 `json:"psn_pay,omitempty"`
  21815. AcctPay float64 `json:"acct_pay,omitempty"`
  21816. CashPayamt float64 `json:"cash_payamt,omitempty"`
  21817. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  21818. Balc float64 `json:"balc,omitempty"`
  21819. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  21820. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  21821. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  21822. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  21823. Year string `json:"year,omitempty"`
  21824. DiseNo string `json:"dise_no,omitempty"`
  21825. DiseName string `json:"dise_name,omitempty"`
  21826. Invono string `json:"invono,omitempty"`
  21827. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  21828. ValiFlag string `json:"vali_flag,omitempty"`
  21829. Memo string `json:"memo,omitempty"`
  21830. Rid string `json:"rid"`
  21831. UpdtTime string `json:"updt_time,omitempty"`
  21832. CrterID string `json:"crter_id,omitempty"`
  21833. CrterName string `json:"crter_name,omitempty"`
  21834. CrteTime string `json:"crte_time,omitempty"`
  21835. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  21836. OpterID string `json:"opter_id,omitempty"`
  21837. OpterName string `json:"opter_name,omitempty"`
  21838. OptTime string `json:"opt_time,omitempty"`
  21839. OptinsNo string `json:"optins_no,omitempty"`
  21840. PoolareaNo string `json:"poolarea_no,omitempty"`
  21841. } `json:"result"`
  21842. } `json:"output"`
  21843. RefmsgTime string `json:"refmsg_time"`
  21844. RespondTime string `json:"respond_time"`
  21845. Signtype interface{} `json:"signtype"`
  21846. WarnInfo interface{} `json:"warn_info"`
  21847. }
  21848. type Result5267 struct {
  21849. ErrMsg string `json:"err_msg"`
  21850. InfRefmsgid string `json:"inf_refmsgid"`
  21851. Infcode int64 `json:"infcode"`
  21852. Output struct {
  21853. PageInfo struct {
  21854. Size int `json:"size"`
  21855. RecordCounts int `json:"record_counts"`
  21856. } `json:"pageinfo"`
  21857. Result []struct {
  21858. SetlID string `json:"setl_id"`
  21859. ClrOptins string `json:"clr_optins"`
  21860. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21861. MdtrtID string `json:"mdtrt_id"`
  21862. InitSetlID string `json:"init_setl_id,omitempty"`
  21863. PsnNo string `json:"psn_no"`
  21864. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21865. PsnName string `json:"psn_name"`
  21866. PsnCertType string `json:"psn_cert_type"`
  21867. Certno string `json:"certno"`
  21868. Gend string `json:"gend,omitempty"`
  21869. Naty string `json:"naty,omitempty"`
  21870. Brdy string `json:"brdy,omitempty"`
  21871. Age float64 `json:"age,omitempty"`
  21872. Insutype string `json:"insutype,omitempty"`
  21873. PsnType string `json:"psn_type"`
  21874. CvlservFlag string `json:"cvlserv_flag"`
  21875. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21876. SpPsnType string `json:"sp_psn_type,omitempty"`
  21877. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21878. ClctGrde string `json:"clct_grde,omitempty"`
  21879. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21880. NwbFlag string `json:"nwb_flag,omitempty"`
  21881. InsuAdmdvs string `json:"insu_admdvs"`
  21882. EmpNo string `json:"emp_no,omitempty"`
  21883. EmpName string `json:"emp_name,omitempty"`
  21884. EmpType string `json:"emp_type,omitempty"`
  21885. EconType string `json:"econ_type,omitempty"`
  21886. AfilIndu string `json:"afil_indu,omitempty"`
  21887. AfilRlts string `json:"afil_rlts,omitempty"`
  21888. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21889. PayLoc string `json:"pay_loc,omitempty"`
  21890. FixmedinsCode string `json:"fixmedins_code"`
  21891. FixmedinsName string `json:"fixmedins_name"`
  21892. HospLv string `json:"hosp_lv,omitempty"`
  21893. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21894. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21895. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21896. Begndate string `json:"begndate,omitempty"`
  21897. Enddate string `json:"enddate,omitempty"`
  21898. SetlTime string `json:"setl_time,omitempty"`
  21899. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21900. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21901. MedType string `json:"med_type"`
  21902. SetlType string `json:"setl_type,omitempty"`
  21903. ClrType string `json:"clr_type,omitempty"`
  21904. ClrWay string `json:"clr_way,omitempty"`
  21905. PsnSetlway string `json:"psn_setlway,omitempty"`
  21906. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21907. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21908. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21909. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21910. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21911. DedcStd float64 `json:"dedc_std,omitempty"`
  21912. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21913. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21914. HifpPay float64 `json:"hifp_pay,omitempty"`
  21915. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21916. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21917. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21918. HifesPay float64 `json:"hifes_pay,omitempty"`
  21919. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  21920. HifobPay float64 `json:"hifob_pay,omitempty"`
  21921. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  21922. MafPay float64 `json:"maf_pay,omitempty"`
  21923. OthfundPay float64 `json:"othfund_pay,omitempty"`
  21924. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  21925. PsnPay float64 `json:"psn_pay,omitempty"`
  21926. AcctPay float64 `json:"acct_pay,omitempty"`
  21927. CashPayamt float64 `json:"cash_payamt,omitempty"`
  21928. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  21929. Balc float64 `json:"balc,omitempty"`
  21930. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  21931. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  21932. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  21933. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  21934. Year string `json:"year,omitempty"`
  21935. DiseNo string `json:"dise_no,omitempty"`
  21936. DiseName string `json:"dise_name,omitempty"`
  21937. Invono string `json:"invono,omitempty"`
  21938. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  21939. Memo string `json:"memo,omitempty"`
  21940. UpdtTime string `json:"updt_time,omitempty"`
  21941. OpterID string `json:"opter_id,omitempty"`
  21942. OpterName string `json:"opter_name,omitempty"`
  21943. OptTime string `json:"opt_time,omitempty"`
  21944. OptinsNo string `json:"optins_no,omitempty"`
  21945. PoolareaNo string `json:"poolarea_no,omitempty"`
  21946. } `json:"result"`
  21947. } `json:"output"`
  21948. RefmsgTime string `json:"refmsg_time"`
  21949. RespondTime string `json:"respond_time"`
  21950. Signtype interface{} `json:"signtype"`
  21951. WarnInfo interface{} `json:"warn_info"`
  21952. }
  21953. // type Autogenerated struct {
  21954. // Output struct {
  21955. // Setlinfo struct {
  21956. // SetlTime string `json:"setl_time"`
  21957. // CvlservPay float64 `json:"cvlserv_pay"`
  21958. // Year string `json:"year"`
  21959. // MedType string `json:"med_type"`
  21960. // PsnPay float64 `json:"psn_pay"`
  21961. // OpterID string `json:"opter_id"`
  21962. // Begndate string `json:"begndate"`
  21963. // FlxempeFlag string `json:"flxempe_flag"`
  21964. // HifmiPay float64 `json:"hifmi_pay"`
  21965. // PsnNo string `json:"psn_no"`
  21966. // ActPayDedc float64 `json:"act_pay_dedc"`
  21967. // MedinsSetlID interface{} `json:"medins_setl_id"`
  21968. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21969. // ClrWay string `json:"clr_way"`
  21970. // OthPay float64 `json:"oth_pay"`
  21971. // Gend string `json:"gend"`
  21972. // MdtrtID string `json:"mdtrt_id"`
  21973. // AcctPay float64 `json:"acct_pay"`
  21974. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  21975. // Insutype string `json:"insutype"`
  21976. // Invono interface{} `json:"invono"`
  21977. // Enddate string `json:"enddate"`
  21978. // CashPayamt float64 `json:"cash_payamt"`
  21979. // PsnType string `json:"psn_type"`
  21980. // FixmedinsName string `json:"fixmedins_name"`
  21981. // HifpPay float64 `json:"hifp_pay"`
  21982. // NewFlag interface{} `json:"new_flag"`
  21983. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21984. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  21985. // PayLoc string `json:"pay_loc"`
  21986. // ClrType string `json:"clr_type"`
  21987. // RefdSetlFlag string `json:"refd_setl_flag"`
  21988. // CvlservFlag string `json:"cvlserv_flag"`
  21989. // EmpName string `json:"emp_name"`
  21990. // Brdy string `json:"brdy"`
  21991. // Naty string `json:"naty"`
  21992. // Certno string `json:"certno"`
  21993. // DiseCode string `json:"dise_code"`
  21994. // FixmedinsCode string `json:"fixmedins_code"`
  21995. // DedcHospLv string `json:"dedc_hosp_lv"`
  21996. // OpterName string `json:"opter_name"`
  21997. // Balc float64 `json:"balc"`
  21998. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21999. // PsnCertType string `json:"psn_cert_type"`
  22000. // HifobPay float64 `json:"hifob_pay"`
  22001. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22002. // HifesPay float64 `json:"hifes_pay"`
  22003. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22004. // OptTime string `json:"opt_time"`
  22005. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22006. // SetlID string `json:"setl_id"`
  22007. // MafPay float64 `json:"maf_pay"`
  22008. // PsnName string `json:"psn_name"`
  22009. // InsuOptins interface{} `json:"insu_optins"`
  22010. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22011. // ClrOptins string `json:"clr_optins"`
  22012. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22013. // DiseName string `json:"dise_name"`
  22014. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22015. // Age float64 `json:"age"`
  22016. // DtrtCertType string `json:"dtrt_cert_type"`
  22017. // HospLv string `json:"hosp_lv"`
  22018. // } `json:"setlinfo"`
  22019. // Setldetail []struct {
  22020. // FundPayType string `json:"fund_pay_type"`
  22021. // FundPayamt float64 `json:"fund_payamt"`
  22022. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22023. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22024. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22025. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22026. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22027. // } `json:"setldetail"`
  22028. // } `json:"output"`
  22029. // Infcode int `json:"infcode"`
  22030. // WarnMsg interface{} `json:"warn_msg"`
  22031. // Cainfo interface{} `json:"cainfo"`
  22032. // ErrMsg interface{} `json:"err_msg"`
  22033. // RefmsgTime string `json:"refmsg_time"`
  22034. // Signtype interface{} `json:"signtype"`
  22035. // RespondTime string `json:"respond_time"`
  22036. // InfRefmsgid string `json:"inf_refmsgid"`
  22037. // }
  22038. type Result002 struct {
  22039. Cainfo interface{} `json:"cainfo"`
  22040. ErrMsg string `json:"err_msg"`
  22041. InfRefmsgid string `json:"inf_refmsgid"`
  22042. Infcode int64 `json:"infcode"`
  22043. Output struct {
  22044. RxFile string `json:"rx_file"`
  22045. SignDigest string `json:"sign_digest"`
  22046. SignCertSn string `json:"sign_cert_sn"`
  22047. SignCertDn string `json:"sign_cert_dn"`
  22048. } `json:"output"`
  22049. RefmsgTime string `json:"refmsg_time"`
  22050. RespondTime string `json:"respond_time"`
  22051. Signtype interface{} `json:"signtype"`
  22052. WarnMsg interface{} `json:"warn_msg"`
  22053. }
  22054. type Result003 struct {
  22055. Cainfo interface{} `json:"cainfo"`
  22056. ErrMsg string `json:"err_msg"`
  22057. InfRefmsgid string `json:"inf_refmsgid"`
  22058. Infcode int64 `json:"infcode"`
  22059. Output struct {
  22060. HiRxno string `json:"hi_rxno"`
  22061. RxStasCodg string `json:"rx_stas_codg"`
  22062. RxStasName string `json:"rx_stas_name"`
  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 ResultEleven struct {
  22070. Cainfo string `json:"cainfo"`
  22071. ErrMsg string `json:"err_msg"`
  22072. InfRefmsgid string `json:"inf_refmsgid"`
  22073. Infcode int64 `json:"infcode"`
  22074. Output struct {
  22075. Setlinfo struct {
  22076. SetlTime string `json:"setl_time"`
  22077. CvlservPay float64 `json:"cvlserv_pay"`
  22078. Year string `json:"year"`
  22079. MedType string `json:"med_type"`
  22080. PsnPay float64 `json:"psn_pay"`
  22081. OpterID string `json:"opter_id"`
  22082. Begndate string `json:"begndate"`
  22083. FlxempeFlag string `json:"flxempe_flag"`
  22084. HifmiPay float64 `json:"hifmi_pay"`
  22085. PsnNo string `json:"psn_no"`
  22086. ActPayDedc float64 `json:"act_pay_dedc"`
  22087. MedinsSetlID interface{} `json:"medins_setl_id"`
  22088. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22089. ClrWay string `json:"clr_way"`
  22090. OthPay float64 `json:"oth_pay"`
  22091. Gend string `json:"gend"`
  22092. MdtrtID string `json:"mdtrt_id"`
  22093. AcctPay float64 `json:"acct_pay"`
  22094. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22095. Insutype string `json:"insutype"`
  22096. Invono interface{} `json:"invono"`
  22097. Enddate string `json:"enddate"`
  22098. CashPayamt float64 `json:"cash_payamt"`
  22099. PsnType string `json:"psn_type"`
  22100. FixmedinsName string `json:"fixmedins_name"`
  22101. HifpPay float64 `json:"hifp_pay"`
  22102. NewFlag interface{} `json:"new_flag"`
  22103. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22104. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22105. PayLoc string `json:"pay_loc"`
  22106. ClrType string `json:"clr_type"`
  22107. RefdSetlFlag string `json:"refd_setl_flag"`
  22108. CvlservFlag string `json:"cvlserv_flag"`
  22109. EmpName string `json:"emp_name"`
  22110. Brdy string `json:"brdy"`
  22111. Naty string `json:"naty"`
  22112. Certno string `json:"certno"`
  22113. DiseCode string `json:"dise_code"`
  22114. FixmedinsCode string `json:"fixmedins_code"`
  22115. DedcHospLv string `json:"dedc_hosp_lv"`
  22116. OpterName string `json:"opter_name"`
  22117. Balc float64 `json:"balc"`
  22118. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22119. PsnCertType string `json:"psn_cert_type"`
  22120. HifobPay float64 `json:"hifob_pay"`
  22121. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22122. HifesPay float64 `json:"hifes_pay"`
  22123. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22124. OptTime string `json:"opt_time"`
  22125. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22126. SetlID string `json:"setl_id"`
  22127. MafPay float64 `json:"maf_pay"`
  22128. PsnName string `json:"psn_name"`
  22129. InsuOptins interface{} `json:"insu_optins"`
  22130. PrefFundPay interface{} `json:"pref_fund_pay"`
  22131. ClrOptins string `json:"clr_optins"`
  22132. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22133. DiseName string `json:"dise_name"`
  22134. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22135. Age float64 `json:"age"`
  22136. DtrtCertType string `json:"dtrt_cert_type"`
  22137. HospLv string `json:"hosp_lv"`
  22138. PsnCashPay float64 `json:"psn_cash_pay"`
  22139. } `json:"setlinfo"`
  22140. } `json:"output"`
  22141. RefmsgTime string `json:"refmsg_time"`
  22142. RespondTime string `json:"respond_time"`
  22143. Signtype interface{} `json:"signtype"`
  22144. WarnMsg interface{} `json:"warn_msg"`
  22145. }
  22146. type ResultElevenah struct {
  22147. Cainfo string `json:"cainfo"`
  22148. ErrMsg string `json:"err_msg"`
  22149. InfRefmsgid string `json:"inf_refmsgid"`
  22150. Infcode int64 `json:"infcode"`
  22151. Output struct {
  22152. Setlinfo struct {
  22153. SetlTime int64 `json:"setl_time"`
  22154. CvlservPay float64 `json:"cvlserv_pay"`
  22155. Year string `json:"year"`
  22156. MedType string `json:"med_type"`
  22157. PsnPay float64 `json:"psn_pay"`
  22158. OpterID string `json:"opter_id"`
  22159. Begndate int64 `json:"begndate"`
  22160. FlxempeFlag string `json:"flxempe_flag"`
  22161. HifmiPay float64 `json:"hifmi_pay"`
  22162. PsnNo string `json:"psn_no"`
  22163. ActPayDedc float64 `json:"act_pay_dedc"`
  22164. MedinsSetlID interface{} `json:"medins_setl_id"`
  22165. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22166. ClrWay string `json:"clr_way"`
  22167. OthPay float64 `json:"oth_pay"`
  22168. Gend string `json:"gend"`
  22169. MdtrtID string `json:"mdtrt_id"`
  22170. AcctPay float64 `json:"acct_pay"`
  22171. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22172. Insutype string `json:"insutype"`
  22173. Invono interface{} `json:"invono"`
  22174. Enddate int64 `json:"enddate"`
  22175. CashPayamt float64 `json:"cash_payamt"`
  22176. PsnType string `json:"psn_type"`
  22177. FixmedinsName string `json:"fixmedins_name"`
  22178. HifpPay float64 `json:"hifp_pay"`
  22179. NewFlag interface{} `json:"new_flag"`
  22180. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22181. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22182. PayLoc string `json:"pay_loc"`
  22183. ClrType string `json:"clr_type"`
  22184. RefdSetlFlag string `json:"refd_setl_flag"`
  22185. CvlservFlag string `json:"cvlserv_flag"`
  22186. EmpName string `json:"emp_name"`
  22187. Brdy int64 `json:"brdy"`
  22188. Naty string `json:"naty"`
  22189. Certno string `json:"certno"`
  22190. DiseCode string `json:"dise_code"`
  22191. FixmedinsCode string `json:"fixmedins_code"`
  22192. DedcHospLv string `json:"dedc_hosp_lv"`
  22193. OpterName string `json:"opter_name"`
  22194. Balc float64 `json:"balc"`
  22195. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22196. PsnCertType string `json:"psn_cert_type"`
  22197. HifobPay float64 `json:"hifob_pay"`
  22198. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22199. HifesPay float64 `json:"hifes_pay"`
  22200. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22201. OptTime int64 `json:"opt_time"`
  22202. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22203. SetlID string `json:"setl_id"`
  22204. MafPay float64 `json:"maf_pay"`
  22205. PsnName string `json:"psn_name"`
  22206. InsuOptins interface{} `json:"insu_optins"`
  22207. PrefFundPay interface{} `json:"pref_fund_pay"`
  22208. ClrOptins string `json:"clr_optins"`
  22209. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22210. DiseName string `json:"dise_name"`
  22211. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22212. Age float64 `json:"age"`
  22213. DtrtCertType string `json:"dtrt_cert_type"`
  22214. HospLv string `json:"hosp_lv"`
  22215. PsnCashPay float64 `json:"psn_cash_pay"`
  22216. } `json:"setlinfo"`
  22217. } `json:"output"`
  22218. RefmsgTime string `json:"refmsg_time"`
  22219. RespondTime string `json:"respond_time"`
  22220. Signtype interface{} `json:"signtype"`
  22221. WarnMsg interface{} `json:"warn_msg"`
  22222. }
  22223. type ResultEleven10265 struct {
  22224. Cainfo string `json:"cainfo"`
  22225. ErrMsg string `json:"err_msg"`
  22226. InfRefmsgid string `json:"inf_refmsgid"`
  22227. Infcode string `json:"infcode"`
  22228. Output struct {
  22229. Setlinfo struct {
  22230. SetlTime string `json:"setl_time"`
  22231. CvlservPay float64 `json:"cvlserv_pay"`
  22232. Year string `json:"year"`
  22233. MedType string `json:"med_type"`
  22234. PsnPay float64 `json:"psn_pay"`
  22235. OpterID string `json:"opter_id"`
  22236. Begndate string `json:"begndate"`
  22237. FlxempeFlag string `json:"flxempe_flag"`
  22238. HifmiPay float64 `json:"hifmi_pay"`
  22239. PsnNo string `json:"psn_no"`
  22240. ActPayDedc float64 `json:"act_pay_dedc"`
  22241. MedinsSetlID interface{} `json:"medins_setl_id"`
  22242. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22243. ClrWay string `json:"clr_way"`
  22244. OthPay float64 `json:"oth_pay"`
  22245. Gend string `json:"gend"`
  22246. MdtrtID string `json:"mdtrt_id"`
  22247. AcctPay float64 `json:"acct_pay"`
  22248. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22249. Insutype string `json:"insutype"`
  22250. Invono interface{} `json:"invono"`
  22251. Enddate string `json:"enddate"`
  22252. CashPayamt float64 `json:"cash_payamt"`
  22253. PsnType string `json:"psn_type"`
  22254. FixmedinsName string `json:"fixmedins_name"`
  22255. HifpPay float64 `json:"hifp_pay"`
  22256. NewFlag interface{} `json:"new_flag"`
  22257. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22258. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22259. PayLoc string `json:"pay_loc"`
  22260. ClrType string `json:"clr_type"`
  22261. RefdSetlFlag string `json:"refd_setl_flag"`
  22262. CvlservFlag string `json:"cvlserv_flag"`
  22263. EmpName string `json:"emp_name"`
  22264. Brdy string `json:"brdy"`
  22265. Naty string `json:"naty"`
  22266. Certno string `json:"certno"`
  22267. DiseCode string `json:"dise_code"`
  22268. FixmedinsCode string `json:"fixmedins_code"`
  22269. DedcHospLv string `json:"dedc_hosp_lv"`
  22270. OpterName string `json:"opter_name"`
  22271. Balc float64 `json:"balc"`
  22272. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22273. PsnCertType string `json:"psn_cert_type"`
  22274. HifobPay float64 `json:"hifob_pay"`
  22275. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22276. HifesPay float64 `json:"hifes_pay"`
  22277. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22278. OptTime string `json:"opt_time"`
  22279. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22280. SetlID string `json:"setl_id"`
  22281. MafPay float64 `json:"maf_pay"`
  22282. PsnName string `json:"psn_name"`
  22283. InsuOptins interface{} `json:"insu_optins"`
  22284. PrefFundPay interface{} `json:"pref_fund_pay"`
  22285. ClrOptins string `json:"clr_optins"`
  22286. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22287. DiseName string `json:"dise_name"`
  22288. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22289. Age float64 `json:"age"`
  22290. DtrtCertType string `json:"dtrt_cert_type"`
  22291. HospLv string `json:"hosp_lv"`
  22292. PsnCashPay float64 `json:"psn_cash_pay"`
  22293. } `json:"setlinfo"`
  22294. } `json:"output"`
  22295. RefmsgTime string `json:"refmsg_time"`
  22296. RespondTime string `json:"respond_time"`
  22297. Signtype interface{} `json:"signtype"`
  22298. WarnMsg interface{} `json:"warn_msg"`
  22299. }
  22300. type ResultTwelve struct {
  22301. Cainfo string `json:"cainfo"`
  22302. ErrMsg string `json:"err_msg"`
  22303. InfRefmsgid string `json:"inf_refmsgid"`
  22304. Infcode int64 `json:"infcode"`
  22305. Output struct {
  22306. MdtrtId string `json:"mdtrt_id"`
  22307. ChrgBchno string `json:"chrg_bchno"`
  22308. PsnNo string `json:"psn_no"`
  22309. } `json:"output"`
  22310. RefmsgTime string `json:"refmsg_time"`
  22311. RespondTime string `json:"respond_time"`
  22312. Signtype interface{} `json:"signtype"`
  22313. WarnMsg interface{} `json:"warn_msg"`
  22314. }
  22315. type ResultThirteen struct {
  22316. ErrMsg string `json:"err_msg"`
  22317. InfRefmsgid string `json:"inf_refmsgid"`
  22318. Infcode int64 `json:"infcode"`
  22319. Output struct {
  22320. Result struct {
  22321. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22322. } `json:"result"`
  22323. } `json:"output"`
  22324. RefmsgTime string `json:"refmsg_time"`
  22325. RespondTime string `json:"respond_time"`
  22326. Signtype interface{} `json:"signtype"`
  22327. WarnInfo interface{} `json:"warn_info"`
  22328. }
  22329. type ResultThirteen10265 struct {
  22330. ErrMsg string `json:"err_msg"`
  22331. InfRefmsgid string `json:"inf_refmsgid"`
  22332. Infcode string `json:"infcode"`
  22333. Output struct {
  22334. Result struct {
  22335. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22336. } `json:"result"`
  22337. } `json:"output"`
  22338. RefmsgTime string `json:"refmsg_time"`
  22339. RespondTime string `json:"respond_time"`
  22340. Signtype interface{} `json:"signtype"`
  22341. WarnInfo interface{} `json:"warn_info"`
  22342. }
  22343. type ResultFourteen struct {
  22344. ErrMsg string `json:"err_msg"`
  22345. InfRefmsgid string `json:"inf_refmsgid"`
  22346. Infcode int64 `json:"infcode"`
  22347. Output struct {
  22348. } `json:"output"`
  22349. RefmsgTime string `json:"refmsg_time"`
  22350. RespondTime string `json:"respond_time"`
  22351. Signtype interface{} `json:"signtype"`
  22352. WarnInfo interface{} `json:"warn_info"`
  22353. }
  22354. type ResultCFYLJG001 struct {
  22355. ErrMsg string `json:"err_msg"`
  22356. InfRefmsgid string `json:"inf_refmsgid"`
  22357. Infcode int64 `json:"infcode"`
  22358. Output struct {
  22359. RxTraceCode string `json:"rx_trace_code"`
  22360. HiRxno string `json:"hi_rxno"`
  22361. } `json:"output"`
  22362. RefmsgTime string `json:"refmsg_time"`
  22363. RespondTime string `json:"respond_time"`
  22364. Signtype interface{} `json:"signtype"`
  22365. WarnInfo interface{} `json:"warn_info"`
  22366. }
  22367. type ResultCFYLJG007 struct {
  22368. ErrMsg string `json:"err_msg"`
  22369. InfRefmsgid string `json:"inf_refmsgid"`
  22370. Infcode int64 `json:"infcode"`
  22371. Output struct {
  22372. HiRxno string `json:"hi_rxno"`
  22373. RxStasName string `json:"rx_stas_name"`
  22374. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22375. Seltdelts []interface{} `json:"seltdelts"`
  22376. RxUsedStasName string `json:"rx_used_stas_name"`
  22377. RxStasCodg string `json:"rx_stas_codg"`
  22378. } `json:"output"`
  22379. RefmsgTime string `json:"refmsg_time"`
  22380. RespondTime string `json:"respond_time"`
  22381. Signtype interface{} `json:"signtype"`
  22382. WarnInfo interface{} `json:"warn_info"`
  22383. }
  22384. type ResultCFYLJG002 struct {
  22385. ErrMsg string `json:"err_msg"`
  22386. InfRefmsgid string `json:"inf_refmsgid"`
  22387. Infcode int64 `json:"infcode"`
  22388. Output struct {
  22389. RxFile string `json:"rx_file"`
  22390. SignDigest string `json:"sign_digest"`
  22391. SignCertSn string `json:"sign_cert_sn"`
  22392. SignCertDn string `json:"sign_cert_dn"`
  22393. } `json:"output"`
  22394. RefmsgTime string `json:"refmsg_time"`
  22395. RespondTime string `json:"respond_time"`
  22396. Signtype interface{} `json:"signtype"`
  22397. WarnInfo interface{} `json:"warn_info"`
  22398. }
  22399. type ResultCFYLJG003 struct {
  22400. ErrMsg string `json:"err_msg"`
  22401. InfRefmsgid string `json:"inf_refmsgid"`
  22402. Infcode int64 `json:"infcode"`
  22403. Output struct {
  22404. HiRxno string `json:"hi_rxno"`
  22405. RxStasCodg string `json:"rx_stas_codg"`
  22406. RxStasName string `json:"rx_stas_name"`
  22407. } `json:"output"`
  22408. RefmsgTime string `json:"refmsg_time"`
  22409. RespondTime string `json:"respond_time"`
  22410. Signtype interface{} `json:"signtype"`
  22411. WarnInfo interface{} `json:"warn_info"`
  22412. }
  22413. type ResultCFYLJG004 struct {
  22414. ErrMsg string `json:"err_msg"`
  22415. InfRefmsgid string `json:"inf_refmsgid"`
  22416. Infcode int64 `json:"infcode"`
  22417. Output struct {
  22418. HiRxno string `json:"hi_rxno"`
  22419. RxStasCodg string `json:"rx_stas_codg"`
  22420. RxStasName string `json:"rx_stas_name"`
  22421. } `json:"output"`
  22422. RefmsgTime string `json:"refmsg_time"`
  22423. RespondTime string `json:"respond_time"`
  22424. Signtype interface{} `json:"signtype"`
  22425. WarnInfo interface{} `json:"warn_info"`
  22426. }
  22427. type ResultCFYLJG008 struct {
  22428. ErrMsg string `json:"err_msg"`
  22429. InfRefmsgid string `json:"inf_refmsgid"`
  22430. Infcode int64 `json:"infcode"`
  22431. Output struct {
  22432. PoolareaNo string `json:"poolareaNo"`
  22433. AdmdvsName string `json:"admdvsName"`
  22434. Count string `json:"count"`
  22435. } `json:"output"`
  22436. RefmsgTime string `json:"refmsg_time"`
  22437. RespondTime string `json:"respond_time"`
  22438. Signtype interface{} `json:"signtype"`
  22439. WarnInfo interface{} `json:"warn_info"`
  22440. }
  22441. type ResultCFYLJG005 struct {
  22442. ErrMsg string `json:"err_msg"`
  22443. InfRefmsgid string `json:"inf_refmsgid"`
  22444. Infcode int64 `json:"infcode"`
  22445. Output struct {
  22446. HiRxNo string `json:"hi_rxno"`
  22447. FixMedinsCode string `json:"fixmedins_code"`
  22448. FixMedinsName string `json:"fixmedins_name"`
  22449. RxStasCodg string `json:"rx_stas_codg"`
  22450. RxStasName string `json:"rx_stas_name"`
  22451. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22452. RxUserdStasName string `json:"rx_userd_stas_name"`
  22453. PrscTime string `json:"prsc_time"`
  22454. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22455. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22456. RxUsedWayName string `json:"rx_used_way_name"`
  22457. RxFrquCodg string `json:"rx_frqu_codg"`
  22458. RxFrquName string `json:"rx_frqu_name"`
  22459. RxDosunt string `json:"rx_dosunt"`
  22460. RxDoscnt float64 `json:"rx_doscnt"`
  22461. RxDrordDscr string `json:"rx_drord_dscr"`
  22462. ValiDays int64 `json:"vali_days"`
  22463. ValiEndTime string `json:"vali_end_time"`
  22464. ReptFlag string `json:"rept_flag"`
  22465. MaxReptCnt int64 `json:"max_rept_cnt"`
  22466. ReptdCnt int64 `json:"reptd_cnt"`
  22467. MinInrvDays int64 `json:"min_inrv_days"`
  22468. RxTypeCode string `json:"rx_type_code"`
  22469. RxTypeName string `json:"rx_type_name"`
  22470. LongRxFlag string `json:"long_rx_flag"`
  22471. RxDetlList []struct {
  22472. MedListCodg string `json:"med_list_codg"`
  22473. MedinsListCodg string `json:"medins_list_codg"`
  22474. HospPrepFlag string `json:"hosp_prep_flag"`
  22475. RxItemTypeCode string `json:"rx_item_type_code"`
  22476. RxItemTypeName string `json:"rx_item_type_name"`
  22477. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22478. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22479. TcmHerbFoote string `json:"tcmherb_foote"`
  22480. MednTypeCode string `json:"medn_type_code"`
  22481. MednTypeName string `json:"medn_type_name"`
  22482. MainMedcFlag string `json:"main_medc_flag"`
  22483. UrgtFlag string `json:"urgt_flag"`
  22484. BasMednFlag string `json:"bas_medn_flag"`
  22485. ImpDrugFlag string `json:"imp_drug_flag"`
  22486. ProdBarc string `json:"prod_barc"`
  22487. DrugProdname string `json:"drug_prodname"`
  22488. GennameCodg string `json:"genname_codg"`
  22489. DrugGenname string `json:"drug_genname"`
  22490. DrugDosform string `json:"drug_dosform"`
  22491. DrugSpec string `json:"drug_spec"`
  22492. PrdrName string `json:"prdr_name"`
  22493. MedcWayCodg string `json:"medc_way_codg"`
  22494. MedcWayDscr string `json:"medc_way_dscr"`
  22495. MedcBegntime string `json:"medc_begntime"`
  22496. MedcEndtime string `json:"medc_endtime"`
  22497. MedcDays float64 `json:"medc_days"`
  22498. DrugPric float64 `json:"drug_pric"`
  22499. DrugSumamt float64 `json:"drug_sumamt"`
  22500. DrugCnt float64 `json:"drug_cnt"`
  22501. DrugDosunt string `json:"drug_dosunt"`
  22502. SinDoscnt float64 `json:"sin_doscnt"`
  22503. SinDosunt string `json:"sin_dosunt"`
  22504. UsedFrquCodg string `json:"used_frqu_codg"`
  22505. UsedFrquName string `json:"used_frqu_name"`
  22506. DrugTotlcnt string `json:"drug_totlcnt"`
  22507. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22508. DiseCodg string `json:"dise_codg"`
  22509. HospApprFlag string `json:"hosp_appr_flag"`
  22510. } `json:"rx_detl_list"`
  22511. RxOtpinfo struct {
  22512. MedType string `json:"med_type"`
  22513. IptOtpNo string `json:"ipt_otp_no"`
  22514. OtpIptFlag string `json:"otp_ipt_flag"`
  22515. PatnName string `json:"patn_name"`
  22516. PatnAge float64 `json:"patn_age"`
  22517. PatnHgt float64 `json:"patn_hgt"`
  22518. PatnWt float64 `json:"patn_wt"`
  22519. Gend string `json:"gend"`
  22520. GesoVal float64 `json:"geso_val"`
  22521. NwbFlag string `json:"nwb_flag"`
  22522. NwbAge string `json:"nwb_age"`
  22523. SuckPrdFlag string `json:"suck_prd_flag"`
  22524. AlgsHis string `json:"algs_his"`
  22525. Insutype string `json:"insutype"`
  22526. PrscDeptName string `json:"prsc_dept_name"`
  22527. PrscDrName string `json:"prsc_dr_name"`
  22528. PharName string `json:"phar_name"`
  22529. PharChkTime string `json:"phar_chk_time"`
  22530. MdtrtTime string `json:"mdtrt_time"`
  22531. DiseCodg string `json:"dise_codg"`
  22532. DiseName string `json:"dise_name"`
  22533. SpDiseFlag string `json:"sp_dise_flag"`
  22534. MaindiagCode string `json:"maindiag_code"`
  22535. MaindiagName string `json:"maindiag_name"`
  22536. DiseCondDscr string `json:"dise_cond_dscr"`
  22537. FstdiagFlag string `json:"fstdiag_flag"`
  22538. } `json:"rx_otpinfo"`
  22539. RxDiseList []struct {
  22540. DiagType string `json:"diag_type"`
  22541. MaindiagFlag string `json:"maindiag_flag"`
  22542. DiagSrtNo string `json:"diag_srt_no"`
  22543. DiagCode string `json:"diag_code"`
  22544. DiagName string `json:"diag_name"`
  22545. DiagDept string `json:"diag_dept"`
  22546. DiagDrNo string `json:"diag_dr_no"`
  22547. DiagDrName string `json:"diag_dr_name"`
  22548. DiagTime string `json:"diag_time"`
  22549. TcmDiseCode string `json:"tcm_dise_code"`
  22550. TcmDiseName string `json:"tcm_dise_name"`
  22551. TcmSympCode string `json:"tcmsymp_code"`
  22552. TcmSymp string `json:"tcmsymp"`
  22553. } `json:"rx_dise_list"`
  22554. } `json:"output"`
  22555. RefmsgTime string `json:"refmsg_time"`
  22556. RespondTime string `json:"respond_time"`
  22557. Signtype interface{} `json:"signtype"`
  22558. WarnInfo interface{} `json:"warn_info"`
  22559. }
  22560. type ResultCFYLJG006 struct {
  22561. ErrMsg string `json:"err_msg"`
  22562. InfRefmsgid string `json:"inf_refmsgid"`
  22563. Infcode int64 `json:"infcode"`
  22564. Output struct {
  22565. HiRxNo string `json:"hi_rxno"`
  22566. PharCode string `json:"phar_code"`
  22567. PharName string `json:"phar_name"`
  22568. RxChkOpnn string `json:"rx_chk_opnn"`
  22569. RxChkTime string `json:"rx_chk_time"`
  22570. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22571. RxChkStasName string `json:"rx_chk_stas_name"`
  22572. RxStasCodg string `json:"rx_stas_codg"`
  22573. RxStasName string `json:"rx_stas_name"`
  22574. } `json:"output"`
  22575. RefmsgTime string `json:"refmsg_time"`
  22576. RespondTime string `json:"respond_time"`
  22577. Signtype interface{} `json:"signtype"`
  22578. WarnInfo interface{} `json:"warn_info"`
  22579. }
  22580. type ResultFourteen10265 struct {
  22581. ErrMsg string `json:"err_msg"`
  22582. InfRefmsgid string `json:"inf_refmsgid"`
  22583. Infcode string `json:"infcode"`
  22584. Output struct {
  22585. } `json:"output"`
  22586. RefmsgTime string `json:"refmsg_time"`
  22587. RespondTime string `json:"respond_time"`
  22588. Signtype interface{} `json:"signtype"`
  22589. WarnInfo interface{} `json:"warn_info"`
  22590. }
  22591. type ResultSixteen struct {
  22592. Cainfo string `json:"cainfo"`
  22593. ErrMsg string `json:"err_msg"`
  22594. InfRefmsgid string `json:"inf_refmsgid"`
  22595. Infcode int64 `json:"infcode"`
  22596. Output struct {
  22597. Setlinfo struct {
  22598. MdtrtID string `json:"mdtrt_id"`
  22599. SetlID string `json:"setl_id"`
  22600. ClrOptins string `json:"clr_optins"`
  22601. SetlTime string `json:"setl_time"`
  22602. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22603. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22604. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22605. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22606. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22607. ActPayDedc float64 `json:"act_pay_dedc"`
  22608. HifpPay float64 `json:"hifp_pay"`
  22609. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22610. Lfpay float64 `json:"selfpay"`
  22611. CvlservPay float64 `json:"cvlserv_pay"`
  22612. HifesPay float64 `json:"hifes_pay"`
  22613. HifmiPay float64 `json:"hifmi_pay"`
  22614. HifobPay float64 `json:"hifob_pay"`
  22615. MafPay float64 `json:"maf_pay"`
  22616. OthPay float64 `json:"oth_pay"`
  22617. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22618. PsnPartAmt float64 `json:"psn_part_amt"`
  22619. AcctPay float64 `json:"acct_pay"`
  22620. Balc float64 `json:"balc"`
  22621. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22622. HospPartAmt float64 `json:"hosp_part_amt"`
  22623. MedinsSetlID string `json:"medins_setl_id"`
  22624. PdnCashPay string `json:"pdn_cash_pay"`
  22625. } `json:"setlinfo"`
  22626. } `json:"output"`
  22627. RefmsgTime string `json:"refmsg_time"`
  22628. RespondTime string `json:"respond_time"`
  22629. Signtype interface{} `json:"signtype"`
  22630. WarnMsg interface{} `json:"warn_msg"`
  22631. }
  22632. type ResultSixteen10265 struct {
  22633. Cainfo string `json:"cainfo"`
  22634. ErrMsg string `json:"err_msg"`
  22635. InfRefmsgid string `json:"inf_refmsgid"`
  22636. Infcode string `json:"infcode"`
  22637. Output struct {
  22638. Setlinfo struct {
  22639. MdtrtID string `json:"mdtrt_id"`
  22640. SetlID string `json:"setl_id"`
  22641. ClrOptins string `json:"clr_optins"`
  22642. SetlTime string `json:"setl_time"`
  22643. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22644. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22645. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22646. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22647. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22648. ActPayDedc float64 `json:"act_pay_dedc"`
  22649. HifpPay float64 `json:"hifp_pay"`
  22650. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22651. Lfpay float64 `json:"selfpay"`
  22652. CvlservPay float64 `json:"cvlserv_pay"`
  22653. HifesPay float64 `json:"hifes_pay"`
  22654. HifmiPay float64 `json:"hifmi_pay"`
  22655. HifobPay float64 `json:"hifob_pay"`
  22656. MafPay float64 `json:"maf_pay"`
  22657. OthPay float64 `json:"oth_pay"`
  22658. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22659. PsnPartAmt float64 `json:"psn_part_amt"`
  22660. AcctPay float64 `json:"acct_pay"`
  22661. Balc float64 `json:"balc"`
  22662. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22663. HospPartAmt float64 `json:"hosp_part_amt"`
  22664. MedinsSetlID string `json:"medins_setl_id"`
  22665. PdnCashPay string `json:"pdn_cash_pay"`
  22666. } `json:"setlinfo"`
  22667. } `json:"output"`
  22668. RefmsgTime string `json:"refmsg_time"`
  22669. RespondTime string `json:"respond_time"`
  22670. Signtype interface{} `json:"signtype"`
  22671. WarnMsg interface{} `json:"warn_msg"`
  22672. }
  22673. type ResultSixteen10265Two struct {
  22674. Cainfo string `json:"cainfo"`
  22675. ErrMsg string `json:"err_msg"`
  22676. InfRefmsgid string `json:"inf_refmsgid"`
  22677. Infcode string `json:"infcode"`
  22678. Output struct {
  22679. Setlinfo interface{} `json:"setlinfo"`
  22680. } `json:"output"`
  22681. RefmsgTime string `json:"refmsg_time"`
  22682. RespondTime string `json:"respond_time"`
  22683. Signtype interface{} `json:"signtype"`
  22684. WarnMsg interface{} `json:"warn_msg"`
  22685. }
  22686. type ResultgzSixteen10265Two struct {
  22687. Cainfo string `json:"cainfo"`
  22688. ErrMsg string `json:"err_msg"`
  22689. InfRefmsgid string `json:"inf_refmsgid"`
  22690. Infcode int64 `json:"infcode"`
  22691. Output struct {
  22692. Setlinfo interface{} `json:"setlinfo"`
  22693. } `json:"output"`
  22694. RefmsgTime string `json:"refmsg_time"`
  22695. RespondTime string `json:"respond_time"`
  22696. Signtype interface{} `json:"signtype"`
  22697. WarnMsg interface{} `json:"warn_msg"`
  22698. }
  22699. type ResultSeventeen struct {
  22700. ErrMsg string `json:"err_msg"`
  22701. InfRefmsgid string `json:"inf_refmsgid"`
  22702. Infcode int64 `json:"infcode"`
  22703. Output struct {
  22704. SetlListId string `json:"setl_list_id"`
  22705. } `json:"output"`
  22706. RefmsgTime string `json:"refmsg_time"`
  22707. RespondTime string `json:"respond_time"`
  22708. Signtype string `json:"signtype"`
  22709. WarnInfo string `json:"warn_info"`
  22710. }
  22711. type ResultSeventeenOther struct {
  22712. ErrMsg string `json:"err_msg"`
  22713. InfRefmsgid string `json:"inf_refmsgid"`
  22714. Infcode string `json:"infcode"`
  22715. Output struct {
  22716. SetlListId string `json:"setl_list_id"`
  22717. } `json:"output"`
  22718. RefmsgTime string `json:"refmsg_time"`
  22719. RespondTime string `json:"respond_time"`
  22720. Signtype string `json:"signtype"`
  22721. WarnInfo string `json:"warn_info"`
  22722. }
  22723. type Result90991 struct {
  22724. ErrMsg string `json:"err_msg"`
  22725. InfRefmsgid string `json:"inf_refmsgid"`
  22726. Infcode int64 `json:"infcode"`
  22727. Output struct {
  22728. Result struct {
  22729. PsnNo string `json:"psn_no"`
  22730. CardStat string `json:"card_stat"`
  22731. Certno string `json:"certno"`
  22732. PsnName string `json:"psn_name"`
  22733. CheckStat string `json:"check_stat"`
  22734. SscnoCheckStat string `json:"sscno_check_stat"`
  22735. } `json:"result"`
  22736. } `json:"output"`
  22737. RefmsgTime string `json:"refmsg_time"`
  22738. RespondTime string `json:"respond_time"`
  22739. Signtype interface{} `json:"signtype"`
  22740. WarnInfo interface{} `json:"warn_info"`
  22741. }
  22742. type Result90100 struct {
  22743. ErrMsg string `json:"err_msg"`
  22744. InfRefmsgid string `json:"inf_refmsgid"`
  22745. Infcode int64 `json:"infcode"`
  22746. Output struct {
  22747. PoolareaNo string `json:"poolarea_no"`
  22748. PoolareaNoName string `json:"poolarea_no_name"`
  22749. Insutype string `json:"insutype"`
  22750. InsutypeName string `json:"insutype_name"`
  22751. ClctType string `json:"clct_type"`
  22752. ClctTypeName string `json:"clct_type_name"`
  22753. ClctFlag string `json:"clct_flag"`
  22754. ClctFlagName string `json:"clct_flag_name"`
  22755. AccrymBegn string `json:"accrym_begn"`
  22756. AccrymEnd string `json:"accrym_end"`
  22757. ClctTime string `json:"clct_time"`
  22758. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  22759. } `json:"output"`
  22760. RefmsgTime string `json:"refmsg_time"`
  22761. RespondTime string `json:"respond_time"`
  22762. Signtype interface{} `json:"signtype"`
  22763. WarnInfo interface{} `json:"warn_info"`
  22764. }
  22765. type Custom struct {
  22766. DetItemFeeSumamt string
  22767. Cut string
  22768. FeedetlSn string
  22769. Price string
  22770. MedListCodg string
  22771. Type int64
  22772. AdviceId int64
  22773. ProjectId int64
  22774. ItemId int64
  22775. }
  22776. type Result5301 struct {
  22777. ErrMsg string `json:"err_msg"`
  22778. InfRefmsgid string `json:"inf_refmsgid"`
  22779. Infcode int64 `json:"infcode"`
  22780. Output struct {
  22781. Result []struct {
  22782. OpspDiseCode string `json:"opsp_dise_code"`
  22783. OpspDiseName string `json:"opsp_dise_name"`
  22784. Begndate string `json:"begndate"`
  22785. Enddate string `json:"enddate"`
  22786. } `json:"feedetail"`
  22787. } `json:"output"`
  22788. RefmsgTime string `json:"refmsg_time"`
  22789. RespondTime string `json:"respond_time"`
  22790. Signtype interface{} `json:"signtype"`
  22791. WarnInfo interface{} `json:"warn_info"`
  22792. }
  22793. type Result5301For10265 struct {
  22794. ErrMsg string `json:"err_msg"`
  22795. InfRefmsgid string `json:"inf_refmsgid"`
  22796. Infcode string `json:"infcode"`
  22797. Output struct {
  22798. Result []struct {
  22799. OpspDiseCode string `json:"opsp_dise_code"`
  22800. OpspDiseName string `json:"opsp_dise_name"`
  22801. Begndate string `json:"begndate"`
  22802. Enddate string `json:"enddate"`
  22803. } `json:"feedetail"`
  22804. } `json:"output"`
  22805. RefmsgTime string `json:"refmsg_time"`
  22806. RespondTime string `json:"respond_time"`
  22807. Signtype interface{} `json:"signtype"`
  22808. WarnInfo interface{} `json:"warn_info"`
  22809. }
  22810. //获取个人信息----挂号-----上传就诊信息
  22811. func (c *HisApiController) GetRegisterInfo() {
  22812. id, _ := c.GetInt64("id")
  22813. record_time := c.GetString("record_time")
  22814. settlementValue, _ := c.GetInt64("settlement_value")
  22815. medical_insurance_card := c.GetString("medical_insurance_card")
  22816. name := c.GetString("name")
  22817. id_card_type, _ := c.GetInt64("id_card_type")
  22818. certificates, _ := c.GetInt64("certificates")
  22819. medical_care, _ := c.GetInt64("medical_care")
  22820. birthday := c.GetString("birthday")
  22821. id_card := c.GetString("id_card")
  22822. register_type, _ := c.GetInt64("register")
  22823. doctor, _ := c.GetInt64("doctor")
  22824. department, _ := c.GetInt64("department")
  22825. gender, _ := c.GetInt64("sex")
  22826. registration_fee, _ := c.GetFloat("registration_fee")
  22827. medical_expenses, _ := c.GetFloat("medical_expenses")
  22828. social_type, _ := c.GetInt64("social_type")
  22829. admin_user_id, _ := c.GetInt64("admin_user_id")
  22830. insuplc_admdvs := c.GetString("insuplc_admdvs")
  22831. mdtrt_type := c.GetString("mdtrt_type")
  22832. if id_card_type == 5 {
  22833. id_card_type = 4
  22834. }
  22835. timeLayout := "2006-01-02"
  22836. loc, _ := time.LoadLocation("Local")
  22837. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  22838. birthUnix := birthdays.Unix()
  22839. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22840. if err != nil {
  22841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22842. return
  22843. }
  22844. recordDateTime := theTime.Unix()
  22845. adminInfo := c.GetAdminUserInfo()
  22846. var patient service.Patients
  22847. if id == 0 {
  22848. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  22849. } else {
  22850. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  22851. }
  22852. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  22853. if patientPrescription.ID == 0 {
  22854. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  22855. }
  22856. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22857. if patient.ID == 0 {
  22858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  22859. return
  22860. }
  22861. if len(patient.IdCardNo) == 0 {
  22862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  22863. return
  22864. }
  22865. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22866. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  22867. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  22868. //就诊结算未完成,不能进行二次挂号
  22869. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  22870. if len(his) >= 1 {
  22871. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  22872. if len(his) >= 1 && order.ID == 0 {
  22873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  22874. return
  22875. }
  22876. }
  22877. //var register_log string
  22878. if config.IsOpen == 1 {
  22879. var res ResultTwo
  22880. var res10265 ResultTwo10265
  22881. var PsnNo string
  22882. var PsnCertType string
  22883. var Certno string
  22884. var PsnName string
  22885. var Gend string
  22886. var Naty string
  22887. var Brdy string
  22888. var Age float64
  22889. var infoStr string
  22890. var idetinfoStr string
  22891. var infocode int64
  22892. var verify_number string
  22893. fmt.Println(verify_number)
  22894. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  22895. psn_info, _ := service.GetPsnByPatientId(id)
  22896. PsnNo = psn_info.PsnNo
  22897. PsnCertType = psn_info.PsnCertType
  22898. Certno = psn_info.Certno
  22899. PsnName = psn_info.PsnName
  22900. Gend = psn_info.Gend
  22901. Naty = psn_info.Naty
  22902. Brdy = psn_info.Brdy
  22903. Age = psn_info.Age
  22904. infoStr = psn_info.Insuinfo
  22905. idetinfoStr = psn_info.Idetinfo
  22906. infocode = 0
  22907. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22908. psn_info, _ := service.GetPsnByPatientId(id)
  22909. PsnNo = psn_info.PsnNo
  22910. PsnCertType = psn_info.PsnCertType
  22911. Certno = psn_info.Certno
  22912. PsnName = psn_info.PsnName
  22913. Gend = psn_info.Gend
  22914. Naty = psn_info.Naty
  22915. Brdy = psn_info.Brdy
  22916. Age = psn_info.Age
  22917. infoStr = psn_info.Insuinfo
  22918. idetinfoStr = psn_info.Idetinfo
  22919. infocode = 0
  22920. verify_number = psn_info.VerifyNumber
  22921. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22922. if id_card_type == 2 {
  22923. //请求内网数据
  22924. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  22925. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22926. "&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
  22927. resp, requestErr := http.Get(api)
  22928. if requestErr != nil {
  22929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22930. return
  22931. }
  22932. body, ioErr := ioutil.ReadAll(resp.Body)
  22933. if ioErr != nil {
  22934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22936. return
  22937. }
  22938. var respJSON map[string]interface{}
  22939. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22942. return
  22943. }
  22944. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22945. result_byte, _ := json.Marshal(respJSON)
  22946. result := string(result_byte)
  22947. var dat map[string]interface{}
  22948. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22949. fmt.Println(dat)
  22950. } else {
  22951. fmt.Println(err)
  22952. }
  22953. userJSONBytes, _ := json.Marshal(dat)
  22954. var res ResultTwo
  22955. var resTwo10265 ResultTwo10265
  22956. if miConfig.Code == "H15049901371" {
  22957. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  22958. utils.ErrorLog("解析失败:%v", err)
  22959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22960. return
  22961. }
  22962. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  22963. res.Infcode = Infcode
  22964. res.ErrMsg = resTwo10265.ErrMsg
  22965. res.Output = resTwo10265.Output
  22966. res.InfRefmsgid = resTwo10265.InfRefmsgid
  22967. res.RespondTime = resTwo10265.RespondTime
  22968. res.WarnInfo = resTwo10265.WarnInfo
  22969. } else {
  22970. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22971. utils.ErrorLog("解析失败:%v", err)
  22972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22973. return
  22974. }
  22975. }
  22976. //var insutypes []string
  22977. //var insutype string
  22978. //var is390 int = 0
  22979. //var is310 int = 0
  22980. //for _, item := range res.Output.Iinfo {
  22981. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22982. // insutypes = append(insutypes, item.Insutype)
  22983. // }
  22984. //}
  22985. //if len(insutypes) == 1 {
  22986. // insutype = insutypes[0]
  22987. //} else {
  22988. // for _, i := range insutypes {
  22989. // if i == "390" {
  22990. // is390 = 1
  22991. // }
  22992. //
  22993. // if i == "310" {
  22994. // is310 = 1
  22995. // }
  22996. // }
  22997. //}
  22998. //if is390 == 1 {
  22999. // insutype = "390"
  23000. //}
  23001. //if is310 == 1 {
  23002. // insutype = "310"
  23003. //}
  23004. //if len(insutypes) == 0 {
  23005. // insutype = "310"
  23006. //}
  23007. PsnNo = res.Output.Baseinfo.PsnNo
  23008. PsnCertType = res.Output.Baseinfo.PsnCertType
  23009. Certno = res.Output.Baseinfo.Certno
  23010. PsnName = res.Output.Baseinfo.PsnName
  23011. Gend = res.Output.Baseinfo.Gend
  23012. Naty = res.Output.Baseinfo.Naty
  23013. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23014. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23015. infoStr = string(Iinfos)
  23016. idetinfoStr = string(Idetinfos)
  23017. infocode = res.Infcode
  23018. //infocode = 0
  23019. //verify_number = psn_info.VerifyNumber
  23020. } else {
  23021. psn_info, _ := service.GetPsnByPatientId(id)
  23022. PsnNo = psn_info.PsnNo
  23023. PsnCertType = psn_info.PsnCertType
  23024. Certno = psn_info.Certno
  23025. PsnName = psn_info.PsnName
  23026. Gend = psn_info.Gend
  23027. Naty = psn_info.Naty
  23028. Brdy = psn_info.Brdy
  23029. Age = psn_info.Age
  23030. infoStr = psn_info.Insuinfo
  23031. idetinfoStr = psn_info.Idetinfo
  23032. infocode = 0
  23033. verify_number = psn_info.VerifyNumber
  23034. }
  23035. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23036. if id_card_type == 1 {
  23037. psn_info, _ := service.GetPsnByPatientId(id)
  23038. PsnNo = psn_info.PsnNo
  23039. PsnCertType = psn_info.PsnCertType
  23040. Certno = psn_info.Certno
  23041. PsnName = psn_info.PsnName
  23042. Gend = psn_info.Gend
  23043. Naty = psn_info.Naty
  23044. Brdy = psn_info.Brdy
  23045. Age = psn_info.Age
  23046. infoStr = psn_info.Insuinfo
  23047. idetinfoStr = psn_info.Idetinfo
  23048. infocode = 0
  23049. verify_number = psn_info.VerifyNumber
  23050. } else if id_card_type == 2 {
  23051. 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)
  23052. fmt.Println(errMsgLog)
  23053. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23054. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23055. utils.ErrorLog("解析失败:%v", err)
  23056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23057. return
  23058. }
  23059. PsnNo = res.Output.Baseinfo.PsnNo
  23060. PsnCertType = res.Output.Baseinfo.PsnCertType
  23061. Certno = res.Output.Baseinfo.Certno
  23062. PsnName = res.Output.Baseinfo.PsnName
  23063. Gend = res.Output.Baseinfo.Gend
  23064. Naty = res.Output.Baseinfo.Naty
  23065. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23066. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23067. infoStr = string(Iinfos)
  23068. idetinfoStr = string(Idetinfos)
  23069. infocode = res.Infcode
  23070. }
  23071. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23072. if id_card_type == 1 {
  23073. psn_info, _ := service.GetPsnByPatientId(id)
  23074. PsnNo = psn_info.PsnNo
  23075. PsnCertType = psn_info.PsnCertType
  23076. Certno = psn_info.Certno
  23077. PsnName = psn_info.PsnName
  23078. Gend = psn_info.Gend
  23079. Naty = psn_info.Naty
  23080. Brdy = psn_info.Brdy
  23081. Age = psn_info.Age
  23082. infoStr = psn_info.Insuinfo
  23083. idetinfoStr = psn_info.Idetinfo
  23084. infocode = 0
  23085. verify_number = psn_info.VerifyNumber
  23086. } else if id_card_type == 2 {
  23087. 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, "")
  23088. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23089. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23090. utils.ErrorLog("解析失败:%v", err)
  23091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23092. return
  23093. }
  23094. PsnNo = res.Output.Baseinfo.PsnNo
  23095. PsnCertType = res.Output.Baseinfo.PsnCertType
  23096. Certno = res.Output.Baseinfo.Certno
  23097. PsnName = res.Output.Baseinfo.PsnName
  23098. Gend = res.Output.Baseinfo.Gend
  23099. Naty = res.Output.Baseinfo.Naty
  23100. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23101. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23102. infoStr = string(Iinfos)
  23103. idetinfoStr = string(Idetinfos)
  23104. infocode = res.Infcode
  23105. } else {
  23106. psn_info, _ := service.GetPsnByPatientId(id)
  23107. PsnNo = psn_info.PsnNo
  23108. PsnCertType = psn_info.PsnCertType
  23109. Certno = psn_info.Certno
  23110. PsnName = psn_info.PsnName
  23111. Gend = psn_info.Gend
  23112. Naty = psn_info.Naty
  23113. Brdy = psn_info.Brdy
  23114. Age = psn_info.Age
  23115. infoStr = psn_info.Insuinfo
  23116. idetinfoStr = psn_info.Idetinfo
  23117. infocode = 0
  23118. verify_number = psn_info.VerifyNumber
  23119. }
  23120. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23121. if id_card_type == 1 {
  23122. psn_info, _ := service.GetPsnByPatientId(id)
  23123. PsnNo = psn_info.PsnNo
  23124. PsnCertType = psn_info.PsnCertType
  23125. Certno = psn_info.Certno
  23126. PsnName = psn_info.PsnName
  23127. Gend = psn_info.Gend
  23128. Naty = psn_info.Naty
  23129. Brdy = psn_info.Brdy
  23130. Age = psn_info.Age
  23131. infoStr = psn_info.Insuinfo
  23132. idetinfoStr = psn_info.Idetinfo
  23133. infocode = 0
  23134. verify_number = psn_info.VerifyNumber
  23135. } else if id_card_type == 2 {
  23136. psn_info, _ := service.GetPsnByPatientId(id)
  23137. PsnNo = psn_info.PsnNo
  23138. PsnCertType = psn_info.PsnCertType
  23139. Certno = psn_info.Certno
  23140. PsnName = psn_info.PsnName
  23141. Gend = psn_info.Gend
  23142. Naty = psn_info.Naty
  23143. Brdy = psn_info.Brdy
  23144. Age = psn_info.Age
  23145. infoStr = psn_info.Insuinfo
  23146. idetinfoStr = psn_info.Idetinfo
  23147. infocode = 0
  23148. verify_number = psn_info.VerifyNumber
  23149. } else {
  23150. psn_info, _ := service.GetPsnByPatientId(id)
  23151. PsnNo = psn_info.PsnNo
  23152. PsnCertType = psn_info.PsnCertType
  23153. Certno = psn_info.Certno
  23154. PsnName = psn_info.PsnName
  23155. Gend = psn_info.Gend
  23156. Naty = psn_info.Naty
  23157. Brdy = psn_info.Brdy
  23158. Age = psn_info.Age
  23159. infoStr = psn_info.Insuinfo
  23160. idetinfoStr = psn_info.Idetinfo
  23161. infocode = 0
  23162. verify_number = psn_info.VerifyNumber
  23163. }
  23164. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23165. psn_info, _ := service.GetPsnByPatientId(id)
  23166. PsnNo = psn_info.PsnNo
  23167. PsnCertType = psn_info.PsnCertType
  23168. Certno = psn_info.Certno
  23169. PsnName = psn_info.PsnName
  23170. Gend = psn_info.Gend
  23171. Naty = psn_info.Naty
  23172. Brdy = psn_info.Brdy
  23173. Age = psn_info.Age
  23174. infoStr = psn_info.Insuinfo
  23175. idetinfoStr = psn_info.Idetinfo
  23176. infocode = 0
  23177. verify_number = psn_info.VerifyNumber
  23178. idetinfoStr = psn_info.Idetinfo
  23179. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23180. if id_card_type == 1 {
  23181. psn_info, _ := service.GetPsnByPatientId(id)
  23182. PsnNo = psn_info.PsnNo
  23183. PsnCertType = psn_info.PsnCertType
  23184. Certno = psn_info.Certno
  23185. PsnName = psn_info.PsnName
  23186. Gend = psn_info.Gend
  23187. Naty = psn_info.Naty
  23188. Brdy = psn_info.Brdy
  23189. Age = psn_info.Age
  23190. infoStr = psn_info.Insuinfo
  23191. idetinfoStr = psn_info.Idetinfo
  23192. infocode = 0
  23193. verify_number = psn_info.VerifyNumber
  23194. } else if id_card_type == 2 {
  23195. 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)
  23196. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23197. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23198. utils.ErrorLog("解析失败:%v", err)
  23199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23200. return
  23201. }
  23202. PsnNo = res.Output.Baseinfo.PsnNo
  23203. PsnCertType = res.Output.Baseinfo.PsnCertType
  23204. Certno = res.Output.Baseinfo.Certno
  23205. PsnName = res.Output.Baseinfo.PsnName
  23206. Gend = res.Output.Baseinfo.Gend
  23207. Naty = res.Output.Baseinfo.Naty
  23208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23210. infoStr = string(Iinfos)
  23211. idetinfoStr = string(Idetinfos)
  23212. infocode = res.Infcode
  23213. } else if id_card_type == 4 {
  23214. psn_info, _ := service.GetPsnByPatientId(id)
  23215. PsnNo = psn_info.PsnNo
  23216. PsnCertType = psn_info.PsnCertType
  23217. Certno = psn_info.Certno
  23218. PsnName = psn_info.PsnName
  23219. Gend = psn_info.Gend
  23220. Naty = psn_info.Naty
  23221. Brdy = psn_info.Brdy
  23222. Age = psn_info.Age
  23223. infoStr = psn_info.Insuinfo
  23224. idetinfoStr = psn_info.Idetinfo
  23225. infocode = 0
  23226. verify_number = psn_info.VerifyNumber
  23227. }
  23228. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23229. var result string
  23230. var requestLog string
  23231. 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), "")
  23232. if id_card_type == 4 {
  23233. psn_info, _ := service.GetPsnByPatientId(id)
  23234. PsnNo = psn_info.PsnNo
  23235. PsnCertType = psn_info.PsnCertType
  23236. Certno = psn_info.Certno
  23237. PsnName = psn_info.PsnName
  23238. Gend = psn_info.Gend
  23239. Naty = psn_info.Naty
  23240. Brdy = psn_info.Brdy
  23241. Age = psn_info.Age
  23242. infoStr = psn_info.Insuinfo
  23243. idetinfoStr = psn_info.Idetinfo
  23244. infocode = 0
  23245. verify_number = psn_info.VerifyNumber
  23246. } else {
  23247. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23248. if miConfig.Code == "H15049901371" {
  23249. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23250. utils.ErrorLog("解析失败:%v", err)
  23251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23252. return
  23253. }
  23254. res.ErrMsg = res10265.ErrMsg
  23255. res.Output = res10265.Output
  23256. res.InfRefmsgid = res10265.InfRefmsgid
  23257. } else {
  23258. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23259. utils.ErrorLog("解析失败:%v", err)
  23260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23261. return
  23262. }
  23263. }
  23264. PsnNo = res.Output.Baseinfo.PsnNo
  23265. PsnCertType = res.Output.Baseinfo.PsnCertType
  23266. Certno = res.Output.Baseinfo.Certno
  23267. PsnName = res.Output.Baseinfo.PsnName
  23268. Gend = res.Output.Baseinfo.Gend
  23269. Naty = res.Output.Baseinfo.Naty
  23270. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23271. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23272. infoStr = string(Iinfos)
  23273. idetinfoStr = string(Idetinfos)
  23274. if miConfig.Code == "H15049901371" {
  23275. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23276. } else {
  23277. infocode = res.Infcode
  23278. }
  23279. }
  23280. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23281. psn_info, _ := service.GetPsnByPatientId(id)
  23282. PsnNo = psn_info.PsnNo
  23283. PsnCertType = psn_info.PsnCertType
  23284. Certno = psn_info.Certno
  23285. PsnName = psn_info.PsnName
  23286. Gend = psn_info.Gend
  23287. Naty = psn_info.Naty
  23288. Brdy = psn_info.Brdy
  23289. Age = psn_info.Age
  23290. infoStr = psn_info.Insuinfo
  23291. idetinfoStr = psn_info.Idetinfo
  23292. infocode = 0
  23293. verify_number = psn_info.VerifyNumber
  23294. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23295. psn_info, _ := service.GetPsnByPatientId(id)
  23296. PsnNo = psn_info.PsnNo
  23297. PsnCertType = psn_info.PsnCertType
  23298. Certno = psn_info.Certno
  23299. PsnName = psn_info.PsnName
  23300. Gend = psn_info.Gend
  23301. Naty = psn_info.Naty
  23302. Brdy = psn_info.Brdy
  23303. Age = psn_info.Age
  23304. infoStr = psn_info.Insuinfo
  23305. idetinfoStr = psn_info.Idetinfo
  23306. infocode = 0
  23307. verify_number = psn_info.VerifyNumber
  23308. } else {
  23309. var result string
  23310. var requestLog string
  23311. //if miConfig.UserOrgId == 10138 {
  23312. if id_card_type != 4 || id_card_type != 1 {
  23313. var insa string
  23314. if len(patient.InsuplcAdmdvs) > 0 {
  23315. insa = patient.InsuplcAdmdvs
  23316. } else {
  23317. insa = miConfig.InsuplcAdmdvs
  23318. }
  23319. //psn_info, _ := service.GetPsnByPatientId(id)
  23320. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23321. 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)
  23322. }
  23323. //}
  23324. //else {
  23325. // var insa string
  23326. // if len(patient.InsuplcAdmdvs) > 0 {
  23327. // insa = patient.InsuplcAdmdvs
  23328. // } else {
  23329. // insa = miConfig.InsuplcAdmdvs
  23330. // }
  23331. // 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)
  23332. //}
  23333. if id_card_type == 4 || id_card_type == 1 {
  23334. psn_info, _ := service.GetPsnByPatientId(id)
  23335. PsnNo = psn_info.PsnNo
  23336. PsnCertType = psn_info.PsnCertType
  23337. Certno = psn_info.Certno
  23338. PsnName = psn_info.PsnName
  23339. Gend = psn_info.Gend
  23340. Naty = psn_info.Naty
  23341. Brdy = psn_info.Brdy
  23342. Age = psn_info.Age
  23343. infoStr = psn_info.Insuinfo
  23344. idetinfoStr = psn_info.Idetinfo
  23345. infocode = 0
  23346. verify_number = psn_info.VerifyNumber
  23347. } else {
  23348. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23349. if miConfig.Code == "H15049901371" {
  23350. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23351. utils.ErrorLog("解析失败:%v", err)
  23352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23353. return
  23354. }
  23355. res.ErrMsg = res10265.ErrMsg
  23356. res.Output = res10265.Output
  23357. res.InfRefmsgid = res10265.InfRefmsgid
  23358. } else {
  23359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23360. utils.ErrorLog("解析失败:%v", err)
  23361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23362. return
  23363. }
  23364. }
  23365. PsnNo = res.Output.Baseinfo.PsnNo
  23366. PsnCertType = res.Output.Baseinfo.PsnCertType
  23367. Certno = res.Output.Baseinfo.Certno
  23368. PsnName = res.Output.Baseinfo.PsnName
  23369. Gend = res.Output.Baseinfo.Gend
  23370. Naty = res.Output.Baseinfo.Naty
  23371. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23372. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23373. infoStr = string(Iinfos)
  23374. idetinfoStr = string(Idetinfos)
  23375. if miConfig.Code == "H15049901371" {
  23376. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23377. } else {
  23378. infocode = res.Infcode
  23379. }
  23380. }
  23381. }
  23382. if infocode == 0 {
  23383. his := models.VMHisPatient{
  23384. Name: name,
  23385. Gender: gender,
  23386. Birthday: birthUnix,
  23387. MedicalTreatmentType: medical_care,
  23388. IdType: certificates,
  23389. IdCardNo: id_card,
  23390. BalanceAccountsType: settlementValue,
  23391. SocialType: social_type,
  23392. MedicalInsuranceNumber: medical_insurance_card,
  23393. RegisterType: register_type,
  23394. RegisterCost: registration_fee,
  23395. TreatmentCost: medical_expenses,
  23396. Status: 1,
  23397. Ctime: time.Now().Unix(),
  23398. Mtime: time.Now().Unix(),
  23399. PsnNo: PsnNo,
  23400. PsnCertType: PsnCertType,
  23401. Certno: Certno,
  23402. PsnName: PsnName,
  23403. Gend: Gend,
  23404. Naty: Naty,
  23405. Brdy: Brdy,
  23406. Age: Age,
  23407. Iinfo: infoStr,
  23408. Idetinfo: idetinfoStr,
  23409. PatientId: patient.ID,
  23410. RecordDate: theTime.Unix(),
  23411. UserOrgId: adminInfo.CurrentOrgId,
  23412. AdminUserId: admin_user_id,
  23413. IsReturn: 1,
  23414. IdCardType: id_card_type,
  23415. Doctor: doctor,
  23416. Departments: department,
  23417. MdtrtGrpType: mdtrt_type,
  23418. }
  23419. timestamp := time.Now().Unix()
  23420. tempTime := time.Unix(timestamp, 0)
  23421. timeFormat := tempTime.Format("20060102150405")
  23422. chrgBchno := rand.Intn(100000) + 10000
  23423. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23424. his.Number = ipt_otp_no
  23425. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23426. department, _ := service.GetDepartMentDetail(department)
  23427. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23428. IdCardNo := ""
  23429. if id_card_type == 1 {
  23430. // IdCardNo = medical_insurance_card
  23431. IdCardNo = patient.IdCardNo
  23432. } else {
  23433. IdCardNo = patient.IdCardNo
  23434. }
  23435. var rf []*ResultFive
  23436. json.Unmarshal([]byte(his.Iinfo), &rf)
  23437. var insutypes []*ResultFive
  23438. var insutype string
  23439. var insuplc_admdvs_temp string
  23440. var is390 int = 0
  23441. var is310 int = 0
  23442. for _, item := range rf {
  23443. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23444. insutypes = append(insutypes, item)
  23445. }
  23446. }
  23447. if len(insutypes) == 1 {
  23448. insutype = insutypes[0].Insutype
  23449. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23450. if insutype == "390" {
  23451. is390 = 1
  23452. }
  23453. if insutype == "310" {
  23454. is310 = 1
  23455. }
  23456. } else {
  23457. for _, i := range insutypes {
  23458. if i.Insutype == "390" {
  23459. is390 = 1
  23460. }
  23461. if i.Insutype == "310" {
  23462. is310 = 1
  23463. }
  23464. }
  23465. }
  23466. if is390 == 1 {
  23467. insutype = "390"
  23468. }
  23469. if is310 == 1 {
  23470. insutype = "310"
  23471. }
  23472. fmt.Println(social_type)
  23473. if social_type > 0 {
  23474. insutype = strconv.FormatInt(social_type, 10)
  23475. }
  23476. var infocode int64
  23477. var resThree ResultThree
  23478. var resThree10265 ResultThree10265
  23479. if len(insuplc_admdvs) == 0 {
  23480. psn_info, _ := service.GetPsnByPatientId(id)
  23481. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23482. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23483. //}
  23484. } else {
  23485. insuplc_admdvs_temp = insuplc_admdvs
  23486. }
  23487. if miConfig.MdtrtareaAdmvs == "421300" {
  23488. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23489. psn_info, _ := service.GetPsnByPatientId(id)
  23490. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23491. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23492. "&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
  23493. resp, requestErr := http.Get(api)
  23494. if requestErr != nil {
  23495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23496. return
  23497. }
  23498. body, ioErr := ioutil.ReadAll(resp.Body)
  23499. if ioErr != nil {
  23500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23502. return
  23503. }
  23504. var respJSON map[string]interface{}
  23505. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23508. return
  23509. }
  23510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23511. result, _ := json.Marshal(respJSON)
  23512. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23513. utils.ErrorLog("解析失败:%v", err)
  23514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23515. return
  23516. }
  23517. infocode = resThree.Infcode
  23518. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23519. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23520. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23521. // insuplc_admdvs_temp =
  23522. //}
  23523. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23524. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23525. //}
  23526. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23527. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23528. "&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
  23529. resp, requestErr := http.Get(api)
  23530. if requestErr != nil {
  23531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23532. return
  23533. }
  23534. body, ioErr := ioutil.ReadAll(resp.Body)
  23535. if ioErr != nil {
  23536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23538. return
  23539. }
  23540. var respJSON map[string]interface{}
  23541. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23544. return
  23545. }
  23546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23547. result, _ := json.Marshal(respJSON)
  23548. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23549. utils.ErrorLog("解析失败:%v", err)
  23550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23551. return
  23552. }
  23553. infocode = resThree.Infcode
  23554. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23555. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23556. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23557. // insuplc_admdvs_temp =
  23558. //}
  23559. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23560. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23561. //}
  23562. utils.ErrorLog("解析失败:%v", insutype)
  23563. utils.ErrorLog("解析失败:%v", PsnNo)
  23564. utils.ErrorLog("解析失败:%v", Certno)
  23565. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23566. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23567. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23568. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23569. utils.ErrorLog("解析失败:%v", PsnNo)
  23570. utils.ErrorLog("解析失败:%v", department.Number)
  23571. utils.ErrorLog("解析失败:%v", department.Name)
  23572. utils.ErrorLog("解析失败:%v", roles.UserName)
  23573. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23574. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23575. "&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
  23576. resp, requestErr := http.Get(api)
  23577. if requestErr != nil {
  23578. utils.ErrorLog("解析失败:%v", requestErr)
  23579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23580. return
  23581. }
  23582. body, ioErr := ioutil.ReadAll(resp.Body)
  23583. if ioErr != nil {
  23584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23586. return
  23587. }
  23588. var respJSON map[string]interface{}
  23589. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23592. return
  23593. }
  23594. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23595. result, _ := json.Marshal(respJSON)
  23596. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23597. utils.ErrorLog("解析失败:%v", err)
  23598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23599. return
  23600. }
  23601. infocode = resThree.Infcode
  23602. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23603. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23604. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23605. // insuplc_admdvs_temp =
  23606. //}
  23607. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23608. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23609. //}
  23610. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23611. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23612. "&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
  23613. resp, requestErr := http.Get(api)
  23614. if requestErr != nil {
  23615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23616. return
  23617. }
  23618. body, ioErr := ioutil.ReadAll(resp.Body)
  23619. if ioErr != nil {
  23620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23622. return
  23623. }
  23624. var respJSON map[string]interface{}
  23625. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23628. return
  23629. }
  23630. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23631. result, _ := json.Marshal(respJSON)
  23632. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23633. utils.ErrorLog("解析失败:%v", err)
  23634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23635. return
  23636. }
  23637. infocode = resThree.Infcode
  23638. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23639. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23640. psn_info, _ := service.GetPsnByPatientId(id)
  23641. var verify_number string
  23642. if id_card_type == 4 {
  23643. verify_number = psn_info.VerifyNumber
  23644. } else if id_card_type == 1 {
  23645. bas := strings.Split(psn_info.CardInfo, "|")
  23646. cardNumber := bas[2]
  23647. verify_number = cardNumber
  23648. }
  23649. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23650. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23651. "&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
  23652. resp, requestErr := http.Get(api)
  23653. if requestErr != nil {
  23654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23655. return
  23656. }
  23657. body, ioErr := ioutil.ReadAll(resp.Body)
  23658. if ioErr != nil {
  23659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23661. return
  23662. }
  23663. var respJSON map[string]interface{}
  23664. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23667. return
  23668. }
  23669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23670. result, _ := json.Marshal(respJSON)
  23671. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23672. // utils.ErrorLog("解析失败:%v", err)
  23673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23674. // return
  23675. //}
  23676. //infocode = resThree.Infcode
  23677. //result, _ := json.Marshal(respJSON)
  23678. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23679. utils.ErrorLog("解析失败:%v", err)
  23680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23681. return
  23682. }
  23683. resThree.ErrMsg = resThree10265.ErrMsg
  23684. resThree.Output = resThree10265.Output
  23685. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23686. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23687. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23688. psn_info, _ := service.GetPsnByPatientId(id)
  23689. his.PsnNo = psn_info.PsnNo
  23690. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23691. var cert_no string
  23692. if id_card_type == 3 {
  23693. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23694. cert_no = IdCardNo
  23695. } else if id_card_type == 4 {
  23696. cert_no = IdCardNo
  23697. psn_info.VerifyNumber = psn_info.VerifyNumber
  23698. } else {
  23699. bas := strings.Split(psn_info.CardInfo, "|")
  23700. cert_no = bas[2]
  23701. }
  23702. var hisPrescription []*models.HisPrescription
  23703. for _, item := range rf {
  23704. if item.Insutype == insutype {
  23705. //insuplc_admdvs = item.InsuplcAdmdvs
  23706. his.InsuplcAdmdvs = insuplc_admdvs
  23707. }
  23708. }
  23709. his.Insutype = insutype
  23710. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23711. fmt.Println(res3101)
  23712. fmt.Println(res3101.Infcode)
  23713. if res3101.Infcode == "0" {
  23714. fmt.Println("33333333")
  23715. if len(res3101.Output.Result) > 0 {
  23716. fmt.Println("222222")
  23717. for _, item := range res3101.Output.Result {
  23718. if len(res3101.ErrMsg) == 0 {
  23719. res3101.ErrMsg = item.VolaCont
  23720. } else {
  23721. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23722. }
  23723. }
  23724. c.ServeSuccessJSON(map[string]interface{}{
  23725. "failed_code": -10,
  23726. "msg": res3101.ErrMsg,
  23727. })
  23728. return
  23729. } else {
  23730. fmt.Println("11111")
  23731. var api string
  23732. if miConfig.MdtrtareaAdmvs == "320921" {
  23733. ipt_otp_no = timeFormat
  23734. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23735. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23736. "&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
  23737. } else {
  23738. ipt_otp_no = timeFormat
  23739. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23740. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23741. "&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
  23742. }
  23743. resp, requestErr := http.Get(api)
  23744. if requestErr != nil {
  23745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23746. return
  23747. }
  23748. body, ioErr := ioutil.ReadAll(resp.Body)
  23749. if ioErr != nil {
  23750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23752. return
  23753. }
  23754. var respJSON map[string]interface{}
  23755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23758. return
  23759. }
  23760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23761. result, _ := json.Marshal(respJSON)
  23762. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23763. utils.ErrorLog("解析失败:%v", err)
  23764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23765. return
  23766. }
  23767. resThree.ErrMsg = resThree10265.ErrMsg
  23768. resThree.Output = resThree10265.Output
  23769. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23770. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23771. }
  23772. } else if res3101.Infcode != "0" {
  23773. c.ServeSuccessJSON(map[string]interface{}{
  23774. "failed_code": -10,
  23775. "msg": res3101.ErrMsg,
  23776. })
  23777. return
  23778. }
  23779. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23780. psn_info, _ := service.GetPsnByPatientId(id)
  23781. var cert_no string
  23782. if id_card_type == 1 {
  23783. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23784. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23785. } else if id_card_type == 4 {
  23786. cert_no = psn_info.VerifyNumber
  23787. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23788. } else {
  23789. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23790. cert_no = psn_info.VerifyNumber
  23791. }
  23792. 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)
  23793. saveLog(result, requestLog, "2201", "挂号")
  23794. if miConfig.Code == "H15049901371" {
  23795. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23796. utils.ErrorLog("解析失败:%v", err)
  23797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23798. return
  23799. }
  23800. resThree.ErrMsg = resThree10265.ErrMsg
  23801. resThree.Output = resThree10265.Output
  23802. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23803. } else {
  23804. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23805. utils.ErrorLog("解析失败:%v", err)
  23806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23807. return
  23808. }
  23809. }
  23810. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23811. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  23812. psn_info, _ := service.GetPsnByPatientId(id)
  23813. var result string
  23814. var requestLog string
  23815. if id_card_type == 1 {
  23816. bas := strings.Split(psn_info.CardInfo, "|")
  23817. basNumber := bas[2]
  23818. card_sn := bas[3]
  23819. 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)
  23820. saveLog(result, requestLog, "2201A", "挂号")
  23821. } else if id_card_type == 2 {
  23822. 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, "", "", "", "", "", "")
  23823. saveLog(result, requestLog, "2201A", "挂号")
  23824. } else {
  23825. 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)
  23826. saveLog(result, requestLog, "2201A", "挂号")
  23827. }
  23828. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23829. utils.ErrorLog("解析失败:%v", err)
  23830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23831. return
  23832. }
  23833. infocode = resThree.Infcode
  23834. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  23835. psn_info, _ := service.GetPsnByPatientId(id)
  23836. var result string
  23837. var requestLog string
  23838. if id_card_type == 1 {
  23839. bas := strings.Split(psn_info.CardInfo, "|")
  23840. basNumber := bas[2]
  23841. card_sn := ""
  23842. 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)
  23843. saveLog(result, requestLog, "2201A", "挂号")
  23844. } else if id_card_type == 2 {
  23845. 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, "", "", "", "", "", "")
  23846. saveLog(result, requestLog, "2201A", "挂号")
  23847. } else {
  23848. 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)
  23849. saveLog(result, requestLog, "2201A", "挂号")
  23850. }
  23851. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23852. utils.ErrorLog("解析失败:%v", err)
  23853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23854. return
  23855. }
  23856. infocode = resThree.Infcode
  23857. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23858. psn_info, _ := service.GetPsnByPatientId(id)
  23859. his.PsnNo = psn_info.PsnNo
  23860. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23861. var cert_no string
  23862. if id_card_type == 1 {
  23863. bas := strings.Split(psn_info.CardInfo, "|")
  23864. cert_no = bas[2]
  23865. } else if id_card_type == 4 {
  23866. cert_no = psn_info.VerifyNumber
  23867. psn_info.VerifyNumber = psn_info.VerifyNumber
  23868. IdCardNo = psn_info.VerifyNumber
  23869. } else {
  23870. cert_no = IdCardNo
  23871. psn_info.VerifyNumber = cert_no
  23872. }
  23873. for _, item := range rf {
  23874. if item.Insutype == insutype {
  23875. his.InsuplcAdmdvs = insuplc_admdvs
  23876. }
  23877. }
  23878. his.Insutype = insutype
  23879. var api string
  23880. ipt_otp_no = timeFormat
  23881. 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 +
  23882. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23883. "&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
  23884. resp, requestErr := http.Get(api)
  23885. if requestErr != nil {
  23886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23887. return
  23888. }
  23889. body, ioErr := ioutil.ReadAll(resp.Body)
  23890. if ioErr != nil {
  23891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23893. return
  23894. }
  23895. var respJSON map[string]interface{}
  23896. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23899. return
  23900. }
  23901. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23902. if status == "0" {
  23903. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23904. c.ServeSuccessJSON(map[string]interface{}{
  23905. "failed_code": -10,
  23906. "msg": err_msg,
  23907. })
  23908. return
  23909. }
  23910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23911. result, _ := json.Marshal(respJSON)
  23912. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23913. utils.ErrorLog("解析失败:%v", err)
  23914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23915. return
  23916. }
  23917. infocode = resThree.Infcode
  23918. } else if miConfig.MdtrtareaAdmvs == "340699" {
  23919. psn_info, _ := service.GetPsnByPatientId(id)
  23920. his.PsnNo = psn_info.PsnNo
  23921. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23922. var cert_no string
  23923. if id_card_type == 1 {
  23924. bas := strings.Split(psn_info.CardInfo, "|")
  23925. cert_no = bas[2]
  23926. } else if id_card_type == 4 {
  23927. cert_no = psn_info.VerifyNumber
  23928. psn_info.VerifyNumber = psn_info.VerifyNumber
  23929. IdCardNo = psn_info.VerifyNumber
  23930. } else {
  23931. cert_no = IdCardNo
  23932. psn_info.VerifyNumber = cert_no
  23933. }
  23934. for _, item := range rf {
  23935. if item.Insutype == insutype {
  23936. his.InsuplcAdmdvs = insuplc_admdvs
  23937. patient.InsuplcAdmdvs = insuplc_admdvs
  23938. }
  23939. }
  23940. his.Insutype = insutype
  23941. var api string
  23942. ipt_otp_no = timeFormat
  23943. 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 +
  23944. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + 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=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  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. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23964. if status == "0" {
  23965. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23966. c.ServeSuccessJSON(map[string]interface{}{
  23967. "failed_code": -10,
  23968. "msg": err_msg,
  23969. })
  23970. return
  23971. }
  23972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23973. result, _ := json.Marshal(respJSON)
  23974. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23975. utils.ErrorLog("解析失败:%v", err)
  23976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23977. return
  23978. }
  23979. infocode = resThree.Infcode
  23980. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23981. psn_info, _ := service.GetPsnByPatientId(id)
  23982. var result string
  23983. var requestLog string
  23984. if id_card_type == 1 {
  23985. bas := strings.Split(psn_info.CardInfo, "|")
  23986. basNumber := bas[2]
  23987. card_sn := bas[3]
  23988. 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)
  23989. saveLog(result, requestLog, "2201A", "挂号")
  23990. } else if id_card_type == 2 {
  23991. 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, "", "")
  23992. saveLog(result, requestLog, "2201A", "挂号")
  23993. } else {
  23994. 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, "", "")
  23995. saveLog(result, requestLog, "2201A", "挂号")
  23996. }
  23997. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23998. utils.ErrorLog("解析失败:%v", err)
  23999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. return
  24001. }
  24002. infocode = resThree.Infcode
  24003. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24004. psn_info, _ := service.GetPsnByPatientId(id)
  24005. 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)
  24006. saveLog(result, requestLog, "2201A", "挂号")
  24007. if miConfig.Code == "H15049901371" {
  24008. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24009. utils.ErrorLog("解析失败:%v", err)
  24010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24011. return
  24012. }
  24013. resThree.ErrMsg = resThree10265.ErrMsg
  24014. resThree.Output = resThree10265.Output
  24015. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24016. } else {
  24017. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24018. utils.ErrorLog("解析失败:%v", err)
  24019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24020. return
  24021. }
  24022. }
  24023. if miConfig.Code == "H15049901371" {
  24024. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24025. } else {
  24026. infocode = resThree.Infcode
  24027. }
  24028. } else {
  24029. psn_info, _ := service.GetPsnByPatientId(id)
  24030. if id_card_type == 4 || id_card_type == 1 {
  24031. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24032. }
  24033. var rf []*ResultFive
  24034. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24035. var insutypes []*ResultFive
  24036. var insutype string
  24037. var is390 int = 0
  24038. var is310 int = 0
  24039. for _, item := range rf {
  24040. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24041. insutypes = append(insutypes, item)
  24042. }
  24043. }
  24044. if len(insutypes) == 1 {
  24045. insutype = insutypes[0].Insutype
  24046. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24047. } else {
  24048. for _, i := range insutypes {
  24049. if i.Insutype == "390" {
  24050. is390 = 1
  24051. }
  24052. if i.Insutype == "310" {
  24053. is310 = 1
  24054. }
  24055. }
  24056. }
  24057. if is390 == 1 {
  24058. insutype = "390"
  24059. }
  24060. if is310 == 1 {
  24061. insutype = "310"
  24062. }
  24063. fmt.Println(len(insutypes))
  24064. if len(insutypes) == 0 {
  24065. for index, item := range rf {
  24066. if index == 0 {
  24067. insutype = item.Insutype
  24068. insuplc_admdvs = item.InsuplcAdmdvs
  24069. }
  24070. }
  24071. fmt.Println(insutype)
  24072. fmt.Println(insuplc_admdvs)
  24073. }
  24074. if social_type > 0 {
  24075. insutype = strconv.FormatInt(social_type, 10)
  24076. }
  24077. fmt.Println("--------")
  24078. fmt.Println(psn_info)
  24079. fmt.Println(psn_info.PsnNo)
  24080. if miConfig.MdtrtareaAdmvs == "441202" {
  24081. var hisPrescription []*models.HisPrescription
  24082. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24083. if res3101.Infcode == 0 {
  24084. fmt.Println("33333333")
  24085. if len(res3101.Output.Result) > 0 {
  24086. fmt.Println("222222")
  24087. for _, item := range res3101.Output.Result {
  24088. if len(res3101.ErrMsg) == 0 {
  24089. res3101.ErrMsg = item.VolaCont
  24090. } else {
  24091. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24092. }
  24093. }
  24094. c.ServeSuccessJSON(map[string]interface{}{
  24095. "failed_code": -10,
  24096. "msg": res3101.ErrMsg,
  24097. })
  24098. return
  24099. } else {
  24100. hour := time.Now().Format("15")
  24101. min := time.Now().Format("04")
  24102. sec := time.Now().Format("05")
  24103. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24104. fmt.Println(record_time_two)
  24105. 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)
  24106. saveLog(result, requestLog, "2201A", "挂号")
  24107. if miConfig.Code == "H15049901371" {
  24108. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24109. utils.ErrorLog("解析失败:%v", err)
  24110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24111. return
  24112. }
  24113. resThree.ErrMsg = resThree10265.ErrMsg
  24114. resThree.Output = resThree10265.Output
  24115. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24116. } else {
  24117. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24118. utils.ErrorLog("解析失败:%v", err)
  24119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24120. return
  24121. }
  24122. }
  24123. if miConfig.Code == "H15049901371" {
  24124. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24125. } else {
  24126. infocode = resThree.Infcode
  24127. }
  24128. }
  24129. } else if res3101.Infcode != 0 {
  24130. c.ServeSuccessJSON(map[string]interface{}{
  24131. "failed_code": -10,
  24132. "msg": res3101.ErrMsg,
  24133. })
  24134. return
  24135. }
  24136. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24137. var hisPrescription []*models.HisPrescription
  24138. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24139. if res3101.Infcode == 0 {
  24140. fmt.Println("33333333")
  24141. if len(res3101.Output.Result) > 0 {
  24142. fmt.Println("222222")
  24143. for _, item := range res3101.Output.Result {
  24144. if len(res3101.ErrMsg) == 0 {
  24145. res3101.ErrMsg = item.VolaCont
  24146. } else {
  24147. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24148. }
  24149. }
  24150. c.ServeSuccessJSON(map[string]interface{}{
  24151. "failed_code": -10,
  24152. "msg": res3101.ErrMsg,
  24153. })
  24154. return
  24155. } else {
  24156. hour := time.Now().Format("15")
  24157. min := time.Now().Format("04")
  24158. sec := time.Now().Format("05")
  24159. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24160. fmt.Println(record_time_two)
  24161. 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)
  24162. saveLog(result, requestLog, "2201A", "挂号")
  24163. if miConfig.Code == "H15049901371" {
  24164. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24165. utils.ErrorLog("解析失败:%v", err)
  24166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24167. return
  24168. }
  24169. resThree.ErrMsg = resThree10265.ErrMsg
  24170. resThree.Output = resThree10265.Output
  24171. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24172. } else {
  24173. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24174. utils.ErrorLog("解析失败:%v", err)
  24175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24176. return
  24177. }
  24178. }
  24179. if miConfig.Code == "H15049901371" {
  24180. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24181. } else {
  24182. infocode = resThree.Infcode
  24183. }
  24184. }
  24185. } else if res3101.Infcode != 0 {
  24186. c.ServeSuccessJSON(map[string]interface{}{
  24187. "failed_code": -10,
  24188. "msg": res3101.ErrMsg,
  24189. })
  24190. return
  24191. }
  24192. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24193. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24194. psn_info, _ := service.GetPsnByPatientId(id)
  24195. var verify_number string
  24196. if id_card_type == 4 {
  24197. verify_number = psn_info.VerifyNumber
  24198. } else if id_card_type == 1 {
  24199. bas := strings.Split(psn_info.CardInfo, "|")
  24200. cardNumber := bas[2]
  24201. verify_number = cardNumber
  24202. } else {
  24203. verify_number = psn_info.Certno
  24204. }
  24205. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24206. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24207. "&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
  24208. resp, requestErr := http.Get(api)
  24209. if requestErr != nil {
  24210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24211. return
  24212. }
  24213. body, ioErr := ioutil.ReadAll(resp.Body)
  24214. if ioErr != nil {
  24215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24217. return
  24218. }
  24219. var respJSON map[string]interface{}
  24220. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24223. return
  24224. }
  24225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24226. result, _ := json.Marshal(respJSON)
  24227. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24228. utils.ErrorLog("解析失败:%v", err)
  24229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24230. return
  24231. }
  24232. infocode = resThree.Infcode
  24233. } else {
  24234. hour := time.Now().Format("15")
  24235. min := time.Now().Format("04")
  24236. sec := time.Now().Format("05")
  24237. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24238. if id_card_type == 1 {
  24239. for _, item := range rf {
  24240. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24241. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24242. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24243. } else if strconv.FormatInt(social_type, 10) == "390" {
  24244. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24245. } else {
  24246. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24247. }
  24248. }
  24249. }
  24250. }
  24251. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24252. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24253. }
  24254. if id_card_type == 1 {
  24255. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24256. bas := strings.Split(psn_info.CardInfo, "|")
  24257. basNumber := bas[1]
  24258. IdCardNo = basNumber
  24259. }
  24260. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24261. IdCardNo = psn_info.VerifyNumber
  24262. }
  24263. if len(insuplc_admdvs_temp) == 0 {
  24264. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24265. }
  24266. var result string
  24267. var requestLog string
  24268. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24269. var hisPrescription []*models.HisPrescription
  24270. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24271. if res3101.Infcode == 0 {
  24272. if len(res3101.Output.Result) > 0 {
  24273. for _, item := range res3101.Output.Result {
  24274. if len(res3101.ErrMsg) == 0 {
  24275. res3101.ErrMsg = item.VolaCont
  24276. } else {
  24277. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24278. }
  24279. }
  24280. c.ServeSuccessJSON(map[string]interface{}{
  24281. "failed_code": -10,
  24282. "msg": res3101.ErrMsg,
  24283. })
  24284. return
  24285. } else {
  24286. hour := time.Now().Format("15")
  24287. min := time.Now().Format("04")
  24288. sec := time.Now().Format("05")
  24289. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24290. fmt.Println(record_time_two)
  24291. 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)
  24292. saveLog(result, requestLog, "2201A", "挂号")
  24293. if miConfig.Code == "H15049901371" {
  24294. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24295. utils.ErrorLog("解析失败:%v", err)
  24296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24297. return
  24298. }
  24299. resThree.ErrMsg = resThree10265.ErrMsg
  24300. resThree.Output = resThree10265.Output
  24301. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24302. } else {
  24303. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24304. utils.ErrorLog("解析失败:%v", err)
  24305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24306. return
  24307. }
  24308. }
  24309. if miConfig.Code == "H15049901371" {
  24310. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24311. } else {
  24312. infocode = resThree.Infcode
  24313. }
  24314. }
  24315. } else if res3101.Infcode != 0 {
  24316. c.ServeSuccessJSON(map[string]interface{}{
  24317. "failed_code": -10,
  24318. "msg": res3101.ErrMsg,
  24319. })
  24320. return
  24321. }
  24322. } else {
  24323. psn_info, _ := service.GetPsnByPatientId(id)
  24324. var rf []*ResultFive
  24325. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24326. //var insutypes []*ResultFive
  24327. var insutype string
  24328. if social_type > 0 {
  24329. insutype = strconv.FormatInt(social_type, 10)
  24330. }
  24331. for _, item := range rf {
  24332. if item.Insutype == insutype {
  24333. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24334. }
  24335. }
  24336. 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)
  24337. saveLog(result, requestLog, "2201A", "挂号")
  24338. }
  24339. if miConfig.Code == "H15049901371" {
  24340. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24341. utils.ErrorLog("解析失败:%v", err)
  24342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24343. return
  24344. }
  24345. resThree.ErrMsg = resThree10265.ErrMsg
  24346. resThree.Output = resThree10265.Output
  24347. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24348. } else {
  24349. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24350. utils.ErrorLog("解析失败:%v", err)
  24351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24352. return
  24353. }
  24354. }
  24355. if miConfig.Code == "H15049901371" {
  24356. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24357. } else {
  24358. infocode = resThree.Infcode
  24359. }
  24360. }
  24361. }
  24362. if infocode == -1 {
  24363. adminUser := c.GetAdminUserInfo()
  24364. errlog := &models.HisOrderError{
  24365. UserOrgId: adminUser.CurrentOrgId,
  24366. Ctime: time.Now().Unix(),
  24367. Mtime: time.Now().Unix(),
  24368. ErrMsg: resThree.ErrMsg,
  24369. Status: 1,
  24370. PatientId: id,
  24371. RecordTime: recordDateTime,
  24372. Stage: 2,
  24373. }
  24374. service.CreateErrMsgLog(errlog)
  24375. c.ServeSuccessJSON(map[string]interface{}{
  24376. "failed_code": -10,
  24377. "msg": resThree.ErrMsg,
  24378. })
  24379. return
  24380. }
  24381. his.Number = resThree.Output.Data.MdtrtID
  24382. his.PsnNo = resThree.Output.Data.PsnNo
  24383. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24384. his.IdCardNo = patient.IdCardNo
  24385. his.PhoneNumber = patient.Phone
  24386. his.UserOrgId = adminInfo.CurrentOrgId
  24387. his.Insutype = insutype
  24388. his.Ctime = time.Now().Unix()
  24389. his.Mtime = time.Now().Unix()
  24390. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24391. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24392. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24393. }
  24394. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24395. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24396. }
  24397. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24398. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24399. }
  24400. his.Status = 1
  24401. his.MdtrtGrpType = mdtrt_type
  24402. service.UpdateHisPatientStatus(&his)
  24403. service.UpdateHisPatient123(&patient)
  24404. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24405. c.ServeSuccessJSON(map[string]interface{}{
  24406. "his_info": his,
  24407. })
  24408. } else {
  24409. adminUser := c.GetAdminUserInfo()
  24410. errlog := &models.HisOrderError{
  24411. UserOrgId: adminUser.CurrentOrgId,
  24412. Ctime: time.Now().Unix(),
  24413. Mtime: time.Now().Unix(),
  24414. ErrMsg: res.ErrMsg,
  24415. Status: 1,
  24416. PatientId: id,
  24417. RecordTime: recordDateTime,
  24418. Stage: 1,
  24419. }
  24420. service.CreateErrMsgLog(errlog)
  24421. c.ServeSuccessJSON(map[string]interface{}{
  24422. "failed_code": -10,
  24423. "msg": res.ErrMsg,
  24424. })
  24425. return
  24426. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24427. }
  24428. }
  24429. }
  24430. func (c *HisApiController) GetUploadInfo() {
  24431. id, _ := c.GetInt64("id")
  24432. record_time := c.GetString("record_time")
  24433. his_patient_id, _ := c.GetInt64("his_patient_id")
  24434. order_id, _ := c.GetInt64("order_id")
  24435. pay_way, _ := c.GetInt64("pay_way")
  24436. pay_ways := c.GetString("pay_ways")
  24437. oth_desc := c.GetString("oth_desc")
  24438. pay_price, _ := c.GetFloat("pay_price")
  24439. pay_card_no := c.GetString("pay_card_no")
  24440. discount_price, _ := c.GetFloat("discount_price")
  24441. preferential_price, _ := c.GetFloat("preferential_price")
  24442. reality_price, _ := c.GetFloat("reality_price")
  24443. found_price, _ := c.GetFloat("found_price")
  24444. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24445. private_price, _ := c.GetFloat("private_price")
  24446. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24447. admin_user_id, _ := c.GetInt64("admin_user_id")
  24448. fapiao_code := c.GetString("fapiao_code")
  24449. fapiao_number := c.GetString("fapiao_number")
  24450. diagnosis_id := c.GetString("diagnosis")
  24451. sick_type, _ := c.GetInt64("sick_type")
  24452. reg_type, _ := c.GetInt64("p_type")
  24453. begin_time := c.GetString("begin_time")
  24454. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24455. cash_pay := c.GetString("cash_pay")
  24456. band_card_pay := c.GetString("band_card_pay")
  24457. wechat_pay := c.GetString("wechat_pay")
  24458. ali_pay := c.GetString("ali_pay")
  24459. jifen_pay := c.GetString("jifen_pay")
  24460. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24461. fmt.Println(acct_used_flag)
  24462. id_str := c.GetString("ids")
  24463. ids_arr := strings.Split(id_str, ",")
  24464. timeLayout := "2006-01-02"
  24465. loc, _ := time.LoadLocation("Local")
  24466. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24467. if err != nil {
  24468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24469. return
  24470. }
  24471. recordDateTime := theTime.Unix()
  24472. adminUser := c.GetAdminUserInfo()
  24473. var tempOrder models.HisOrder
  24474. tempOrder, _ = service.GetHisOrderByID(order_id)
  24475. var prescriptions []*models.HisPrescription
  24476. var start_time int64
  24477. var end_time int64
  24478. //押金模块
  24479. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24480. tmp_decimal := c.GetString("tmp_decimal")
  24481. var decimal float64 //本次使用的押金
  24482. var errmsg error
  24483. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24484. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24485. return
  24486. }
  24487. if len(tmp_decimal) > 0 {
  24488. if tmp_decimal[0] == 45 {
  24489. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24490. return
  24491. }
  24492. }
  24493. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24494. fmt.Println(errs)
  24495. decimal = tt
  24496. //if adminUser.CurrentOrgId == 10106{
  24497. // if len(fapiao_code) == 0{
  24498. // fapiao_code = "144072080589"
  24499. // }
  24500. // if len(fapiao_number) == 0{
  24501. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24502. // if order.ID == 0{
  24503. // fapiao_number = "00001520"
  24504. // }else{
  24505. // //fapiao_code = "00001520"
  24506. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24507. // var zero string
  24508. // if fpNumber >= 1000{
  24509. // zero = "0000" + strconv.Itoa(fpNumber)
  24510. // }else if fpNumber >= 10000{
  24511. // zero = "000" + strconv.Itoa(fpNumber)
  24512. // } else if fpNumber >= 100000{
  24513. // zero = "00" + strconv.Itoa(fpNumber)
  24514. // } else if fpNumber >= 1000000{
  24515. // zero = "0" + strconv.Itoa(fpNumber)
  24516. // }else {
  24517. // zero = strconv.Itoa(fpNumber)
  24518. // }
  24519. // fapiao_number = zero
  24520. // }
  24521. // }
  24522. //}
  24523. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24524. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24525. var patientPrescription models.HisPrescriptionInfo
  24526. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24527. if patientPrescription.ID == 0 {
  24528. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24529. }
  24530. //if patientPrescription.Do
  24531. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24532. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24533. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24534. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24535. var config []*models.HisXtDiagnoseConfig
  24536. for _, item := range diagnosis_ids {
  24537. id, _ := strconv.ParseInt(item, 10, 64)
  24538. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24539. config = append(config, &diagnosisConfig)
  24540. }
  24541. sickConfig, _ := service.FindSickById(sick_type)
  24542. //if tempOrder.ID == 0 {
  24543. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24544. //}
  24545. if tempOrder.ID == 0 {
  24546. var result string
  24547. var requestLog string
  24548. var res2 ResultSix
  24549. var res3 GZResultSix
  24550. var ressix10265 ResultSix10265
  24551. if miConfig.MdtrtareaAdmvs == "421300" {
  24552. data := make(map[string]interface{})
  24553. client := &http.Client{}
  24554. data["psn_no"] = his.PsnNo
  24555. data["mdtrt_id"] = his.Number
  24556. data["opter"] = roles.UserName
  24557. data["org_name"] = miConfig.OrgName
  24558. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24559. data["doctor_id"] = doctor_info.DoctorNumber
  24560. data["doctor_name"] = doctor_info.UserName
  24561. data["department"] = department.Name
  24562. data["fixmedins_code"] = miConfig.Code
  24563. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24564. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24565. data["secret_key"] = miConfig.SecretKey
  24566. data["sick_code"] = sickConfig.CountryCode
  24567. data["sick_name"] = sickConfig.ClassName
  24568. data["dept"] = strconv.FormatInt(department.ID, 10)
  24569. data["config"] = config
  24570. data["begin_time"] = begin_time
  24571. bytesData, _ := json.Marshal(data)
  24572. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24573. resp, _ := client.Do(req)
  24574. defer resp.Body.Close()
  24575. body, ioErr := ioutil.ReadAll(resp.Body)
  24576. if ioErr != nil {
  24577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24579. return
  24580. }
  24581. var respJSON map[string]interface{}
  24582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24585. return
  24586. }
  24587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24588. userJSONBytes, _ := json.Marshal(respJSON)
  24589. fmt.Println("log")
  24590. fmt.Println(string(userJSONBytes))
  24591. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24592. utils.ErrorLog("解析失败:%v", err)
  24593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24594. return
  24595. }
  24596. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24597. data := make(map[string]interface{})
  24598. client := &http.Client{}
  24599. data["psn_no"] = his.PsnNo
  24600. data["mdtrt_id"] = his.Number
  24601. data["opter"] = roles.UserName
  24602. data["org_name"] = miConfig.OrgName
  24603. if reg_type == 11 && his.Insutype == "390" {
  24604. data["med_type"] = "110104"
  24605. } else {
  24606. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24607. }
  24608. data["doctor_id"] = doctor_info.DoctorNumber
  24609. data["doctor_name"] = doctor_info.UserName
  24610. data["department"] = department.Name
  24611. data["fixmedins_code"] = miConfig.Code
  24612. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24613. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24614. data["secret_key"] = miConfig.SecretKey
  24615. data["sick_code"] = sickConfig.CountryCode
  24616. data["sick_name"] = sickConfig.ClassName
  24617. data["dept"] = strconv.FormatInt(department.ID, 10)
  24618. data["config"] = config
  24619. data["begin_time"] = begin_time
  24620. bytesData, _ := json.Marshal(data)
  24621. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24622. resp, _ := client.Do(req)
  24623. defer resp.Body.Close()
  24624. body, ioErr := ioutil.ReadAll(resp.Body)
  24625. if ioErr != nil {
  24626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24628. return
  24629. }
  24630. var respJSON map[string]interface{}
  24631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24634. return
  24635. }
  24636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24637. userJSONBytes, _ := json.Marshal(respJSON)
  24638. fmt.Println("log")
  24639. fmt.Println(string(userJSONBytes))
  24640. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24641. utils.ErrorLog("解析失败:%v", err)
  24642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24643. return
  24644. }
  24645. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24646. data := make(map[string]interface{})
  24647. client := &http.Client{}
  24648. data["psn_no"] = his.PsnNo
  24649. data["mdtrt_id"] = his.Number
  24650. data["opter"] = roles.UserName
  24651. data["org_name"] = miConfig.OrgName
  24652. if reg_type == 11 && his.Insutype == "390" {
  24653. data["med_type"] = "110104"
  24654. } else {
  24655. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24656. }
  24657. data["doctor_id"] = doctor_info.DoctorNumber
  24658. data["doctor_name"] = doctor_info.UserName
  24659. data["department"] = department.Name
  24660. data["fixmedins_code"] = miConfig.Code
  24661. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24662. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24663. data["secret_key"] = miConfig.SecretKey
  24664. data["sick_code"] = sickConfig.CountryCode
  24665. data["sick_name"] = sickConfig.ClassName
  24666. data["dept"] = strconv.FormatInt(department.ID, 10)
  24667. data["config"] = config
  24668. data["begin_time"] = begin_time
  24669. bytesData, _ := json.Marshal(data)
  24670. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24671. resp, _ := client.Do(req)
  24672. defer resp.Body.Close()
  24673. body, ioErr := ioutil.ReadAll(resp.Body)
  24674. if ioErr != nil {
  24675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24677. return
  24678. }
  24679. var respJSON map[string]interface{}
  24680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24683. return
  24684. }
  24685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24686. userJSONBytes, _ := json.Marshal(respJSON)
  24687. fmt.Println("log")
  24688. fmt.Println(string(userJSONBytes))
  24689. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24690. utils.ErrorLog("解析失败:%v", err)
  24691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24692. return
  24693. }
  24694. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24695. data := make(map[string]interface{})
  24696. client := &http.Client{}
  24697. data["psn_no"] = his.PsnNo
  24698. data["mdtrt_id"] = his.Number
  24699. data["opter"] = roles.UserName
  24700. data["org_name"] = miConfig.OrgName
  24701. if reg_type == 11 && his.Insutype == "390" {
  24702. data["med_type"] = "110104"
  24703. } else {
  24704. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24705. }
  24706. data["doctor_id"] = doctor_info.DoctorNumber
  24707. data["doctor_name"] = doctor_info.UserName
  24708. data["department"] = department.Name
  24709. data["fixmedins_code"] = miConfig.Code
  24710. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24711. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24712. data["secret_key"] = miConfig.SecretKey
  24713. data["sick_code"] = sickConfig.CountryCode
  24714. data["sick_name"] = sickConfig.ClassName
  24715. data["dept"] = strconv.FormatInt(department.ID, 10)
  24716. data["config"] = config
  24717. data["begin_time"] = begin_time
  24718. bytesData, _ := json.Marshal(data)
  24719. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24720. resp, _ := client.Do(req)
  24721. defer resp.Body.Close()
  24722. body, ioErr := ioutil.ReadAll(resp.Body)
  24723. if ioErr != nil {
  24724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24726. return
  24727. }
  24728. var respJSON map[string]interface{}
  24729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24732. return
  24733. }
  24734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24735. userJSONBytes, _ := json.Marshal(respJSON)
  24736. fmt.Println("log")
  24737. fmt.Println(string(userJSONBytes))
  24738. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24739. utils.ErrorLog("解析失败:%v", err)
  24740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24741. return
  24742. }
  24743. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24744. data := make(map[string]interface{})
  24745. client := &http.Client{}
  24746. data["psn_no"] = his.PsnNo
  24747. data["mdtrt_id"] = his.Number
  24748. data["doctor"] = roles.UserName
  24749. data["department"] = department.Name
  24750. data["org_name"] = miConfig.OrgName
  24751. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24752. data["doctor_id"] = doctor_info.DoctorNumber
  24753. data["new_doctor_name"] = doctor_info.UserName
  24754. data["fixmedins_code"] = miConfig.Code
  24755. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24756. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24757. data["secret_key"] = miConfig.SecretKey
  24758. data["sick_code"] = sickConfig.CountryCode
  24759. data["sick_name"] = sickConfig.ClassName
  24760. data["url"] = miConfig.Url
  24761. data["ak"] = miConfig.AccessKey
  24762. data["begin_time"] = begin_time
  24763. data["cainfo"] = miConfig.Cainfo
  24764. data["dept"] = strconv.FormatInt(department.ID, 10)
  24765. data["config"] = config
  24766. bytesData, _ := json.Marshal(data)
  24767. var req *http.Request
  24768. if miConfig.MdtrtareaAdmvs == "320921" {
  24769. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24770. //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 +
  24771. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  24772. } else {
  24773. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24774. }
  24775. resp, _ := client.Do(req)
  24776. defer resp.Body.Close()
  24777. body, ioErr := ioutil.ReadAll(resp.Body)
  24778. if ioErr != nil {
  24779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24781. return
  24782. }
  24783. var respJSON map[string]interface{}
  24784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24787. return
  24788. }
  24789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24790. userJSONBytes, _ := json.Marshal(respJSON)
  24791. fmt.Println("log")
  24792. fmt.Println(string(userJSONBytes))
  24793. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24794. utils.ErrorLog("解析失败:%v", err)
  24795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24796. return
  24797. }
  24798. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24799. res2.Output = ressix10265.Output
  24800. res2.ErrMsg = ressix10265.ErrMsg
  24801. res2.Cainfo = ressix10265.Cainfo
  24802. res2.WarnMsg = ressix10265.WarnMsg
  24803. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24804. res2.Infcode = infocode
  24805. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24806. data := make(map[string]interface{})
  24807. client := &http.Client{}
  24808. data["psn_no"] = his.PsnNo
  24809. data["mdtrt_id"] = his.Number
  24810. data["doctor"] = roles.UserName
  24811. data["department"] = department.Name
  24812. data["org_name"] = miConfig.OrgName
  24813. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24814. data["doctor_id"] = doctor_info.DoctorNumber
  24815. data["new_doctor_name"] = doctor_info.UserName
  24816. data["fixmedins_code"] = miConfig.Code
  24817. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24818. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24819. data["secret_key"] = miConfig.SecretKey
  24820. data["sick_code"] = sickConfig.CountryCode
  24821. data["sick_name"] = sickConfig.ClassName
  24822. data["url"] = miConfig.Url
  24823. data["ak"] = miConfig.AccessKey
  24824. data["begin_time"] = begin_time
  24825. data["cainfo"] = miConfig.Cainfo
  24826. data["dept"] = strconv.FormatInt(department.ID, 10)
  24827. data["config"] = config
  24828. bytesData, _ := json.Marshal(data)
  24829. var req *http.Request
  24830. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  24831. resp, _ := client.Do(req)
  24832. defer resp.Body.Close()
  24833. body, ioErr := ioutil.ReadAll(resp.Body)
  24834. if ioErr != nil {
  24835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24837. return
  24838. }
  24839. var respJSON map[string]interface{}
  24840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24843. return
  24844. }
  24845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24846. userJSONBytes, _ := json.Marshal(respJSON)
  24847. fmt.Println("log")
  24848. fmt.Println(string(userJSONBytes))
  24849. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24850. utils.ErrorLog("解析失败:%v", err)
  24851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24852. return
  24853. }
  24854. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24855. res2.Output = ressix10265.Output
  24856. res2.ErrMsg = ressix10265.ErrMsg
  24857. res2.Cainfo = ressix10265.Cainfo
  24858. res2.WarnMsg = ressix10265.WarnMsg
  24859. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24860. res2.Infcode = infocode
  24861. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24862. 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)
  24863. saveLog(result, requestLog, "2203", "上传就诊信息")
  24864. var respJSON2 map[string]interface{}
  24865. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24868. return
  24869. }
  24870. userJSONBytes2, _ := json.Marshal(respJSON2)
  24871. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24872. utils.ErrorLog("解析失败:%v", err)
  24873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24874. return
  24875. }
  24876. 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)
  24877. fmt.Println(result2)
  24878. fmt.Println(src_request)
  24879. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24880. data := make(map[string]interface{})
  24881. client := &http.Client{}
  24882. data["psn_no"] = his.PsnNo
  24883. data["mdtrt_id"] = his.Number
  24884. data["doctor"] = roles.UserName
  24885. data["department"] = department.Name
  24886. data["org_name"] = miConfig.OrgName
  24887. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24888. data["doctor_id"] = doctor_info.DoctorNumber
  24889. data["new_doctor_name"] = doctor_info.UserName
  24890. data["fixmedins_code"] = miConfig.Code
  24891. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24892. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24893. data["secret_key"] = miConfig.SecretKey
  24894. data["sick_code"] = sickConfig.CountryCode
  24895. data["sick_name"] = sickConfig.ClassName
  24896. data["url"] = miConfig.Url
  24897. data["ak"] = miConfig.AccessKey
  24898. data["begin_time"] = begin_time
  24899. data["cainfo"] = miConfig.Cainfo
  24900. data["dept"] = strconv.FormatInt(department.ID, 10)
  24901. data["config"] = config
  24902. bytesData, _ := json.Marshal(data)
  24903. var req *http.Request
  24904. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  24905. resp, _ := client.Do(req)
  24906. defer resp.Body.Close()
  24907. body, ioErr := ioutil.ReadAll(resp.Body)
  24908. if ioErr != nil {
  24909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24911. return
  24912. }
  24913. var respJSON map[string]interface{}
  24914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24917. return
  24918. }
  24919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24920. userJSONBytes, _ := json.Marshal(respJSON)
  24921. fmt.Println("log")
  24922. fmt.Println(string(userJSONBytes))
  24923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24924. utils.ErrorLog("解析失败:%v", err)
  24925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24926. return
  24927. }
  24928. } else {
  24929. if miConfig.MdtrtareaAdmvs == "440781" { //
  24930. 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)
  24931. } else {
  24932. if miConfig.Code == "H15049901371" {
  24933. //赤峰地区国家医保医疗类别
  24934. //职工透析:医疗类别选特殊情况门诊990502
  24935. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24936. var med_type string
  24937. if his.Insutype == "390" {
  24938. if reg_type == 14 {
  24939. med_type = "9933"
  24940. } else if reg_type == 11 {
  24941. med_type = "11"
  24942. }
  24943. } else if his.Insutype == "310" {
  24944. if reg_type == 14 {
  24945. med_type = "990502"
  24946. } else if reg_type == 11 {
  24947. med_type = "11"
  24948. }
  24949. }
  24950. 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)
  24951. } else {
  24952. 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)
  24953. }
  24954. }
  24955. saveLog(result, requestLog, "2203", "上传就诊信息")
  24956. var respJSON2 map[string]interface{}
  24957. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24960. return
  24961. }
  24962. userJSONBytes2, _ := json.Marshal(respJSON2)
  24963. if miConfig.Code == "H15049901371" {
  24964. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  24965. utils.ErrorLog("解析失败:%v", err)
  24966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24967. return
  24968. }
  24969. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24970. res2.Output = ressix10265.Output
  24971. res2.ErrMsg = ressix10265.ErrMsg
  24972. res2.Cainfo = ressix10265.Cainfo
  24973. res2.WarnMsg = ressix10265.WarnMsg
  24974. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24975. res2.Infcode = infocode
  24976. } else {
  24977. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24978. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  24979. utils.ErrorLog("解析失败:%v", err)
  24980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24981. return
  24982. }
  24983. res2.Infcode = res3.Infcode
  24984. } else {
  24985. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24986. utils.ErrorLog("解析失败:%v", err)
  24987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24988. return
  24989. }
  24990. }
  24991. }
  24992. }
  24993. if res2.Infcode == -1 {
  24994. adminUser := c.GetAdminUserInfo()
  24995. errlog := &models.HisOrderError{
  24996. UserOrgId: adminUser.CurrentOrgId,
  24997. Ctime: time.Now().Unix(),
  24998. Mtime: time.Now().Unix(),
  24999. ErrMsg: res2.ErrMsg,
  25000. Status: 1,
  25001. PatientId: id,
  25002. RecordTime: recordDateTime,
  25003. Stage: 3,
  25004. }
  25005. service.CreateErrMsgLog(errlog)
  25006. c.ServeSuccessJSON(map[string]interface{}{
  25007. "failed_code": -10,
  25008. "msg": res2.ErrMsg,
  25009. })
  25010. return
  25011. } else {
  25012. his.Diagnosis = diagnosis_id
  25013. his.SickType = sickConfig.ID
  25014. //var p_type int64
  25015. //if reg_type == 1111 || reg_type == 1112 {
  25016. // p_type = 11
  25017. //
  25018. //}
  25019. his.PType = fmt.Sprintf("%d", reg_type)
  25020. service.UpdateHisPatientThree(&his)
  25021. data := make(map[string]interface{})
  25022. if settle_accounts_type == 1 { //日结
  25023. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25024. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25025. } else {
  25026. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25027. }
  25028. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25029. data["pre"] = prescriptions
  25030. } else { //月结
  25031. start_time_str := c.GetString("start_time")
  25032. end_time_str := c.GetString("end_time")
  25033. timeLayout := "2006-01-02"
  25034. loc, _ := time.LoadLocation("Local")
  25035. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25036. if err != nil {
  25037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25038. return
  25039. }
  25040. recordStartTime := theStartTime.Unix()
  25041. start_time = recordStartTime
  25042. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25043. if err != nil {
  25044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25045. return
  25046. }
  25047. recordEndTime := theEndTime.Unix()
  25048. end_time = recordEndTime
  25049. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25050. data["pre"] = prescriptions
  25051. }
  25052. timestamp := time.Now().Unix()
  25053. tempTime := time.Unix(timestamp, 0)
  25054. timeFormat := tempTime.Format("20060102150405")
  25055. chrgBchno := rand.Intn(100000) + 10000
  25056. new_chrg_bchno := ""
  25057. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25058. new_chrg_bchno = chrg_bchno
  25059. strconv.FormatInt(his.PatientId, 10)
  25060. client := &http.Client{}
  25061. if adminUser.CurrentOrgId == 10265 {
  25062. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25063. new_chrg_bchno = "0000"
  25064. }
  25065. }
  25066. data["psn_no"] = his.PsnNo
  25067. data["mdtrt_id"] = his.Number
  25068. data["chrg_bchno"] = new_chrg_bchno
  25069. data["org_name"] = miConfig.OrgName
  25070. data["doctor"] = doctor_info.UserName
  25071. data["doctor_id"] = doctor_info.DoctorNumber
  25072. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25073. data["fixmedins_code"] = miConfig.Code
  25074. data["dept_code"] = department.Number
  25075. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25076. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25077. data["secret_key"] = miConfig.SecretKey
  25078. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25079. data["url"] = miConfig.Url
  25080. data["ak"] = miConfig.AccessKey
  25081. data["new_doctor_name"] = patientPrescription.Doctor
  25082. data["diag_code"] = sickConfig.CountryCode
  25083. data["cainfo"] = miConfig.Cainfo
  25084. data["opter"] = roles.UserName
  25085. var ids []int64
  25086. for _, item := range prescriptions {
  25087. ids = append(ids, item.ID)
  25088. }
  25089. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25090. if config.IsOpen == 1 { //对接了医保,走医保流程
  25091. var res ResultFour
  25092. var resFour10265 ResultFour10265
  25093. if miConfig.MdtrtareaAdmvs == "421300" {
  25094. bytesData, _ := json.Marshal(data)
  25095. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25096. resp, _ := client.Do(req)
  25097. defer resp.Body.Close()
  25098. body, ioErr := ioutil.ReadAll(resp.Body)
  25099. if ioErr != nil {
  25100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25102. return
  25103. }
  25104. var respJSON map[string]interface{}
  25105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25108. return
  25109. }
  25110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25111. userJSONBytes, _ := json.Marshal(respJSON)
  25112. fmt.Println("log")
  25113. fmt.Println(string(userJSONBytes))
  25114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25115. utils.ErrorLog("解析失败:%v", err)
  25116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25117. return
  25118. }
  25119. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25120. bytesData, _ := json.Marshal(data)
  25121. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25122. resp, _ := client.Do(req)
  25123. defer resp.Body.Close()
  25124. body, ioErr := ioutil.ReadAll(resp.Body)
  25125. if ioErr != nil {
  25126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25128. return
  25129. }
  25130. var respJSON map[string]interface{}
  25131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25134. return
  25135. }
  25136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25137. userJSONBytes, _ := json.Marshal(respJSON)
  25138. fmt.Println("log")
  25139. fmt.Println(string(userJSONBytes))
  25140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25141. utils.ErrorLog("解析失败:%v", err)
  25142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25143. return
  25144. }
  25145. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25146. bytesData, _ := json.Marshal(data)
  25147. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25148. resp, _ := client.Do(req)
  25149. defer resp.Body.Close()
  25150. body, ioErr := ioutil.ReadAll(resp.Body)
  25151. if ioErr != nil {
  25152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25154. return
  25155. }
  25156. var respJSON map[string]interface{}
  25157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25160. return
  25161. }
  25162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25163. userJSONBytes, _ := json.Marshal(respJSON)
  25164. fmt.Println("log")
  25165. fmt.Println(string(userJSONBytes))
  25166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25167. utils.ErrorLog("解析失败:%v", err)
  25168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25169. return
  25170. }
  25171. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25172. bytesData, _ := json.Marshal(data)
  25173. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25174. resp, _ := client.Do(req)
  25175. defer resp.Body.Close()
  25176. body, ioErr := ioutil.ReadAll(resp.Body)
  25177. if ioErr != nil {
  25178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25180. return
  25181. }
  25182. var respJSON map[string]interface{}
  25183. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25186. return
  25187. }
  25188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25189. userJSONBytes, _ := json.Marshal(respJSON)
  25190. fmt.Println("log")
  25191. fmt.Println(string(userJSONBytes))
  25192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25193. utils.ErrorLog("解析失败:%v", err)
  25194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25195. return
  25196. }
  25197. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25198. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25199. if result3101.Infcode == "0" {
  25200. if len(result3101.Output.Result) > 0 {
  25201. var errMsgs []string
  25202. for _, item := range result3101.Output.Result {
  25203. errMsgs = append(errMsgs, item.VolaCont)
  25204. }
  25205. c.ServeSuccessJSON(map[string]interface{}{
  25206. "failed_code": -10,
  25207. "msg": errMsgs,
  25208. })
  25209. return
  25210. }
  25211. }
  25212. bytesData, _ := json.Marshal(data)
  25213. var req *http.Request
  25214. if miConfig.MdtrtareaAdmvs == "320921" {
  25215. data["diag_code"] = sickConfig.CountryCode
  25216. fmt.Println(data)
  25217. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25218. } else {
  25219. data["diag_code"] = sickConfig.CountryCode
  25220. fmt.Println(data)
  25221. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25222. }
  25223. resp, _ := client.Do(req)
  25224. defer resp.Body.Close()
  25225. body, ioErr := ioutil.ReadAll(resp.Body)
  25226. if ioErr != nil {
  25227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25229. return
  25230. }
  25231. var respJSON map[string]interface{}
  25232. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25235. return
  25236. }
  25237. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25238. userJSONBytes, _ := json.Marshal(respJSON)
  25239. fmt.Println("log")
  25240. fmt.Println(string(userJSONBytes))
  25241. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25242. utils.ErrorLog("解析失败:%v", err)
  25243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25244. return
  25245. }
  25246. res.InfRefmsgid = resFour10265.InfRefmsgid
  25247. res.Output = resFour10265.Output
  25248. res.ErrMsg = resFour10265.ErrMsg
  25249. res.Cainfo = resFour10265.Cainfo
  25250. res.WarnMsg = resFour10265.WarnMsg
  25251. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25252. res.Infcode = infocode
  25253. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25254. var pagesize int = 2
  25255. var start int = 1
  25256. var stop int
  25257. var pagecount int
  25258. var curpage int
  25259. var isSuccess bool = true
  25260. data["doctor_id"] = doctor_info.DoctorNumber
  25261. //总页数,向上取整,注意除之前要先转换类型为float64
  25262. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25263. for curpage = 1; curpage <= pagecount; curpage++ {
  25264. if curpage == 1 {
  25265. start = 1
  25266. } else {
  25267. start = (curpage-1)*pagesize + 1
  25268. }
  25269. stop = curpage * pagesize
  25270. if stop > len(prescriptions) {
  25271. stop = len(prescriptions)
  25272. }
  25273. //var requestLog string
  25274. data["pre"] = prescriptions[start-1 : stop]
  25275. fmt.Println(data["pre"])
  25276. bytesData, _ := json.Marshal(data)
  25277. var req *http.Request
  25278. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25279. resp, _ := client.Do(req)
  25280. defer resp.Body.Close()
  25281. body, ioErr := ioutil.ReadAll(resp.Body)
  25282. if ioErr != nil {
  25283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25285. return
  25286. }
  25287. var respJSON map[string]interface{}
  25288. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25291. return
  25292. }
  25293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25294. userJSONBytes, _ := json.Marshal(respJSON)
  25295. fmt.Println("log")
  25296. fmt.Println(string(userJSONBytes))
  25297. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25298. utils.ErrorLog("解析失败:%v", err)
  25299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25300. return
  25301. }
  25302. res.InfRefmsgid = resFour10265.InfRefmsgid
  25303. res.Output = resFour10265.Output
  25304. res.ErrMsg = resFour10265.ErrMsg
  25305. res.Cainfo = resFour10265.Cainfo
  25306. res.WarnMsg = resFour10265.WarnMsg
  25307. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25308. res.Infcode = infocode
  25309. if infocode == 0 {
  25310. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25311. } else {
  25312. isSuccess = false
  25313. errlog := &models.HisOrderError{
  25314. UserOrgId: adminUser.CurrentOrgId,
  25315. Ctime: time.Now().Unix(),
  25316. Mtime: time.Now().Unix(),
  25317. Number: chrg_bchno,
  25318. ErrMsg: "",
  25319. Status: 1,
  25320. PatientId: id,
  25321. RecordTime: recordDateTime,
  25322. Stage: 4,
  25323. }
  25324. service.CreateErrMsgLog(errlog)
  25325. c.ServeSuccessJSON(map[string]interface{}{
  25326. "failed_code": -10,
  25327. "msg": res.ErrMsg,
  25328. })
  25329. return
  25330. }
  25331. }
  25332. if isSuccess {
  25333. res.Infcode = 0
  25334. }
  25335. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25336. 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)
  25337. var dat map[string]interface{}
  25338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25339. fmt.Println(dat)
  25340. } else {
  25341. fmt.Println(err)
  25342. }
  25343. saveLog(result, request_log, "2204", "上传费用明细")
  25344. userJSONBytes, _ := json.Marshal(dat)
  25345. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25346. utils.ErrorLog("解析失败:%v", err)
  25347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25348. return
  25349. }
  25350. res.InfRefmsgid = resFour10265.InfRefmsgid
  25351. res.Output = resFour10265.Output
  25352. res.ErrMsg = resFour10265.ErrMsg
  25353. res.Cainfo = resFour10265.Cainfo
  25354. res.WarnMsg = resFour10265.WarnMsg
  25355. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25356. res.Infcode = infocode
  25357. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25358. bytesData, _ := json.Marshal(data)
  25359. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25360. resp, _ := client.Do(req)
  25361. defer resp.Body.Close()
  25362. body, ioErr := ioutil.ReadAll(resp.Body)
  25363. if ioErr != nil {
  25364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25366. return
  25367. }
  25368. var respJSON map[string]interface{}
  25369. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25372. return
  25373. }
  25374. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25375. userJSONBytes, _ := json.Marshal(respJSON)
  25376. fmt.Println("log")
  25377. fmt.Println(string(userJSONBytes))
  25378. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25379. utils.ErrorLog("解析失败:%v", err)
  25380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25381. return
  25382. }
  25383. } else {
  25384. if miConfig.Code == "H15049901371" {
  25385. 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)
  25386. var dat map[string]interface{}
  25387. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25388. fmt.Println(dat)
  25389. } else {
  25390. fmt.Println(err)
  25391. }
  25392. saveLog(result, request_log, "2204", "上传费用明细")
  25393. userJSONBytes, _ := json.Marshal(dat)
  25394. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25395. utils.ErrorLog("解析失败:%v", err)
  25396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25397. return
  25398. }
  25399. res.InfRefmsgid = resFour10265.InfRefmsgid
  25400. res.Output = resFour10265.Output
  25401. res.ErrMsg = resFour10265.ErrMsg
  25402. res.Cainfo = resFour10265.Cainfo
  25403. res.WarnMsg = resFour10265.WarnMsg
  25404. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25405. res.Infcode = infocode
  25406. } else {
  25407. 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)
  25408. var dat map[string]interface{}
  25409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25410. fmt.Println(dat)
  25411. } else {
  25412. fmt.Println(err)
  25413. }
  25414. saveLog(result, request_log, "2204", "上传费用明细")
  25415. userJSONBytes, _ := json.Marshal(dat)
  25416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25417. utils.ErrorLog("解析失败:%v", err)
  25418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25419. return
  25420. }
  25421. }
  25422. }
  25423. if res.Infcode == 0 {
  25424. order := &models.HisOrder{
  25425. UserOrgId: adminUser.CurrentOrgId,
  25426. HisPatientId: his.ID,
  25427. PatientId: his.PatientId,
  25428. SettleAccountsDate: recordDateTime,
  25429. MdtrtId: his.Number,
  25430. PsnNo: his.PsnNo,
  25431. MedType: strconv.FormatInt(reg_type, 10),
  25432. Ctime: time.Now().Unix(),
  25433. Mtime: time.Now().Unix(),
  25434. Status: 1,
  25435. Number: chrg_bchno,
  25436. Infcode: res.Infcode,
  25437. WarnMsg: res.WarnMsg,
  25438. Cainfo: res.Cainfo,
  25439. ErrMsg: res.ErrMsg,
  25440. RespondTime: res.RefmsgTime,
  25441. InfRefmsgid: res.InfRefmsgid,
  25442. OrderStatus: 1,
  25443. PayWay: pay_way,
  25444. PayWays: pay_ways,
  25445. OthDesc: oth_desc,
  25446. PayPrice: pay_price,
  25447. PayCardNo: pay_card_no,
  25448. DiscountPrice: discount_price,
  25449. PreferentialPrice: preferential_price,
  25450. RealityPrice: reality_price,
  25451. FoundPrice: found_price,
  25452. MedicalInsurancePrice: medical_insurance_price,
  25453. PrivatePrice: private_price,
  25454. IsMedicineInsurance: 1,
  25455. SettleType: settle_accounts_type,
  25456. SettleStartTime: start_time,
  25457. SettleEndTime: end_time,
  25458. Creator: roles.AdminUserId,
  25459. Modify: roles.AdminUserId,
  25460. FaPiaoNumber: fapiao_number,
  25461. FaPiaoCode: fapiao_code,
  25462. PType: 2,
  25463. Diagnosis: diagnosis_id,
  25464. CashPay: cash_pay,
  25465. WechatPay: wechat_pay,
  25466. AliPay: ali_pay,
  25467. JifenPay: jifen_pay,
  25468. BandCardPay: band_card_pay,
  25469. }
  25470. err = service.CreateOrder(order)
  25471. if err != nil {
  25472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25473. return
  25474. }
  25475. for _, item := range res.Output.Result {
  25476. temp := strings.Split(item.FeedetlSn, "-")
  25477. var advice_id int64 = 0
  25478. var project_id int64 = 0
  25479. var types int64 = 0
  25480. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25481. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25482. if temp[1] == "1" {
  25483. advice_id = id
  25484. project_id = 0
  25485. } else if temp[1] == "2" {
  25486. advice_id = 0
  25487. project_id = id
  25488. }
  25489. if item.MedChrgitmType == "9" {
  25490. item.MedChrgitmType = "09"
  25491. }
  25492. info := &models.HisOrderInfo{
  25493. OrderNumber: order.Number,
  25494. FeedetlSn: item.FeedetlSn,
  25495. UploadDate: time.Now().Unix(),
  25496. AdviceId: advice_id,
  25497. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25498. Cnt: item.Cnt,
  25499. Pric: float64(item.Pric),
  25500. PatientId: his.PatientId,
  25501. PricUplmtAmt: item.PricUplmtAmt,
  25502. SelfpayProp: item.SelfpayProp,
  25503. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25504. OverlmtAmt: item.OverlmtAmt,
  25505. PreselfpayAmt: item.PreselfpayAmt,
  25506. BasMednFlag: item.BasMednFlag,
  25507. MedChrgitmType: item.MedChrgitmType,
  25508. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25509. Status: 1,
  25510. Memo: item.Memo,
  25511. Mtime: time.Now().Unix(),
  25512. InscpScpAmt: item.InscpScpAmt,
  25513. DrtReimFlag: item.DrtReimFlag,
  25514. Ctime: time.Now().Unix(),
  25515. ListSpItemFlag: item.ListSpItemFlag,
  25516. ChldMedcFlag: item.ChldMedcFlag,
  25517. LmtUsedFlag: item.LmtUsedFlag,
  25518. ChrgitmLv: item.ChrgitmLv,
  25519. UserOrgId: adminUser.CurrentOrgId,
  25520. HisPatientId: his.ID,
  25521. OrderId: order.ID,
  25522. ProjectId: project_id,
  25523. Type: types,
  25524. }
  25525. service.CreateOrderInfo(info)
  25526. }
  25527. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25528. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25529. var total float64
  25530. for _, item := range prescriptions {
  25531. if item.Type == 1 { //药品
  25532. for _, subItem := range item.HisDoctorAdviceInfo {
  25533. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25534. total_one := price * subItem.PrescribingNumber
  25535. total = total + total_one
  25536. }
  25537. }
  25538. if item.Type == 2 { //项目
  25539. for _, subItem := range item.HisPrescriptionProject {
  25540. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25541. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25542. total_one := price * cnt
  25543. total = total + total_one
  25544. }
  25545. }
  25546. }
  25547. allTotal := fmt.Sprintf("%.2f", total)
  25548. //if adminUser.CurrentOrgId == 9919 {
  25549. //
  25550. // allTotal = fmt.Sprintf("%.2f", total)
  25551. //
  25552. //} else {
  25553. //
  25554. // allTotal = fmt.Sprintf("%.2f", total)
  25555. //
  25556. //}
  25557. if res.Infcode == 0 {
  25558. var rf []*ResultFive
  25559. json.Unmarshal([]byte(his.Iinfo), &rf)
  25560. chrg_bchno := chrg_bchno
  25561. cert_no := his.Certno
  25562. var insutypes []string
  25563. var insutype string
  25564. var is390 int = 0
  25565. var is310 int = 0
  25566. for _, item := range rf {
  25567. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25568. insutypes = append(insutypes, item.Insutype)
  25569. }
  25570. }
  25571. if len(insutypes) == 1 {
  25572. insutype = insutypes[0]
  25573. } else {
  25574. for _, i := range insutypes {
  25575. if i == "390" {
  25576. is390 = 1
  25577. }
  25578. if i == "310" {
  25579. is310 = 1
  25580. }
  25581. }
  25582. }
  25583. if is390 == 1 {
  25584. insutype = "390"
  25585. }
  25586. if is310 == 1 {
  25587. insutype = "310"
  25588. }
  25589. if len(insutypes) == 0 {
  25590. insutype = "310"
  25591. }
  25592. if len(insutypes) == 2 {
  25593. insutype = strconv.FormatInt(his.SocialType, 10)
  25594. }
  25595. insutype = strconv.FormatInt(his.SocialType, 10)
  25596. //insutype = "390"
  25597. if his.IdCardType == 1 {
  25598. // cert_no = his.MedicalInsuranceNumber
  25599. cert_no = his.Certno
  25600. } else {
  25601. cert_no = his.Certno
  25602. }
  25603. var res ResultSeven
  25604. var resSeven10265 ResultSeven10265
  25605. var gzresSeven10265Two GZResultSeven10265Two
  25606. var src_resquest string
  25607. var result2 string
  25608. if miConfig.MdtrtareaAdmvs == "421300" {
  25609. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25610. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25611. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25612. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25613. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25614. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25615. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25616. resp, requestErr := http.Get(api)
  25617. if requestErr != nil {
  25618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25619. return
  25620. }
  25621. body, ioErr := ioutil.ReadAll(resp.Body)
  25622. if ioErr != nil {
  25623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25625. return
  25626. }
  25627. var respJSON map[string]interface{}
  25628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25631. return
  25632. }
  25633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25634. result, _ := json.Marshal(respJSON)
  25635. if miConfig.Code == "H15049901371" {
  25636. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25637. utils.ErrorLog("解析失败:%v", err)
  25638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25639. return
  25640. }
  25641. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25642. res.Output = resSeven10265.Output
  25643. res.ErrMsg = resSeven10265.ErrMsg
  25644. res.Cainfo = resSeven10265.Cainfo
  25645. res.WarnMsg = resSeven10265.WarnMsg
  25646. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25647. res.Infcode = infocode
  25648. } else {
  25649. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25650. utils.ErrorLog("解析失败:%v", err)
  25651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25652. return
  25653. }
  25654. }
  25655. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25656. if reg_type == 11 && his.Insutype == "390" {
  25657. reg_type = 110104
  25658. }
  25659. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25660. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25661. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25662. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25663. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25664. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25665. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25666. resp, requestErr := http.Get(api)
  25667. if requestErr != nil {
  25668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25669. return
  25670. }
  25671. body, ioErr := ioutil.ReadAll(resp.Body)
  25672. if ioErr != nil {
  25673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25675. return
  25676. }
  25677. var respJSON map[string]interface{}
  25678. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25681. return
  25682. }
  25683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25684. result, _ := json.Marshal(respJSON)
  25685. if miConfig.Code == "H15049901371" {
  25686. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25687. utils.ErrorLog("解析失败:%v", err)
  25688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25689. return
  25690. }
  25691. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25692. res.Output = resSeven10265.Output
  25693. res.ErrMsg = resSeven10265.ErrMsg
  25694. res.Cainfo = resSeven10265.Cainfo
  25695. res.WarnMsg = resSeven10265.WarnMsg
  25696. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25697. res.Infcode = infocode
  25698. } else {
  25699. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25700. utils.ErrorLog("解析失败:%v", err)
  25701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25702. return
  25703. }
  25704. }
  25705. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25706. if reg_type == 11 && his.Insutype == "390" {
  25707. reg_type = 110104
  25708. }
  25709. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25710. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25711. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25712. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25713. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25714. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25715. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25716. resp, requestErr := http.Get(api)
  25717. if requestErr != nil {
  25718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25719. return
  25720. }
  25721. body, ioErr := ioutil.ReadAll(resp.Body)
  25722. if ioErr != nil {
  25723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25725. return
  25726. }
  25727. var respJSON map[string]interface{}
  25728. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25731. return
  25732. }
  25733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25734. result, _ := json.Marshal(respJSON)
  25735. if miConfig.Code == "H15049901371" {
  25736. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25737. utils.ErrorLog("解析失败:%v", err)
  25738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25739. return
  25740. }
  25741. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25742. res.Output = resSeven10265.Output
  25743. res.ErrMsg = resSeven10265.ErrMsg
  25744. res.Cainfo = resSeven10265.Cainfo
  25745. res.WarnMsg = resSeven10265.WarnMsg
  25746. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25747. res.Infcode = infocode
  25748. } else {
  25749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25750. utils.ErrorLog("解析失败:%v", err)
  25751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25752. return
  25753. }
  25754. }
  25755. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25756. if reg_type == 11 && his.Insutype == "390" {
  25757. reg_type = 110104
  25758. }
  25759. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25760. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25761. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25762. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25763. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25764. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25765. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25766. resp, requestErr := http.Get(api)
  25767. if requestErr != nil {
  25768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25769. return
  25770. }
  25771. body, ioErr := ioutil.ReadAll(resp.Body)
  25772. if ioErr != nil {
  25773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25775. return
  25776. }
  25777. var respJSON map[string]interface{}
  25778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25781. return
  25782. }
  25783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25784. result, _ := json.Marshal(respJSON)
  25785. if miConfig.Code == "H15049901371" {
  25786. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25787. utils.ErrorLog("解析失败:%v", err)
  25788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25789. return
  25790. }
  25791. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25792. res.Output = resSeven10265.Output
  25793. res.ErrMsg = resSeven10265.ErrMsg
  25794. res.Cainfo = resSeven10265.Cainfo
  25795. res.WarnMsg = resSeven10265.WarnMsg
  25796. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25797. res.Infcode = infocode
  25798. } else {
  25799. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25800. utils.ErrorLog("解析失败:%v", err)
  25801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25802. return
  25803. }
  25804. }
  25805. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25806. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  25807. if result3101.Infcode == "0" {
  25808. if len(result3101.Output.Result) > 0 {
  25809. var errMsgs []string
  25810. for _, item := range result3101.Output.Result {
  25811. errMsgs = append(errMsgs, item.VolaCont)
  25812. }
  25813. c.ServeSuccessJSON(map[string]interface{}{
  25814. "failed_code": -10,
  25815. "msg": errMsgs,
  25816. })
  25817. return
  25818. } else {
  25819. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25820. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25821. bas := strings.Split(psn_info.CardInfo, "|")
  25822. if his.IdCardType == 1 {
  25823. cert_no = bas[2]
  25824. } else if his.IdCardType == 3 {
  25825. cert_no = his.Certno
  25826. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25827. } else if his.IdCardType == 4 {
  25828. cert_no = his.Certno
  25829. psn_info.VerifyNumber = psn_info.VerifyNumber
  25830. }
  25831. var api string
  25832. if miConfig.MdtrtareaAdmvs == "320921" {
  25833. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25834. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25835. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25836. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25837. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25838. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25839. "&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
  25840. } else {
  25841. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25842. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25843. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25844. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25845. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25846. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25847. "&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
  25848. }
  25849. resp, requestErr := http.Get(api)
  25850. if requestErr != nil {
  25851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25852. return
  25853. }
  25854. body, ioErr := ioutil.ReadAll(resp.Body)
  25855. if ioErr != nil {
  25856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25858. return
  25859. }
  25860. var respJSON map[string]interface{}
  25861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25864. return
  25865. }
  25866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25867. result, _ := json.Marshal(respJSON)
  25868. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25869. utils.ErrorLog("解析失败:%v", err)
  25870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25871. return
  25872. }
  25873. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25874. res.Output = resSeven10265.Output
  25875. res.ErrMsg = resSeven10265.ErrMsg
  25876. res.Cainfo = resSeven10265.Cainfo
  25877. res.WarnMsg = resSeven10265.WarnMsg
  25878. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25879. res.Infcode = infocode
  25880. }
  25881. }
  25882. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25883. psn_info, _ := service.GetPsnByPatientId(id)
  25884. var verify_number string
  25885. if psn_info.IdCardType == 4 {
  25886. verify_number = psn_info.VerifyNumber
  25887. } else if psn_info.IdCardType == 1 {
  25888. bas := strings.Split(psn_info.CardInfo, "|")
  25889. cardNumber := bas[2]
  25890. verify_number = cardNumber
  25891. } else {
  25892. psn_info.IdCardType = 2
  25893. verify_number = psn_info.Certno
  25894. }
  25895. var api string
  25896. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25897. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25898. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25899. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25900. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25901. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25902. "&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
  25903. resp, requestErr := http.Get(api)
  25904. if requestErr != nil {
  25905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25906. return
  25907. }
  25908. body, ioErr := ioutil.ReadAll(resp.Body)
  25909. if ioErr != nil {
  25910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25912. return
  25913. }
  25914. var respJSON map[string]interface{}
  25915. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25918. return
  25919. }
  25920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25921. result, _ := json.Marshal(respJSON)
  25922. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25923. utils.ErrorLog("解析失败:%v", err)
  25924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25925. return
  25926. }
  25927. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25928. res.Output = resSeven10265.Output
  25929. res.ErrMsg = resSeven10265.ErrMsg
  25930. res.Cainfo = resSeven10265.Cainfo
  25931. res.WarnMsg = resSeven10265.WarnMsg
  25932. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25933. res.Infcode = infocode
  25934. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25935. var cert_no string
  25936. if his.IdCardType == 4 {
  25937. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25938. cert_no = psn_info.VerifyNumber
  25939. 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)
  25940. } else if his.IdCardType == 1 {
  25941. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25942. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25943. 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)
  25944. }
  25945. //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)
  25946. var dat map[string]interface{}
  25947. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25948. fmt.Println(dat)
  25949. } else {
  25950. fmt.Println(err)
  25951. }
  25952. saveLog(result2, src_resquest, "2207", "结算")
  25953. userJSONBytes, _ := json.Marshal(dat)
  25954. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25955. utils.ErrorLog("解析失败:%v", err)
  25956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25957. return
  25958. }
  25959. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25960. res.Output = resSeven10265.Output
  25961. res.ErrMsg = resSeven10265.ErrMsg
  25962. res.Cainfo = resSeven10265.Cainfo
  25963. res.WarnMsg = resSeven10265.WarnMsg
  25964. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25965. res.Infcode = infocode
  25966. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25967. res2 := c.GetoleInfo()
  25968. if res2.Infcode == 0 {
  25969. var result string
  25970. var request_log string
  25971. var result_log string
  25972. if res2.Output.MdtrtCertType == "02" {
  25973. 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)
  25974. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25975. } else if res2.Output.MdtrtCertType == "01" {
  25976. 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)
  25977. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25978. } else {
  25979. 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)
  25980. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25981. }
  25982. var dat map[string]interface{}
  25983. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25984. fmt.Println(dat)
  25985. } else {
  25986. fmt.Println(err)
  25987. }
  25988. userJSONBytes, _ := json.Marshal(dat)
  25989. var res5 ResultTwo
  25990. //var resTwo10265 ResultTwo10265
  25991. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  25992. utils.ErrorLog("解析失败:%v", err)
  25993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25994. return
  25995. }
  25996. if res5.Infcode == -1 {
  25997. c.ServeSuccessJSON(map[string]interface{}{
  25998. "failed_code": -10,
  25999. "msg": res5.ErrMsg,
  26000. })
  26001. return
  26002. }
  26003. var insutypes []string
  26004. var insutype string
  26005. var is390 int = 0
  26006. var is310 int = 0
  26007. for _, item := range res5.Output.Iinfo {
  26008. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26009. insutypes = append(insutypes, item.Insutype)
  26010. }
  26011. }
  26012. if len(insutypes) == 1 {
  26013. insutype = insutypes[0]
  26014. } else {
  26015. for _, i := range insutypes {
  26016. if i == "390" {
  26017. is390 = 1
  26018. }
  26019. if i == "310" {
  26020. is310 = 1
  26021. }
  26022. }
  26023. }
  26024. if is390 == 1 {
  26025. insutype = "390"
  26026. }
  26027. if is310 == 1 {
  26028. insutype = "310"
  26029. }
  26030. if len(insutypes) == 0 {
  26031. insutype = "310"
  26032. }
  26033. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26034. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26035. infoStr := string(Iinfos)
  26036. idetinfoStr := string(Idetinfos)
  26037. psn := &models.HisPsn{
  26038. PsnNo: res5.Output.Baseinfo.PsnNo,
  26039. PatientId: id,
  26040. Certno: res5.Output.Baseinfo.Certno,
  26041. Gend: res5.Output.Baseinfo.Gend,
  26042. Naty: res5.Output.Baseinfo.Naty,
  26043. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26044. PsnName: res5.Output.Baseinfo.PsnName,
  26045. Idetinfo: idetinfoStr,
  26046. Insuinfo: infoStr,
  26047. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26048. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26049. VerifyNumber: res2.Output.EcToken,
  26050. }
  26051. if res2.Output.MdtrtCertType == "01" {
  26052. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26053. psn.VerifyNumber = res2.Output.EcToken
  26054. } else if res2.Output.MdtrtCertType == "02" {
  26055. psn.VerifyNumber = res2.Output.CardNo
  26056. } else {
  26057. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26058. }
  26059. service.CreateHisPsn(psn)
  26060. if res2.Output.MdtrtCertType == "01" {
  26061. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26062. token := res2.Output.EcToken
  26063. 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)
  26064. } else if res2.Output.MdtrtCertType == "02" {
  26065. 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)
  26066. } else {
  26067. 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)
  26068. }
  26069. var dat2 map[string]interface{}
  26070. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26071. fmt.Println(dat2)
  26072. } else {
  26073. fmt.Println(err)
  26074. }
  26075. userJSONBytes3, _ := json.Marshal(dat2)
  26076. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26077. utils.ErrorLog("解析失败:%v", err)
  26078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26079. return
  26080. }
  26081. saveLog(result2, src_resquest, "2207", "结算")
  26082. } else {
  26083. c.ServeSuccessJSON(map[string]interface{}{
  26084. "failed_code": -10,
  26085. "msg": res2.ErrMsg,
  26086. })
  26087. return
  26088. }
  26089. } else {
  26090. if miConfig.Code == "H15049901371" {
  26091. //赤峰地区国家医保医疗类别
  26092. //职工透析:医疗类别选特殊情况门诊990502
  26093. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26094. var med_type string
  26095. if his.Insutype == "390" {
  26096. if reg_type == 14 {
  26097. med_type = "9933"
  26098. } else if reg_type == 11 {
  26099. med_type = "11"
  26100. }
  26101. } else if his.Insutype == "310" {
  26102. if reg_type == 14 {
  26103. med_type = "990502"
  26104. } else if reg_type == 11 {
  26105. med_type = "11"
  26106. }
  26107. }
  26108. 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)
  26109. } else {
  26110. if his.IdCardType == 4 {
  26111. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26112. var token string
  26113. token = psn_info.VerifyNumber
  26114. 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)
  26115. } else {
  26116. if his.IdCardType == 1 {
  26117. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26118. bas := strings.Split(psn_info.CardInfo, "|")
  26119. basNumber := bas[2]
  26120. cert_no = basNumber
  26121. }
  26122. 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)
  26123. }
  26124. }
  26125. //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)
  26126. var dat map[string]interface{}
  26127. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26128. fmt.Println(dat)
  26129. } else {
  26130. fmt.Println(err)
  26131. }
  26132. saveLog(result2, src_resquest, "2207", "结算")
  26133. userJSONBytes, _ := json.Marshal(dat)
  26134. if miConfig.Code == "H15049901371" {
  26135. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26136. utils.ErrorLog("解析失败:%v", err)
  26137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26138. return
  26139. }
  26140. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26141. res.Output = resSeven10265.Output
  26142. res.ErrMsg = resSeven10265.ErrMsg
  26143. res.Cainfo = resSeven10265.Cainfo
  26144. res.WarnMsg = resSeven10265.WarnMsg
  26145. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26146. res.Infcode = infocode
  26147. } else {
  26148. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26149. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26150. utils.ErrorLog("解析失败:%v", err)
  26151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26152. return
  26153. }
  26154. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26155. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26156. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26157. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26158. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26159. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26160. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26161. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26162. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26163. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26164. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26165. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26166. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26167. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26168. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26169. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26170. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26171. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26172. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26173. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26174. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26175. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26176. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26177. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26178. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26179. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26180. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26181. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26182. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26183. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26184. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26185. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26186. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26187. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26188. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26189. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26190. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26191. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26192. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26193. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26194. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26195. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26196. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26197. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26198. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26199. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26200. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26201. res.Cainfo = gzresSeven10265Two.Cainfo
  26202. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26203. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26204. //res.Infcode = infocode
  26205. } else {
  26206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26207. utils.ErrorLog("解析失败:%v", err)
  26208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26209. return
  26210. }
  26211. }
  26212. }
  26213. }
  26214. if res.Infcode == -1 {
  26215. errlog := &models.HisOrderError{
  26216. UserOrgId: adminUser.CurrentOrgId,
  26217. Ctime: time.Now().Unix(),
  26218. Mtime: time.Now().Unix(),
  26219. Number: chrg_bchno,
  26220. ErrMsg: res.ErrMsg,
  26221. Status: 1,
  26222. PatientId: id,
  26223. RecordTime: recordDateTime,
  26224. Stage: 6,
  26225. }
  26226. service.CreateErrMsgLog(errlog)
  26227. c.ServeSuccessJSON(map[string]interface{}{
  26228. "failed_code": -10,
  26229. "msg": res.ErrMsg,
  26230. })
  26231. return
  26232. } else {
  26233. sickConfig, _ := service.FindSickById(his.SickType)
  26234. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26235. order.OrderStatus = 2
  26236. order.Status = 1
  26237. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26238. order.SetlId = res.Output.Setlinfo.SetlID
  26239. order.PsnNo = res.Output.Setlinfo.PsnNo
  26240. order.PsnName = res.Output.Setlinfo.PsnName
  26241. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26242. order.Certno = res.Output.Setlinfo.Certno
  26243. order.Gend = res.Output.Setlinfo.Gend
  26244. order.Naty = res.Output.Setlinfo.Naty
  26245. order.Age = res.Output.Setlinfo.Age
  26246. order.Insutype = res.Output.Setlinfo.Insutype
  26247. order.PsnType = res.Output.Setlinfo.PsnType
  26248. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26249. order.SetlTime = res.Output.Setlinfo.SetlTime
  26250. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26251. if res.Output.Setlinfo.MedType == "140101" {
  26252. order.MedType = "14"
  26253. } else {
  26254. if res.Output.Setlinfo.MedType == "110104" {
  26255. order.MedType = "11"
  26256. } else {
  26257. order.MedType = res.Output.Setlinfo.MedType
  26258. }
  26259. }
  26260. if reg_type == 1112 {
  26261. order.MedType = "1112"
  26262. }
  26263. if reg_type == 1111 {
  26264. order.MedType = "1111"
  26265. }
  26266. order.ClrType = res.Output.Setlinfo.ClrType
  26267. if adminUser.CurrentOrgId == 10480 {
  26268. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26269. order.ClrType = "11"
  26270. } else {
  26271. order.ClrType = "9903"
  26272. }
  26273. }
  26274. if adminUser.CurrentOrgId == 10721 {
  26275. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26276. order.ClrType = "11"
  26277. } else {
  26278. order.ClrType = "9903"
  26279. }
  26280. }
  26281. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26282. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26283. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26284. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26285. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26286. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26287. order.HifpPay = res.Output.Setlinfo.HifpPay
  26288. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26289. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26290. order.HifesPay = res.Output.Setlinfo.HifesPay
  26291. order.HifobPay = res.Output.Setlinfo.HifobPay
  26292. order.MafPay = res.Output.Setlinfo.MafPay
  26293. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26294. order.OthPay = res.Output.Setlinfo.OthPay
  26295. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26296. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26297. order.AcctPay = res.Output.Setlinfo.AcctPay
  26298. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26299. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26300. order.Balc = res.Output.Setlinfo.Balc
  26301. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26302. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26303. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26304. //order.ClrType = res.Output.Setlinfo.ClrType
  26305. order.ClrWay = res.Output.Setlinfo.ClrWay
  26306. order.Creator = order.Creator
  26307. order.Modify = roles.AdminUserId
  26308. order.RequestLog = src_resquest
  26309. order.FaPiaoNumber = fapiao_number
  26310. order.FaPiaoCode = fapiao_code
  26311. order.SickName = sickConfig.ClassName
  26312. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26313. //detailStr := string(setlDetail)
  26314. //order.SetlDetail = detailStr
  26315. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26316. err = service.UpDateOrder(order)
  26317. if err == nil {
  26318. //判断是否使用了押金
  26319. if dec_way == "true" {
  26320. tmpstring := strconv.FormatInt(order.ID, 10)
  26321. order.Decimal = decimal
  26322. service.UpDateOrder(order)
  26323. //扣押金
  26324. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26325. if errmsg != nil {
  26326. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26327. return
  26328. }
  26329. }
  26330. c.ServeSuccessJSON(map[string]interface{}{
  26331. "msg": "结算成功",
  26332. })
  26333. } else {
  26334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26335. return
  26336. }
  26337. }
  26338. } else {
  26339. adminUser := c.GetAdminUserInfo()
  26340. errlog := &models.HisOrderError{
  26341. UserOrgId: adminUser.CurrentOrgId,
  26342. Ctime: time.Now().Unix(),
  26343. Mtime: time.Now().Unix(),
  26344. ErrMsg: res.ErrMsg,
  26345. Status: 1,
  26346. PatientId: id,
  26347. RecordTime: recordDateTime,
  26348. Stage: 4,
  26349. }
  26350. service.CreateErrMsgLog(errlog)
  26351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26352. return
  26353. }
  26354. } else {
  26355. adminUser := c.GetAdminUserInfo()
  26356. errlog := &models.HisOrderError{
  26357. UserOrgId: adminUser.CurrentOrgId,
  26358. Ctime: time.Now().Unix(),
  26359. Mtime: time.Now().Unix(),
  26360. ErrMsg: res.ErrMsg,
  26361. Status: 1,
  26362. PatientId: id,
  26363. RecordTime: recordDateTime,
  26364. Stage: 4,
  26365. }
  26366. service.CreateErrMsgLog(errlog)
  26367. c.ServeSuccessJSON(map[string]interface{}{
  26368. "failed_code": -10,
  26369. "msg": res.ErrMsg,
  26370. })
  26371. return
  26372. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26373. //return
  26374. }
  26375. }
  26376. }
  26377. } else if tempOrder.ID > 0 {
  26378. if tempOrder.IsPre == 1 {
  26379. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26380. var rf []*ResultFive
  26381. json.Unmarshal([]byte(his.Iinfo), &rf)
  26382. chrg_bchno := tempOrder.Number
  26383. cert_no := his.Certno
  26384. var insutypes []string
  26385. var insutype string
  26386. var is390 int = 0
  26387. var is310 int = 0
  26388. for _, item := range rf {
  26389. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26390. insutypes = append(insutypes, item.Insutype)
  26391. }
  26392. }
  26393. if len(insutypes) == 1 {
  26394. insutype = insutypes[0]
  26395. } else {
  26396. for _, i := range insutypes {
  26397. if i == "390" {
  26398. is390 = 1
  26399. }
  26400. if i == "310" {
  26401. is310 = 1
  26402. }
  26403. }
  26404. }
  26405. if is390 == 1 {
  26406. insutype = "390"
  26407. }
  26408. if is310 == 1 {
  26409. insutype = "310"
  26410. }
  26411. if len(insutypes) == 0 {
  26412. insutype = "310"
  26413. }
  26414. if len(insutypes) == 2 {
  26415. insutype = strconv.FormatInt(his.SocialType, 10)
  26416. }
  26417. //insutype = "390"
  26418. if his.IdCardType == 1 {
  26419. // cert_no = his.MedicalInsuranceNumber
  26420. cert_no = his.Certno
  26421. } else {
  26422. cert_no = his.Certno
  26423. }
  26424. var res ResultSeven
  26425. var ahres ResultSevenAH
  26426. var resSeven10265 ResultSeven10265
  26427. var gzresSeven10265Two GZResultSeven10265Two
  26428. var src_resquest string
  26429. var result2 string
  26430. if miConfig.MdtrtareaAdmvs == "450721" {
  26431. res2 := c.GetoleInfo()
  26432. if res2.Infcode == 0 {
  26433. var result string
  26434. var request_log string
  26435. var result_log string
  26436. if res2.Output.MdtrtCertType == "02" {
  26437. 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)
  26438. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26439. } else if res2.Output.MdtrtCertType == "01" {
  26440. 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)
  26441. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26442. } else {
  26443. 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)
  26444. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26445. }
  26446. var dat map[string]interface{}
  26447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26448. fmt.Println(dat)
  26449. } else {
  26450. fmt.Println(err)
  26451. }
  26452. userJSONBytes, _ := json.Marshal(dat)
  26453. var res5 ResultTwo
  26454. //var resTwo10265 ResultTwo10265
  26455. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26456. utils.ErrorLog("解析失败:%v", err)
  26457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26458. return
  26459. }
  26460. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26461. if res5.Infcode == -1 {
  26462. c.ServeSuccessJSON(map[string]interface{}{
  26463. "failed_code": -10,
  26464. "msg": res5.ErrMsg,
  26465. })
  26466. return
  26467. }
  26468. var insutypes []string
  26469. var insutype string
  26470. var is390 int = 0
  26471. var is310 int = 0
  26472. for _, item := range res5.Output.Iinfo {
  26473. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26474. insutypes = append(insutypes, item.Insutype)
  26475. }
  26476. }
  26477. if len(insutypes) == 1 {
  26478. insutype = insutypes[0]
  26479. } else {
  26480. for _, i := range insutypes {
  26481. if i == "390" {
  26482. is390 = 1
  26483. }
  26484. if i == "310" {
  26485. is310 = 1
  26486. }
  26487. }
  26488. }
  26489. if is390 == 1 {
  26490. insutype = "390"
  26491. }
  26492. if is310 == 1 {
  26493. insutype = "310"
  26494. }
  26495. if len(insutypes) == 0 {
  26496. insutype = "310"
  26497. }
  26498. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26499. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26500. infoStr := string(Iinfos)
  26501. idetinfoStr := string(Idetinfos)
  26502. psn := &models.HisPsn{
  26503. PsnNo: res5.Output.Baseinfo.PsnNo,
  26504. PatientId: id,
  26505. Certno: res5.Output.Baseinfo.Certno,
  26506. Gend: res5.Output.Baseinfo.Gend,
  26507. Naty: res5.Output.Baseinfo.Naty,
  26508. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26509. PsnName: res5.Output.Baseinfo.PsnName,
  26510. Idetinfo: idetinfoStr,
  26511. Insuinfo: infoStr,
  26512. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26513. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26514. VerifyNumber: res2.Output.EcToken,
  26515. }
  26516. service.CreateHisPsn(psn)
  26517. if res2.Output.MdtrtCertType == "01" {
  26518. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26519. token := res2.Output.EcToken
  26520. 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)
  26521. } else if res2.Output.MdtrtCertType == "02" {
  26522. 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)
  26523. } else {
  26524. 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)
  26525. }
  26526. var dat2 map[string]interface{}
  26527. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26528. fmt.Println(dat2)
  26529. } else {
  26530. fmt.Println(err)
  26531. }
  26532. userJSONBytes3, _ := json.Marshal(dat2)
  26533. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26534. utils.ErrorLog("解析失败:%v", err)
  26535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26536. return
  26537. }
  26538. saveLog(result2, src_resquest, "2207", "结算")
  26539. } else {
  26540. c.ServeSuccessJSON(map[string]interface{}{
  26541. "failed_code": -10,
  26542. "msg": res2.ErrMsg,
  26543. })
  26544. return
  26545. }
  26546. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26547. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26548. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26549. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26550. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26551. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26552. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26553. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26554. resp, requestErr := http.Get(api)
  26555. if requestErr != nil {
  26556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26557. return
  26558. }
  26559. body, ioErr := ioutil.ReadAll(resp.Body)
  26560. if ioErr != nil {
  26561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26563. return
  26564. }
  26565. var respJSON map[string]interface{}
  26566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26569. return
  26570. }
  26571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26572. result, _ := json.Marshal(respJSON)
  26573. fmt.Println("log")
  26574. fmt.Println(string(result))
  26575. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26576. utils.ErrorLog("解析失败:%v", err)
  26577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26578. return
  26579. }
  26580. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26581. if reg_type == 11 && his.Insutype == "390" {
  26582. reg_type = 110104
  26583. }
  26584. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26585. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26586. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26588. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26589. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26590. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26591. resp, requestErr := http.Get(api)
  26592. if requestErr != nil {
  26593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26594. return
  26595. }
  26596. body, ioErr := ioutil.ReadAll(resp.Body)
  26597. if ioErr != nil {
  26598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26600. return
  26601. }
  26602. var respJSON map[string]interface{}
  26603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26606. return
  26607. }
  26608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26609. result, _ := json.Marshal(respJSON)
  26610. fmt.Println("log")
  26611. fmt.Println(string(result))
  26612. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26613. utils.ErrorLog("解析失败:%v", err)
  26614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26615. return
  26616. }
  26617. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26618. if reg_type == 11 && his.Insutype == "390" {
  26619. reg_type = 110104
  26620. }
  26621. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26622. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26623. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26624. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26625. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26626. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26627. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26628. resp, requestErr := http.Get(api)
  26629. if requestErr != nil {
  26630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26631. return
  26632. }
  26633. body, ioErr := ioutil.ReadAll(resp.Body)
  26634. if ioErr != nil {
  26635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26637. return
  26638. }
  26639. var respJSON map[string]interface{}
  26640. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26643. return
  26644. }
  26645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26646. result, _ := json.Marshal(respJSON)
  26647. fmt.Println("log")
  26648. fmt.Println(string(result))
  26649. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26650. utils.ErrorLog("解析失败:%v", err)
  26651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26652. return
  26653. }
  26654. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26655. if reg_type == 11 && his.Insutype == "390" {
  26656. reg_type = 110104
  26657. }
  26658. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26659. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26660. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26661. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26662. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26663. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26664. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26665. resp, requestErr := http.Get(api)
  26666. if requestErr != nil {
  26667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26668. return
  26669. }
  26670. body, ioErr := ioutil.ReadAll(resp.Body)
  26671. if ioErr != nil {
  26672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26674. return
  26675. }
  26676. var respJSON map[string]interface{}
  26677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26680. return
  26681. }
  26682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26683. result, _ := json.Marshal(respJSON)
  26684. fmt.Println("log")
  26685. fmt.Println(string(result))
  26686. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26687. utils.ErrorLog("解析失败:%v", err)
  26688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26689. return
  26690. }
  26691. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26692. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26693. if result3101.Infcode == "0" {
  26694. if len(result3101.Output.Result) > 0 {
  26695. var errMsgs []string
  26696. for _, item := range result3101.Output.Result {
  26697. errMsgs = append(errMsgs, item.VolaCont)
  26698. }
  26699. c.ServeSuccessJSON(map[string]interface{}{
  26700. "failed_code": -10,
  26701. "msg": errMsgs,
  26702. })
  26703. return
  26704. } else {
  26705. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26706. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26707. bas := strings.Split(psn_info.CardInfo, "|")
  26708. if his.IdCardType == 1 {
  26709. cert_no = bas[2]
  26710. } else if his.IdCardType == 3 {
  26711. cert_no = his.Certno
  26712. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26713. } else if his.IdCardType == 4 {
  26714. cert_no = his.Certno
  26715. psn_info.VerifyNumber = psn_info.VerifyNumber
  26716. }
  26717. //江苏地区国家医保医疗类别
  26718. //职工透析:医疗类别选特殊情况门诊9933
  26719. //居民血透门慢: 医疗类别选门诊慢病1402
  26720. //var med_type string
  26721. //if his.Insutype == "310" {
  26722. // if reg_type == 14 {
  26723. // med_type = "9933"
  26724. // } else if reg_type == 11 {
  26725. // med_type = "11"
  26726. //
  26727. // }
  26728. //} else if his.Insutype == "390" {
  26729. // if reg_type == 14 {
  26730. // med_type = "1402"
  26731. // } else if reg_type == 11 {
  26732. // med_type = "11"
  26733. // }
  26734. //}
  26735. var api string
  26736. if miConfig.MdtrtareaAdmvs == "320921" {
  26737. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26738. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26739. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26740. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26741. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26742. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26743. "&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
  26744. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26745. } else {
  26746. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26747. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26748. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26749. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26750. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26751. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26752. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26753. "&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
  26754. }
  26755. resp, requestErr := http.Get(api)
  26756. if requestErr != nil {
  26757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26758. return
  26759. }
  26760. body, ioErr := ioutil.ReadAll(resp.Body)
  26761. if ioErr != nil {
  26762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26764. return
  26765. }
  26766. var respJSON map[string]interface{}
  26767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26770. return
  26771. }
  26772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26773. result, _ := json.Marshal(respJSON)
  26774. fmt.Println("log")
  26775. fmt.Println(string(result))
  26776. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26777. utils.ErrorLog("解析失败:%v", err)
  26778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26779. return
  26780. }
  26781. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26782. res.Output = resSeven10265.Output
  26783. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26784. res.ErrMsg = resSeven10265.ErrMsg
  26785. res.Cainfo = resSeven10265.Cainfo
  26786. res.WarnMsg = resSeven10265.WarnMsg
  26787. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26788. res.Infcode = infocode
  26789. }
  26790. }
  26791. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26792. psn_info, _ := service.GetPsnByPatientId(id)
  26793. var verify_number string
  26794. if psn_info.IdCardType == 4 {
  26795. verify_number = psn_info.VerifyNumber
  26796. } else if psn_info.IdCardType == 1 {
  26797. bas := strings.Split(psn_info.CardInfo, "|")
  26798. cardNumber := bas[2]
  26799. verify_number = cardNumber
  26800. } else {
  26801. verify_number = psn_info.Certno
  26802. psn_info.IdCardType = 2
  26803. }
  26804. var api string
  26805. new_chrg_bchno := chrg_bchno
  26806. if adminUser.CurrentOrgId == 10265 {
  26807. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26808. new_chrg_bchno = "0000"
  26809. }
  26810. }
  26811. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26812. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  26813. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26814. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26815. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  26816. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26817. "&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
  26818. resp, requestErr := http.Get(api)
  26819. if requestErr != nil {
  26820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26821. return
  26822. }
  26823. body, ioErr := ioutil.ReadAll(resp.Body)
  26824. if ioErr != nil {
  26825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26827. return
  26828. }
  26829. var respJSON map[string]interface{}
  26830. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26833. return
  26834. }
  26835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26836. result, _ := json.Marshal(respJSON)
  26837. fmt.Println("log")
  26838. fmt.Println(string(result))
  26839. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26840. utils.ErrorLog("解析失败:%v", err)
  26841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26842. return
  26843. }
  26844. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26845. res.Output = resSeven10265.Output
  26846. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26847. res.ErrMsg = resSeven10265.ErrMsg
  26848. res.Cainfo = resSeven10265.Cainfo
  26849. res.WarnMsg = resSeven10265.WarnMsg
  26850. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26851. res.Infcode = infocode
  26852. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26853. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26854. var cert_no string
  26855. if his.IdCardType == 1 {
  26856. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26857. } else {
  26858. cert_no = psn_info.VerifyNumber
  26859. }
  26860. 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)
  26861. var dat map[string]interface{}
  26862. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26863. fmt.Println(dat)
  26864. } else {
  26865. fmt.Println(err)
  26866. }
  26867. saveLog(result2, src_resquest, "2207", "结算")
  26868. userJSONBytes, _ := json.Marshal(dat)
  26869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26870. utils.ErrorLog("解析失败:%v", err)
  26871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26872. return
  26873. }
  26874. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26875. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26876. var cert_no string
  26877. var card_sn string
  26878. if his.IdCardType == 1 {
  26879. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26880. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26881. bas := strings.Split(psn_info.CardInfo, "|")
  26882. card_sn = bas[3]
  26883. } else if his.IdCardType == 2 {
  26884. cert_no = his.IdCardNo
  26885. } else {
  26886. cert_no = psn_info.VerifyNumber
  26887. }
  26888. var rf []*ResultFive
  26889. json.Unmarshal([]byte(his.Iinfo), &rf)
  26890. var psn_type string
  26891. for _, item := range rf {
  26892. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26893. psn_type = item.PsnType
  26894. }
  26895. }
  26896. 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)
  26897. var dat map[string]interface{}
  26898. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26899. fmt.Println(dat)
  26900. } else {
  26901. fmt.Println(err)
  26902. }
  26903. saveLog(result2, src_resquest, "2207", "结算")
  26904. userJSONBytes, _ := json.Marshal(dat)
  26905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26906. utils.ErrorLog("解析失败:%v", err)
  26907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26908. return
  26909. }
  26910. } else if miConfig.MdtrtareaAdmvs == "361025" {
  26911. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26912. var cert_no string
  26913. var card_sn string
  26914. if his.IdCardType == 1 {
  26915. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26916. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26917. //bas := strings.Split(psn_info.CardInfo, "|")
  26918. card_sn = ""
  26919. } else if his.IdCardType == 2 {
  26920. cert_no = his.IdCardNo
  26921. } else {
  26922. cert_no = psn_info.VerifyNumber
  26923. }
  26924. var rf []*ResultFive
  26925. json.Unmarshal([]byte(his.Iinfo), &rf)
  26926. var psn_type string
  26927. for _, item := range rf {
  26928. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26929. psn_type = item.PsnType
  26930. }
  26931. }
  26932. 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)
  26933. var dat map[string]interface{}
  26934. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26935. fmt.Println(dat)
  26936. } else {
  26937. fmt.Println(err)
  26938. }
  26939. saveLog(result2, src_resquest, "2207", "结算")
  26940. userJSONBytes, _ := json.Marshal(dat)
  26941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26942. utils.ErrorLog("解析失败:%v", err)
  26943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26944. return
  26945. }
  26946. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26947. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26948. if his.IdCardType == 1 {
  26949. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26950. bas := strings.Split(psn_info.CardInfo, "|")
  26951. cert_no = bas[2]
  26952. } else if his.IdCardType == 3 {
  26953. cert_no = his.Certno
  26954. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26955. } else if his.IdCardType == 4 {
  26956. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26957. cert_no = psn_info.VerifyNumber
  26958. psn_info.VerifyNumber = psn_info.VerifyNumber
  26959. } else {
  26960. cert_no = his.Certno
  26961. psn_info.VerifyNumber = his.Certno
  26962. }
  26963. var api string
  26964. var med_type string
  26965. if his.Insutype == "390" {
  26966. if reg_type == 992102 {
  26967. med_type = "992102"
  26968. }
  26969. if reg_type == 140104 {
  26970. med_type = "140104"
  26971. }
  26972. if reg_type == 140201 {
  26973. med_type = "140201"
  26974. }
  26975. if reg_type == 14 {
  26976. med_type = "14"
  26977. }
  26978. } else if his.Insutype == "310" {
  26979. if reg_type == 992102 {
  26980. med_type = "992102"
  26981. }
  26982. if reg_type == 140104 {
  26983. med_type = "140104"
  26984. }
  26985. if reg_type == 140201 {
  26986. med_type = "140201"
  26987. }
  26988. if reg_type == 14 {
  26989. med_type = "14"
  26990. }
  26991. }
  26992. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26993. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26994. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26995. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26996. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26997. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26998. "&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
  26999. resp, requestErr := http.Get(api)
  27000. if requestErr != nil {
  27001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27002. return
  27003. }
  27004. body, ioErr := ioutil.ReadAll(resp.Body)
  27005. if ioErr != nil {
  27006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27008. return
  27009. }
  27010. var respJSON map[string]interface{}
  27011. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27014. return
  27015. }
  27016. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27017. if status == "0" {
  27018. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27019. c.ServeSuccessJSON(map[string]interface{}{
  27020. "failed_code": -10,
  27021. "msg": err_msg,
  27022. })
  27023. return
  27024. }
  27025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27026. result, _ := json.Marshal(respJSON)
  27027. fmt.Println("log")
  27028. fmt.Println(string(result))
  27029. if err := json.Unmarshal(result, &ahres); err != nil {
  27030. utils.ErrorLog("解析失败:%v", err)
  27031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27032. return
  27033. }
  27034. res.InfRefmsgid = ahres.InfRefmsgid
  27035. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27036. // 创建对应的Time类型
  27037. t := time.UnixMilli(timestamp)
  27038. // 格式化成指定的日期字符串
  27039. str := t.Format("2006-01-02 15:04:05")
  27040. res.Output.Setlinfo.SetlTime = str
  27041. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27042. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27043. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27044. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27045. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27046. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27047. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27048. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27049. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27050. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27051. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27052. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27053. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27054. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27055. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27056. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27057. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27058. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27059. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27060. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27061. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27062. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27063. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27064. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27065. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27066. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27067. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27068. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27069. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27070. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27071. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27072. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27073. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27074. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27075. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27076. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27077. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27078. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27079. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27080. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27081. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27082. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27083. res.Output.Setldetail = ahres.Output.Setldetail
  27084. res.ErrMsg = ahres.ErrMsg
  27085. res.Cainfo = ahres.Cainfo
  27086. res.WarnMsg = ahres.WarnMsg
  27087. res.Infcode = ahres.Infcode
  27088. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27089. res.Output.Setlinfo.ClrType = "11"
  27090. } else {
  27091. res.Output.Setlinfo.ClrType = "9903"
  27092. }
  27093. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27094. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27095. if his.IdCardType == 1 {
  27096. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27097. bas := strings.Split(psn_info.CardInfo, "|")
  27098. cert_no = bas[2]
  27099. } else if his.IdCardType == 3 {
  27100. cert_no = his.Certno
  27101. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27102. } else if his.IdCardType == 4 {
  27103. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27104. cert_no = his.Certno
  27105. psn_info.VerifyNumber = psn_info.VerifyNumber
  27106. } else {
  27107. cert_no = his.Certno
  27108. psn_info.VerifyNumber = his.Certno
  27109. }
  27110. var api string
  27111. var med_type string
  27112. if his.Insutype == "390" {
  27113. if reg_type == 992102 {
  27114. med_type = "992102"
  27115. }
  27116. if reg_type == 140104 {
  27117. med_type = "140104"
  27118. }
  27119. if reg_type == 14 {
  27120. med_type = "14"
  27121. }
  27122. if reg_type == 140201 {
  27123. med_type = "140201"
  27124. }
  27125. } else if his.Insutype == "310" {
  27126. if reg_type == 992102 {
  27127. med_type = "992102"
  27128. }
  27129. if reg_type == 14 {
  27130. med_type = "14"
  27131. }
  27132. if reg_type == 140104 {
  27133. med_type = "140104"
  27134. }
  27135. if reg_type == 140201 {
  27136. med_type = "140201"
  27137. }
  27138. }
  27139. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27140. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27141. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27142. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27143. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27144. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27145. "&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
  27146. resp, requestErr := http.Get(api)
  27147. if requestErr != nil {
  27148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27149. return
  27150. }
  27151. body, ioErr := ioutil.ReadAll(resp.Body)
  27152. if ioErr != nil {
  27153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27155. return
  27156. }
  27157. var respJSON map[string]interface{}
  27158. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27161. return
  27162. }
  27163. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27164. if status == "0" {
  27165. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27166. c.ServeSuccessJSON(map[string]interface{}{
  27167. "failed_code": -10,
  27168. "msg": err_msg,
  27169. })
  27170. return
  27171. }
  27172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27173. result, _ := json.Marshal(respJSON)
  27174. fmt.Println("log")
  27175. fmt.Println(string(result))
  27176. if err := json.Unmarshal(result, &ahres); err != nil {
  27177. utils.ErrorLog("解析失败:%v", err)
  27178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27179. return
  27180. }
  27181. res.InfRefmsgid = ahres.InfRefmsgid
  27182. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27183. // 创建对应的Time类型
  27184. t := time.UnixMilli(timestamp)
  27185. // 格式化成指定的日期字符串
  27186. str := t.Format("2006-01-02 15:04:05")
  27187. res.Output.Setlinfo.SetlTime = str
  27188. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27189. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27190. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27191. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27192. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27193. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27194. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27195. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27196. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27197. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27198. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27199. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27200. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27201. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27202. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27203. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27204. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27205. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27206. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27207. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27208. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27209. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27210. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27211. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27212. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27213. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27214. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27215. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27216. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27217. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27218. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27219. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27220. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27221. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27222. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27223. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27224. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27225. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27226. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27227. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27228. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27229. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27230. res.Output.Setldetail = ahres.Output.Setldetail
  27231. res.ErrMsg = ahres.ErrMsg
  27232. res.Cainfo = ahres.Cainfo
  27233. res.WarnMsg = ahres.WarnMsg
  27234. res.Infcode = ahres.Infcode
  27235. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27236. res.Output.Setlinfo.ClrType = "11"
  27237. } else {
  27238. res.Output.Setlinfo.ClrType = "9903"
  27239. }
  27240. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27241. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27242. var cert_no string
  27243. if his.IdCardType == 1 {
  27244. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27245. } else if his.IdCardType == 2 {
  27246. cert_no = his.IdCardNo
  27247. } else {
  27248. cert_no = psn_info.VerifyNumber
  27249. }
  27250. 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, "")
  27251. var dat map[string]interface{}
  27252. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27253. fmt.Println(dat)
  27254. } else {
  27255. fmt.Println(err)
  27256. }
  27257. saveLog(result2, src_resquest, "2207", "结算")
  27258. userJSONBytes, _ := json.Marshal(dat)
  27259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27260. utils.ErrorLog("解析失败:%v", err)
  27261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27262. return
  27263. }
  27264. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27265. psn_info, _ := service.GetPsnByPatientId(id)
  27266. var verify_number string
  27267. if psn_info.IdCardType == 4 {
  27268. verify_number = psn_info.VerifyNumber
  27269. } else if psn_info.IdCardType == 1 {
  27270. bas := strings.Split(psn_info.CardInfo, "|")
  27271. cardNumber := bas[2]
  27272. verify_number = cardNumber
  27273. } else {
  27274. verify_number = psn_info.Certno
  27275. psn_info.IdCardType = 2
  27276. }
  27277. var api string
  27278. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27279. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27280. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27282. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27283. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27284. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27285. resp, requestErr := http.Get(api)
  27286. if requestErr != nil {
  27287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27288. return
  27289. }
  27290. body, ioErr := ioutil.ReadAll(resp.Body)
  27291. if ioErr != nil {
  27292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27294. return
  27295. }
  27296. var respJSON map[string]interface{}
  27297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27300. return
  27301. }
  27302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27303. result, _ := json.Marshal(respJSON)
  27304. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27305. utils.ErrorLog("解析失败:%v", err)
  27306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27307. return
  27308. }
  27309. } else {
  27310. var src_resquest string
  27311. if miConfig.Code == "H15049901371" {
  27312. //赤峰地区国家医保医疗类别
  27313. //职工透析:医疗类别选特殊情况门诊990502
  27314. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27315. var med_type string
  27316. if his.Insutype == "390" {
  27317. if reg_type == 14 {
  27318. med_type = "9933"
  27319. } else if reg_type == 11 {
  27320. med_type = "11"
  27321. }
  27322. } else if his.Insutype == "310" {
  27323. if reg_type == 14 {
  27324. med_type = "990502"
  27325. } else if reg_type == 11 {
  27326. med_type = "11"
  27327. }
  27328. }
  27329. 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)
  27330. } else {
  27331. if his.IdCardType == 4 {
  27332. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27333. token := psn_info.VerifyNumber
  27334. 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)
  27335. } else {
  27336. 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)
  27337. }
  27338. }
  27339. var dat map[string]interface{}
  27340. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27341. fmt.Println(dat)
  27342. } else {
  27343. fmt.Println(err)
  27344. }
  27345. saveLog(result2, src_resquest, "2207", "结算")
  27346. userJSONBytes, _ := json.Marshal(dat)
  27347. if miConfig.Code == "H15049901371" {
  27348. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27349. utils.ErrorLog("解析失败:%v", err)
  27350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27351. return
  27352. }
  27353. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27354. res.Output = resSeven10265.Output
  27355. res.ErrMsg = resSeven10265.ErrMsg
  27356. res.Cainfo = resSeven10265.Cainfo
  27357. res.WarnMsg = resSeven10265.WarnMsg
  27358. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27359. res.Infcode = infocode
  27360. } else {
  27361. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27362. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27363. utils.ErrorLog("解析失败:%v", err)
  27364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27365. return
  27366. }
  27367. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27368. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27369. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27370. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27371. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27372. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27373. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27374. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27375. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27376. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27377. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27378. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27379. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27380. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27381. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27382. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27383. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27384. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27385. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27386. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27387. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27388. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27389. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27390. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27391. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27392. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27393. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27394. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27395. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27396. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27397. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27398. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27399. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27400. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27401. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27402. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27403. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27404. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27405. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27406. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27407. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27408. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27409. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27410. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27411. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27412. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27413. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27414. res.Cainfo = gzresSeven10265Two.Cainfo
  27415. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27416. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27417. //res.Infcode = infocode
  27418. } else {
  27419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27420. utils.ErrorLog("解析失败:%v", err)
  27421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27422. return
  27423. }
  27424. }
  27425. }
  27426. }
  27427. if res.Infcode == -1 {
  27428. errlog := &models.HisOrderError{
  27429. UserOrgId: adminUser.CurrentOrgId,
  27430. Ctime: time.Now().Unix(),
  27431. Mtime: time.Now().Unix(),
  27432. Number: chrg_bchno,
  27433. ErrMsg: res.ErrMsg,
  27434. Status: 1,
  27435. PatientId: id,
  27436. RecordTime: recordDateTime,
  27437. Stage: 6,
  27438. }
  27439. service.CreateErrMsgLog(errlog)
  27440. c.ServeSuccessJSON(map[string]interface{}{
  27441. "failed_code": -10,
  27442. "msg": res.ErrMsg,
  27443. })
  27444. return
  27445. } else {
  27446. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27447. order.OrderStatus = 2
  27448. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27449. order.SetlId = res.Output.Setlinfo.SetlID
  27450. order.PsnNo = res.Output.Setlinfo.PsnNo
  27451. order.PsnName = res.Output.Setlinfo.PsnName
  27452. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27453. order.Certno = res.Output.Setlinfo.Certno
  27454. order.Gend = res.Output.Setlinfo.Gend
  27455. order.Naty = res.Output.Setlinfo.Naty
  27456. order.Age = res.Output.Setlinfo.Age
  27457. order.Insutype = res.Output.Setlinfo.Insutype
  27458. order.PsnType = res.Output.Setlinfo.PsnType
  27459. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27460. order.SetlTime = res.Output.Setlinfo.SetlTime
  27461. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27462. order.PayWays = pay_ways
  27463. order.AcctUsedFlag = acct_used_flag
  27464. order.WechatPay = wechat_pay
  27465. order.AliPay = ali_pay
  27466. order.JifenPay = jifen_pay
  27467. order.BandCardPay = band_card_pay
  27468. order.CashPay = cash_pay
  27469. order.OthDesc = oth_desc
  27470. //order.MedType = res.Output.Setlinfo.MedType
  27471. if reg_type == 1112 {
  27472. order.MedType = "1112"
  27473. }
  27474. if reg_type == 1111 {
  27475. order.MedType = "1111"
  27476. }
  27477. order.ClrType = res.Output.Setlinfo.ClrType
  27478. if adminUser.CurrentOrgId == 10480 {
  27479. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27480. order.ClrType = "11"
  27481. } else {
  27482. order.ClrType = "9903"
  27483. }
  27484. }
  27485. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27486. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27487. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27488. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27489. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27490. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27491. order.HifpPay = res.Output.Setlinfo.HifpPay
  27492. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27493. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27494. order.HifesPay = res.Output.Setlinfo.HifesPay
  27495. order.HifobPay = res.Output.Setlinfo.HifobPay
  27496. order.MafPay = res.Output.Setlinfo.MafPay
  27497. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27498. order.OthPay = res.Output.Setlinfo.OthPay
  27499. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27500. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27501. order.AcctPay = res.Output.Setlinfo.AcctPay
  27502. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27503. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27504. order.Balc = res.Output.Setlinfo.Balc
  27505. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27506. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27507. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27508. order.ClrWay = res.Output.Setlinfo.ClrWay
  27509. order.Creator = order.Creator
  27510. order.Modify = roles.AdminUserId
  27511. order.RequestLog = src_resquest
  27512. order.Diagnosis = diagnosis_id
  27513. order.FaPiaoNumber = fapiao_number
  27514. order.FaPiaoCode = fapiao_code
  27515. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27516. detailStr := string(setlDetail)
  27517. order.SetlDetail = detailStr
  27518. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27519. err = service.UpDateOrder(order)
  27520. if err == nil {
  27521. //判断是否使用了押金
  27522. if dec_way == "true" {
  27523. tmpstring := strconv.FormatInt(order.ID, 10)
  27524. //扣押金
  27525. order.Decimal = decimal
  27526. service.UpDateOrder(order)
  27527. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27528. if errmsg != nil {
  27529. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27530. return
  27531. }
  27532. }
  27533. c.ServeSuccessJSON(map[string]interface{}{
  27534. "msg": "结算成功",
  27535. })
  27536. } else {
  27537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27538. return
  27539. }
  27540. }
  27541. }
  27542. }
  27543. }
  27544. // 上传明细-预结算-
  27545. func (c *HisApiController) GetPreUploadInfo() {
  27546. id, _ := c.GetInt64("id")
  27547. record_time := c.GetString("record_time")
  27548. his_patient_id, _ := c.GetInt64("his_patient_id")
  27549. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27550. admin_user_id, _ := c.GetInt64("admin_user_id")
  27551. diagnosis_id := c.GetString("diagnosis")
  27552. sick_type, _ := c.GetInt64("sick_type")
  27553. reg_type, _ := c.GetInt64("p_type")
  27554. begin_time := c.GetString("begin_time")
  27555. acct_used_flag := c.GetString("acct_used_flag")
  27556. id_str := c.GetString("ids")
  27557. ids_arr := strings.Split(id_str, ",")
  27558. timeLayout := "2006-01-02"
  27559. loc, _ := time.LoadLocation("Local")
  27560. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27561. if err != nil {
  27562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27563. return
  27564. }
  27565. recordDateTime := theTime.Unix()
  27566. adminUser := c.GetAdminUserInfo()
  27567. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27568. var config []*models.HisXtDiagnoseConfig
  27569. for _, item := range diagnosis_ids {
  27570. id, _ := strconv.ParseInt(item, 10, 64)
  27571. if id > 0 {
  27572. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27573. config = append(config, &diagnosisConfig)
  27574. }
  27575. }
  27576. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27577. sickConfig, _ := service.FindSickById(sick_type)
  27578. var prescriptions []*models.HisPrescription
  27579. var start_time int64
  27580. var end_time int64
  27581. var isSuccess bool = true
  27582. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27583. fmt.Println(his_patient_id)
  27584. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27585. timestamp := time.Now().Unix()
  27586. tempTime := time.Unix(timestamp, 0)
  27587. timeFormat := tempTime.Format("20060102150405")
  27588. chrgBchno := rand.Intn(100000) + 10000
  27589. new_chrg_bchno := ""
  27590. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27591. new_chrg_bchno = chrg_bchno
  27592. if adminUser.CurrentOrgId == 10265 {
  27593. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27594. new_chrg_bchno = "0000"
  27595. }
  27596. }
  27597. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27598. var patientPrescription models.HisPrescriptionInfo
  27599. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27600. if patientPrescription.ID == 0 {
  27601. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27602. }
  27603. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27604. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27605. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27606. strconv.FormatInt(his.PatientId, 10)
  27607. var res2406 Result2406
  27608. //安徽单病种处理
  27609. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27610. data := make(map[string]interface{})
  27611. client := &http.Client{}
  27612. data["psn_no"] = his.PsnNo
  27613. data["mdtrt_id"] = his.Number
  27614. data["operator"] = roles.UserName
  27615. data["cert_no"] = his.IdCardNo
  27616. data["org_name"] = miConfig.OrgName
  27617. data["psn_name"] = his.Name
  27618. data["ipt_otp_no"] = his.IptOtpNo
  27619. data["ipt_psn_sp_flag_type"] = "0901"
  27620. data["ipt_psn_sp_flag"] = "1"
  27621. data["fixmedins_code"] = miConfig.Code
  27622. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27623. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27624. data["url"] = miConfig.Url
  27625. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27626. bytesData, _ := json.Marshal(data)
  27627. var req *http.Request
  27628. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27629. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27630. resp, _ := client.Do(req)
  27631. defer resp.Body.Close()
  27632. body, ioErr := ioutil.ReadAll(resp.Body)
  27633. if ioErr != nil {
  27634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27636. return
  27637. }
  27638. var respJSON map[string]interface{}
  27639. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27642. return
  27643. }
  27644. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27645. if status == "0" {
  27646. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27647. c.ServeSuccessJSON(map[string]interface{}{
  27648. "failed_code": -10,
  27649. "msg": err_msg,
  27650. })
  27651. return
  27652. }
  27653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27654. userJSONBytes, _ := json.Marshal(respJSON)
  27655. fmt.Println("log")
  27656. fmt.Println(string(userJSONBytes))
  27657. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27658. utils.ErrorLog("解析失败:%v", err)
  27659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27660. return
  27661. }
  27662. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27663. data := make(map[string]interface{})
  27664. client := &http.Client{}
  27665. data["psn_no"] = his.PsnNo
  27666. data["mdtrt_id"] = his.Number
  27667. data["operator"] = roles.UserName
  27668. data["cert_no"] = his.IdCardNo
  27669. data["org_name"] = miConfig.OrgName
  27670. data["psn_name"] = his.Name
  27671. data["ipt_otp_no"] = his.IptOtpNo
  27672. data["ipt_psn_sp_flag_type"] = "0901"
  27673. data["ipt_psn_sp_flag"] = "1"
  27674. data["fixmedins_code"] = miConfig.Code
  27675. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27676. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27677. data["url"] = miConfig.Url
  27678. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27679. bytesData, _ := json.Marshal(data)
  27680. var req *http.Request
  27681. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27682. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27683. resp, _ := client.Do(req)
  27684. defer resp.Body.Close()
  27685. body, ioErr := ioutil.ReadAll(resp.Body)
  27686. if ioErr != nil {
  27687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27689. return
  27690. }
  27691. var respJSON map[string]interface{}
  27692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27695. return
  27696. }
  27697. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27698. if status == "0" {
  27699. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27700. c.ServeSuccessJSON(map[string]interface{}{
  27701. "failed_code": -10,
  27702. "msg": err_msg,
  27703. })
  27704. return
  27705. }
  27706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27707. userJSONBytes, _ := json.Marshal(respJSON)
  27708. fmt.Println("log")
  27709. fmt.Println(string(userJSONBytes))
  27710. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27711. utils.ErrorLog("解析失败:%v", err)
  27712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27713. return
  27714. }
  27715. }
  27716. if res2406.Infcode != 0 {
  27717. adminUser := c.GetAdminUserInfo()
  27718. errlog := &models.HisOrderError{
  27719. UserOrgId: adminUser.CurrentOrgId,
  27720. Ctime: time.Now().Unix(),
  27721. Mtime: time.Now().Unix(),
  27722. ErrMsg: res2406.ErrMsg,
  27723. Status: 1,
  27724. PatientId: id,
  27725. RecordTime: recordDateTime,
  27726. Stage: 3,
  27727. }
  27728. service.CreateErrMsgLog(errlog)
  27729. c.ServeSuccessJSON(map[string]interface{}{
  27730. "failed_code": -10,
  27731. "msg": res2406.ErrMsg,
  27732. })
  27733. return
  27734. }
  27735. var res2 ResultSix
  27736. var res3 GZResultSix
  27737. var resSix10265 ResultSix10265
  27738. //var time_stamp string
  27739. if miConfig.MdtrtareaAdmvs == "421300" {
  27740. data := make(map[string]interface{})
  27741. client := &http.Client{}
  27742. data["psn_no"] = his.PsnNo
  27743. data["mdtrt_id"] = his.Number
  27744. data["department"] = department.Name
  27745. data["org_name"] = miConfig.OrgName
  27746. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27747. data["doctor_id"] = doctor_info.DoctorNumber
  27748. data["doctor_name"] = roles.UserName
  27749. data["fixmedins_code"] = miConfig.Code
  27750. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27751. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27752. data["secret_key"] = miConfig.SecretKey
  27753. data["sick_code"] = sickConfig.CountryCode
  27754. data["sick_name"] = sickConfig.ClassName
  27755. data["begin_time"] = begin_time
  27756. data["dept"] = strconv.FormatInt(department.ID, 10)
  27757. data["config"] = config
  27758. data["opter"] = roles.UserName
  27759. fmt.Println(data)
  27760. bytesData, _ := json.Marshal(data)
  27761. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27762. resp, _ := client.Do(req)
  27763. defer resp.Body.Close()
  27764. body, ioErr := ioutil.ReadAll(resp.Body)
  27765. if ioErr != nil {
  27766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27768. return
  27769. }
  27770. var respJSON map[string]interface{}
  27771. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27774. return
  27775. }
  27776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27777. userJSONBytes, _ := json.Marshal(respJSON)
  27778. fmt.Println("log")
  27779. fmt.Println(string(userJSONBytes))
  27780. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27781. utils.ErrorLog("解析失败:%v", err)
  27782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27783. return
  27784. }
  27785. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27786. data := make(map[string]interface{})
  27787. client := &http.Client{}
  27788. data["psn_no"] = his.PsnNo
  27789. data["mdtrt_id"] = his.Number
  27790. data["department"] = department.Name
  27791. data["org_name"] = miConfig.OrgName
  27792. if reg_type == 11 && his.Insutype == "390" {
  27793. data["med_type"] = "110104"
  27794. } else {
  27795. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27796. }
  27797. data["doctor_id"] = doctor_info.DoctorNumber
  27798. data["doctor_name"] = roles.UserName
  27799. data["fixmedins_code"] = miConfig.Code
  27800. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27801. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27802. data["secret_key"] = miConfig.SecretKey
  27803. data["sick_code"] = sickConfig.CountryCode
  27804. data["sick_name"] = sickConfig.ClassName
  27805. data["begin_time"] = begin_time
  27806. data["dept"] = strconv.FormatInt(department.ID, 10)
  27807. data["config"] = config
  27808. data["opter"] = roles.UserName
  27809. fmt.Println(data)
  27810. bytesData, _ := json.Marshal(data)
  27811. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27812. resp, _ := client.Do(req)
  27813. defer resp.Body.Close()
  27814. body, ioErr := ioutil.ReadAll(resp.Body)
  27815. if ioErr != nil {
  27816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27818. return
  27819. }
  27820. var respJSON map[string]interface{}
  27821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27824. return
  27825. }
  27826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27827. userJSONBytes, _ := json.Marshal(respJSON)
  27828. fmt.Println("log")
  27829. fmt.Println(string(userJSONBytes))
  27830. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27831. utils.ErrorLog("解析失败:%v", err)
  27832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27833. return
  27834. }
  27835. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27836. data := make(map[string]interface{})
  27837. client := &http.Client{}
  27838. data["psn_no"] = his.PsnNo
  27839. data["mdtrt_id"] = his.Number
  27840. data["department"] = department.Name
  27841. data["org_name"] = miConfig.OrgName
  27842. if reg_type == 11 && his.Insutype == "390" {
  27843. data["med_type"] = "110104"
  27844. } else {
  27845. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27846. }
  27847. data["doctor_id"] = doctor_info.DoctorNumber
  27848. data["doctor_name"] = roles.UserName
  27849. data["fixmedins_code"] = miConfig.Code
  27850. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27851. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27852. data["secret_key"] = miConfig.SecretKey
  27853. data["sick_code"] = sickConfig.CountryCode
  27854. data["sick_name"] = sickConfig.ClassName
  27855. data["begin_time"] = begin_time
  27856. data["dept"] = strconv.FormatInt(department.ID, 10)
  27857. data["config"] = config
  27858. data["opter"] = roles.UserName
  27859. fmt.Println(data)
  27860. bytesData, _ := json.Marshal(data)
  27861. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  27862. resp, _ := client.Do(req)
  27863. defer resp.Body.Close()
  27864. body, ioErr := ioutil.ReadAll(resp.Body)
  27865. if ioErr != nil {
  27866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27868. return
  27869. }
  27870. var respJSON map[string]interface{}
  27871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27874. return
  27875. }
  27876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27877. userJSONBytes, _ := json.Marshal(respJSON)
  27878. fmt.Println("log")
  27879. fmt.Println(string(userJSONBytes))
  27880. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27881. utils.ErrorLog("解析失败:%v", err)
  27882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27883. return
  27884. }
  27885. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27886. data := make(map[string]interface{})
  27887. client := &http.Client{}
  27888. data["psn_no"] = his.PsnNo
  27889. data["mdtrt_id"] = his.Number
  27890. data["department"] = department.Name
  27891. data["org_name"] = miConfig.OrgName
  27892. if reg_type == 11 && his.Insutype == "390" {
  27893. data["med_type"] = "110104"
  27894. } else {
  27895. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27896. }
  27897. data["doctor_id"] = doctor_info.DoctorNumber
  27898. data["doctor_name"] = roles.UserName
  27899. data["fixmedins_code"] = miConfig.Code
  27900. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27901. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27902. data["secret_key"] = miConfig.SecretKey
  27903. data["sick_code"] = sickConfig.CountryCode
  27904. data["sick_name"] = sickConfig.ClassName
  27905. data["begin_time"] = begin_time
  27906. data["dept"] = strconv.FormatInt(department.ID, 10)
  27907. data["config"] = config
  27908. data["opter"] = roles.UserName
  27909. fmt.Println(data)
  27910. bytesData, _ := json.Marshal(data)
  27911. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  27912. resp, _ := client.Do(req)
  27913. defer resp.Body.Close()
  27914. body, ioErr := ioutil.ReadAll(resp.Body)
  27915. if ioErr != nil {
  27916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27918. return
  27919. }
  27920. var respJSON map[string]interface{}
  27921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27924. return
  27925. }
  27926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27927. userJSONBytes, _ := json.Marshal(respJSON)
  27928. fmt.Println("log")
  27929. fmt.Println(string(userJSONBytes))
  27930. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27931. utils.ErrorLog("解析失败:%v", err)
  27932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27933. return
  27934. }
  27935. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27936. data := make(map[string]interface{})
  27937. client := &http.Client{}
  27938. data["psn_no"] = his.PsnNo
  27939. data["mdtrt_id"] = his.Number
  27940. data["doctor"] = roles.UserName
  27941. data["department"] = department.Name
  27942. data["org_name"] = miConfig.OrgName
  27943. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27944. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  27945. data["fixmedins_code"] = miConfig.Code
  27946. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27947. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27948. data["secret_key"] = miConfig.SecretKey
  27949. data["sick_code"] = sickConfig.CountryCode
  27950. data["sick_name"] = sickConfig.ClassName
  27951. data["begin_time"] = begin_time
  27952. data["dept"] = strconv.FormatInt(department.ID, 10)
  27953. data["config"] = config
  27954. data["url"] = miConfig.Url
  27955. data["ak"] = miConfig.AccessKey
  27956. data["cainfo"] = miConfig.Cainfo
  27957. bytesData, _ := json.Marshal(data)
  27958. var req *http.Request
  27959. if miConfig.MdtrtareaAdmvs == "320921" {
  27960. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  27961. } else {
  27962. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  27963. }
  27964. resp, _ := client.Do(req)
  27965. defer resp.Body.Close()
  27966. body, ioErr := ioutil.ReadAll(resp.Body)
  27967. if ioErr != nil {
  27968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27970. return
  27971. }
  27972. var respJSON map[string]interface{}
  27973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27976. return
  27977. }
  27978. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  27979. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  27980. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  27981. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27982. userJSONBytes, _ := json.Marshal(respJSON)
  27983. fmt.Println("log")
  27984. fmt.Println(string(userJSONBytes))
  27985. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  27986. utils.ErrorLog("解析失败:%v", err)
  27987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27988. return
  27989. }
  27990. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27991. res2.Output = resSix10265.Output
  27992. res2.ErrMsg = resSix10265.ErrMsg
  27993. res2.Cainfo = resSix10265.Cainfo
  27994. res2.WarnMsg = resSix10265.WarnMsg
  27995. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27996. res2.Infcode = infocode
  27997. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27998. data := make(map[string]interface{})
  27999. client := &http.Client{}
  28000. data["psn_no"] = his.PsnNo
  28001. data["mdtrt_id"] = his.Number
  28002. data["doctor"] = roles.UserName
  28003. data["department"] = department.Name
  28004. data["org_name"] = miConfig.OrgName
  28005. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28006. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28007. data["fixmedins_code"] = miConfig.Code
  28008. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28009. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28010. data["secret_key"] = miConfig.SecretKey
  28011. data["sick_code"] = sickConfig.CountryCode
  28012. data["sick_name"] = sickConfig.ClassName
  28013. data["begin_time"] = begin_time
  28014. data["dept"] = strconv.FormatInt(department.ID, 10)
  28015. data["config"] = config
  28016. //data["url"] = miConfig.Url
  28017. //data["ak"] = miConfig.AccessKey
  28018. data["cainfo"] = miConfig.Cainfo
  28019. fmt.Println(data)
  28020. bytesData, _ := json.Marshal(data)
  28021. var req *http.Request
  28022. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28023. resp, _ := client.Do(req)
  28024. defer resp.Body.Close()
  28025. body, ioErr := ioutil.ReadAll(resp.Body)
  28026. if ioErr != nil {
  28027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28029. return
  28030. }
  28031. var respJSON map[string]interface{}
  28032. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28035. return
  28036. }
  28037. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28038. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28039. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28041. userJSONBytes, _ := json.Marshal(respJSON)
  28042. fmt.Println("log")
  28043. fmt.Println(string(userJSONBytes))
  28044. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28045. utils.ErrorLog("解析失败:%v", err)
  28046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28047. return
  28048. }
  28049. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28050. res2.Output = resSix10265.Output
  28051. res2.ErrMsg = resSix10265.ErrMsg
  28052. res2.Cainfo = resSix10265.Cainfo
  28053. res2.WarnMsg = resSix10265.WarnMsg
  28054. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28055. res2.Infcode = infocode
  28056. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28057. 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)
  28058. saveLog(result, requestLog, "2203", "上传就诊信息")
  28059. var respJSON2 map[string]interface{}
  28060. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28063. return
  28064. }
  28065. userJSONBytes2, _ := json.Marshal(respJSON2)
  28066. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28067. utils.ErrorLog("解析失败:%v", err)
  28068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28069. return
  28070. }
  28071. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28072. var result string
  28073. var requestLog string
  28074. 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, "")
  28075. saveLog(result, requestLog, "2203", "上传就诊信息")
  28076. var respJSON2 map[string]interface{}
  28077. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28080. return
  28081. }
  28082. userJSONBytes2, _ := json.Marshal(respJSON2)
  28083. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28084. utils.ErrorLog("解析失败:%v", err)
  28085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28086. return
  28087. }
  28088. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28089. var result string
  28090. var requestLog string
  28091. 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, "")
  28092. saveLog(result, requestLog, "2203", "上传就诊信息")
  28093. var respJSON2 map[string]interface{}
  28094. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28097. return
  28098. }
  28099. userJSONBytes2, _ := json.Marshal(respJSON2)
  28100. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28101. utils.ErrorLog("解析失败:%v", err)
  28102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28103. return
  28104. }
  28105. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28106. data := make(map[string]interface{})
  28107. client := &http.Client{}
  28108. data["psn_no"] = his.PsnNo
  28109. data["mdtrt_id"] = his.Number
  28110. data["operator"] = roles.UserName
  28111. data["department"] = department.Name
  28112. data["org_name"] = miConfig.OrgName
  28113. var med_type string
  28114. if his.Insutype == "390" {
  28115. if reg_type == 992102 {
  28116. med_type = "992102"
  28117. data["sick_code"] = "ZDZ940"
  28118. data["sick_name"] = "慢性肾衰竭"
  28119. }
  28120. if reg_type == 140104 {
  28121. med_type = "140104"
  28122. data["sick_code"] = sickConfig.CountryCode
  28123. data["sick_name"] = sickConfig.ClassName
  28124. }
  28125. if reg_type == 14 {
  28126. med_type = "140104"
  28127. data["sick_code"] = sickConfig.CountryCode
  28128. data["sick_name"] = sickConfig.ClassName
  28129. }
  28130. } else if his.Insutype == "310" {
  28131. if reg_type == 992102 {
  28132. med_type = "992102"
  28133. data["sick_code"] = "ZDZ940"
  28134. data["sick_name"] = "慢性肾衰竭"
  28135. }
  28136. if reg_type == 140104 {
  28137. med_type = "140104"
  28138. data["sick_code"] = sickConfig.CountryCode
  28139. data["sick_name"] = sickConfig.ClassName
  28140. }
  28141. if reg_type == 14 {
  28142. med_type = "14"
  28143. data["sick_code"] = sickConfig.CountryCode
  28144. data["sick_name"] = sickConfig.ClassName
  28145. }
  28146. }
  28147. data["med_type"] = med_type
  28148. data["doctor_number"] = doctor_info.DoctorNumber
  28149. data["doctor_name"] = doctor_info.UserName
  28150. data["fixmedins_code"] = miConfig.Code
  28151. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28152. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28153. data["secret_key"] = miConfig.SecretKey
  28154. data["begin_time"] = begin_time
  28155. data["dept"] = strconv.FormatInt(department.ID, 10)
  28156. data["config"] = config
  28157. data["url"] = miConfig.Url
  28158. data["ak"] = miConfig.AccessKey
  28159. data["cainfo"] = miConfig.Cainfo
  28160. bytesData, _ := json.Marshal(data)
  28161. var req *http.Request
  28162. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28163. resp, _ := client.Do(req)
  28164. defer resp.Body.Close()
  28165. body, ioErr := ioutil.ReadAll(resp.Body)
  28166. if ioErr != nil {
  28167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28169. return
  28170. }
  28171. var respJSON map[string]interface{}
  28172. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28175. return
  28176. }
  28177. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28178. if status == "0" {
  28179. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28180. c.ServeSuccessJSON(map[string]interface{}{
  28181. "failed_code": -10,
  28182. "msg": err_msg,
  28183. })
  28184. return
  28185. }
  28186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28187. userJSONBytes, _ := json.Marshal(respJSON)
  28188. fmt.Println("log")
  28189. fmt.Println(string(userJSONBytes))
  28190. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28191. utils.ErrorLog("解析失败:%v", err)
  28192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28193. return
  28194. }
  28195. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28196. data := make(map[string]interface{})
  28197. client := &http.Client{}
  28198. data["psn_no"] = his.PsnNo
  28199. data["mdtrt_id"] = his.Number
  28200. data["operator"] = roles.UserName
  28201. data["department"] = department.Name
  28202. data["org_name"] = miConfig.OrgName
  28203. var med_type string
  28204. if his.Insutype == "390" {
  28205. if reg_type == 992102 {
  28206. med_type = "992102"
  28207. data["sick_code"] = sickConfig.CountryCode
  28208. data["sick_name"] = sickConfig.ClassName
  28209. }
  28210. if reg_type == 140104 {
  28211. med_type = "140104"
  28212. data["sick_code"] = sickConfig.CountryCode
  28213. data["sick_name"] = sickConfig.ClassName
  28214. }
  28215. if reg_type == 140201 {
  28216. med_type = "140201"
  28217. data["sick_code"] = sickConfig.CountryCode
  28218. data["sick_name"] = sickConfig.ClassName
  28219. }
  28220. if reg_type == 14 {
  28221. med_type = "14"
  28222. data["sick_code"] = sickConfig.CountryCode
  28223. data["sick_name"] = sickConfig.ClassName
  28224. }
  28225. } else if his.Insutype == "310" {
  28226. if reg_type == 992102 {
  28227. med_type = "992102"
  28228. data["sick_code"] = sickConfig.CountryCode
  28229. data["sick_name"] = sickConfig.ClassName
  28230. }
  28231. if reg_type == 140104 {
  28232. med_type = "140104"
  28233. data["sick_code"] = sickConfig.CountryCode
  28234. data["sick_name"] = sickConfig.ClassName
  28235. }
  28236. if reg_type == 140201 {
  28237. med_type = "140201"
  28238. data["sick_code"] = sickConfig.CountryCode
  28239. data["sick_name"] = sickConfig.ClassName
  28240. }
  28241. if reg_type == 14 {
  28242. med_type = "14"
  28243. data["sick_code"] = sickConfig.CountryCode
  28244. data["sick_name"] = sickConfig.ClassName
  28245. }
  28246. }
  28247. data["med_type"] = med_type
  28248. data["doctor_number"] = doctor_info.DoctorNumber
  28249. data["doctor_name"] = doctor_info.UserName
  28250. data["fixmedins_code"] = miConfig.Code
  28251. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28252. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28253. data["secret_key"] = miConfig.SecretKey
  28254. data["begin_time"] = begin_time
  28255. data["dept"] = strconv.FormatInt(department.ID, 10)
  28256. data["config"] = config
  28257. data["url"] = miConfig.Url
  28258. data["ak"] = miConfig.AccessKey
  28259. data["cainfo"] = miConfig.Cainfo
  28260. bytesData, _ := json.Marshal(data)
  28261. var req *http.Request
  28262. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28263. resp, _ := client.Do(req)
  28264. defer resp.Body.Close()
  28265. body, ioErr := ioutil.ReadAll(resp.Body)
  28266. if ioErr != nil {
  28267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28269. return
  28270. }
  28271. var respJSON map[string]interface{}
  28272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28275. return
  28276. }
  28277. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28278. if status == "0" {
  28279. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28280. c.ServeSuccessJSON(map[string]interface{}{
  28281. "failed_code": -10,
  28282. "msg": err_msg,
  28283. })
  28284. return
  28285. }
  28286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28287. userJSONBytes, _ := json.Marshal(respJSON)
  28288. fmt.Println("log")
  28289. fmt.Println(string(userJSONBytes))
  28290. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28291. utils.ErrorLog("解析失败:%v", err)
  28292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28293. return
  28294. }
  28295. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28296. var result string
  28297. var requestLog string
  28298. 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, "")
  28299. saveLog(result, requestLog, "2203", "上传就诊信息")
  28300. var respJSON2 map[string]interface{}
  28301. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28304. return
  28305. }
  28306. userJSONBytes2, _ := json.Marshal(respJSON2)
  28307. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28308. utils.ErrorLog("解析失败:%v", err)
  28309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28310. return
  28311. }
  28312. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28313. data := make(map[string]interface{})
  28314. client := &http.Client{}
  28315. data["psn_no"] = his.PsnNo
  28316. data["mdtrt_id"] = his.Number
  28317. data["doctor"] = roles.UserName
  28318. data["department"] = department.Name
  28319. data["org_name"] = miConfig.OrgName
  28320. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28321. data["doctor_id"] = doctor_info.DoctorNumber
  28322. data["fixmedins_code"] = miConfig.Code
  28323. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28324. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28325. data["secret_key"] = miConfig.SecretKey
  28326. data["sick_code"] = sickConfig.CountryCode
  28327. data["sick_name"] = sickConfig.ClassName
  28328. data["begin_time"] = begin_time
  28329. data["new_doctor_name"] = doctor_info.UserName
  28330. data["dept"] = strconv.FormatInt(department.ID, 10)
  28331. data["config"] = config
  28332. bytesData, _ := json.Marshal(data)
  28333. var req *http.Request
  28334. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28335. resp, _ := client.Do(req)
  28336. defer resp.Body.Close()
  28337. body, ioErr := ioutil.ReadAll(resp.Body)
  28338. if ioErr != nil {
  28339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28341. return
  28342. }
  28343. var respJSON map[string]interface{}
  28344. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28347. return
  28348. }
  28349. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28350. userJSONBytes, _ := json.Marshal(respJSON)
  28351. fmt.Println("log")
  28352. fmt.Println(string(userJSONBytes))
  28353. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28354. utils.ErrorLog("解析失败:%v", err)
  28355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28356. return
  28357. }
  28358. } else {
  28359. var result string
  28360. var requestLog string
  28361. if miConfig.MdtrtareaAdmvs == "440781" { //
  28362. 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)
  28363. } else {
  28364. if miConfig.Code == "H15049901371" {
  28365. //赤峰地区国家医保医疗类别
  28366. //职工透析:医疗类别选特殊情况门诊990502
  28367. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28368. var med_type string
  28369. if his.Insutype == "390" {
  28370. if reg_type == 14 {
  28371. med_type = "9933"
  28372. } else if reg_type == 11 {
  28373. med_type = "11"
  28374. }
  28375. } else if his.Insutype == "310" {
  28376. if reg_type == 14 {
  28377. med_type = "990502"
  28378. } else if reg_type == 11 {
  28379. med_type = "11"
  28380. }
  28381. }
  28382. 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)
  28383. } else {
  28384. 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)
  28385. }
  28386. saveLog(result, requestLog, "2203", "上传就诊信息")
  28387. var respJSON2 map[string]interface{}
  28388. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28391. return
  28392. }
  28393. userJSONBytes2, _ := json.Marshal(respJSON2)
  28394. if miConfig.Code == "H15049901371" {
  28395. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28396. utils.ErrorLog("解析失败:%v", err)
  28397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28398. return
  28399. }
  28400. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28401. res2.Output = resSix10265.Output
  28402. res2.ErrMsg = resSix10265.ErrMsg
  28403. res2.Cainfo = resSix10265.Cainfo
  28404. res2.WarnMsg = resSix10265.WarnMsg
  28405. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28406. res2.Infcode = infocode
  28407. } else {
  28408. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28409. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28410. utils.ErrorLog("解析失败:%v", err)
  28411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28412. return
  28413. }
  28414. res2.Infcode = res3.Infcode
  28415. } else {
  28416. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28417. utils.ErrorLog("解析失败:%v", err)
  28418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28419. return
  28420. }
  28421. }
  28422. }
  28423. }
  28424. }
  28425. if res2.Infcode == -1 {
  28426. adminUser := c.GetAdminUserInfo()
  28427. errlog := &models.HisOrderError{
  28428. UserOrgId: adminUser.CurrentOrgId,
  28429. Ctime: time.Now().Unix(),
  28430. Mtime: time.Now().Unix(),
  28431. ErrMsg: res2.ErrMsg,
  28432. Status: 1,
  28433. PatientId: id,
  28434. RecordTime: recordDateTime,
  28435. Stage: 3,
  28436. }
  28437. service.CreateErrMsgLog(errlog)
  28438. c.ServeSuccessJSON(map[string]interface{}{
  28439. "failed_code": -10,
  28440. "msg": res2.ErrMsg,
  28441. })
  28442. return
  28443. }
  28444. if res2.Infcode != 0 {
  28445. adminUser := c.GetAdminUserInfo()
  28446. errlog := &models.HisOrderError{
  28447. UserOrgId: adminUser.CurrentOrgId,
  28448. Ctime: time.Now().Unix(),
  28449. Mtime: time.Now().Unix(),
  28450. ErrMsg: res2.ErrMsg,
  28451. Status: 1,
  28452. PatientId: id,
  28453. RecordTime: recordDateTime,
  28454. Stage: 3,
  28455. }
  28456. service.CreateErrMsgLog(errlog)
  28457. c.ServeSuccessJSON(map[string]interface{}{
  28458. "failed_code": -10,
  28459. "msg": res2.ErrMsg,
  28460. })
  28461. return
  28462. } else {
  28463. his.Diagnosis = diagnosis_id
  28464. his.SickType = sickConfig.ID
  28465. his.PType = fmt.Sprintf("%d", reg_type)
  28466. service.UpdateHisPatientThree(&his)
  28467. data := make(map[string]interface{})
  28468. if settle_accounts_type == 1 { //日结
  28469. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28470. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28471. } else {
  28472. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28473. }
  28474. data["pre"] = prescriptions
  28475. } else { //月结
  28476. start_time_str := c.GetString("start_time")
  28477. end_time_str := c.GetString("end_time")
  28478. timeLayout := "2006-01-02"
  28479. loc, _ := time.LoadLocation("Local")
  28480. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28481. if err != nil {
  28482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28483. return
  28484. }
  28485. recordStartTime := theStartTime.Unix()
  28486. start_time = recordStartTime
  28487. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28488. if err != nil {
  28489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28490. return
  28491. }
  28492. recordEndTime := theEndTime.Unix()
  28493. end_time = recordEndTime
  28494. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28495. data["pre"] = prescriptions
  28496. }
  28497. client := &http.Client{}
  28498. data["psn_no"] = his.PsnNo
  28499. data["mdtrt_id"] = his.Number
  28500. data["chrg_bchno"] = new_chrg_bchno
  28501. data["org_name"] = miConfig.OrgName
  28502. data["doctor"] = doctor_info.UserName
  28503. data["doctor_id"] = doctor_info.DoctorNumber
  28504. data["dept"] = department.Name
  28505. data["fixmedins_code"] = miConfig.Code
  28506. data["opter"] = roles.UserName
  28507. data["dept_code"] = department.Number
  28508. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28509. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28510. data["secret_key"] = miConfig.SecretKey
  28511. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28512. data["url"] = miConfig.Url
  28513. data["ak"] = miConfig.AccessKey
  28514. data["new_doctor_name"] = patientPrescription.Doctor
  28515. if his.Insutype == "390" {
  28516. if reg_type == 992102 {
  28517. data["diag_code"] = "ZDZ940"
  28518. }
  28519. if reg_type == 140104 {
  28520. data["diag_code"] = sickConfig.CountryCode
  28521. }
  28522. if reg_type == 140201 {
  28523. data["diag_code"] = sickConfig.CountryCode
  28524. }
  28525. if reg_type == 14 {
  28526. data["diag_code"] = sickConfig.CountryCode
  28527. }
  28528. } else if his.Insutype == "310" {
  28529. if miConfig.MdtrtareaAdmvs == "341203" {
  28530. if reg_type == 992102 {
  28531. data["diag_code"] = "ZDZ940"
  28532. }
  28533. if reg_type != 992102 {
  28534. data["diag_code"] = sickConfig.CountryCode
  28535. }
  28536. } else {
  28537. data["diag_code"] = sickConfig.CountryCode
  28538. }
  28539. }
  28540. data["cainfo"] = miConfig.Cainfo
  28541. data["opter"] = roles.UserName
  28542. var ids []int64
  28543. for _, item := range prescriptions {
  28544. ids = append(ids, item.ID)
  28545. }
  28546. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28547. if config.IsOpen == 1 { //对接了医保,走医保流程
  28548. var res ResultFour
  28549. var resFour10265 ResultFour10265
  28550. if miConfig.MdtrtareaAdmvs == "421300" {
  28551. bytesData, _ := json.Marshal(data)
  28552. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28553. resp, _ := client.Do(req)
  28554. defer resp.Body.Close()
  28555. body, ioErr := ioutil.ReadAll(resp.Body)
  28556. if ioErr != nil {
  28557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28559. return
  28560. }
  28561. var respJSON map[string]interface{}
  28562. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28565. return
  28566. }
  28567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28568. userJSONBytes, _ := json.Marshal(respJSON)
  28569. fmt.Println("log")
  28570. fmt.Println(string(userJSONBytes))
  28571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28572. utils.ErrorLog("解析失败:%v", err)
  28573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28574. return
  28575. }
  28576. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28577. bytesData, _ := json.Marshal(data)
  28578. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28579. resp, _ := client.Do(req)
  28580. defer resp.Body.Close()
  28581. body, ioErr := ioutil.ReadAll(resp.Body)
  28582. if ioErr != nil {
  28583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28585. return
  28586. }
  28587. var respJSON map[string]interface{}
  28588. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28591. return
  28592. }
  28593. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28594. userJSONBytes, _ := json.Marshal(respJSON)
  28595. fmt.Println("log")
  28596. fmt.Println(string(userJSONBytes))
  28597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28598. utils.ErrorLog("解析失败:%v", err)
  28599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28600. return
  28601. }
  28602. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28603. bytesData, _ := json.Marshal(data)
  28604. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28605. resp, _ := client.Do(req)
  28606. defer resp.Body.Close()
  28607. body, ioErr := ioutil.ReadAll(resp.Body)
  28608. if ioErr != nil {
  28609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28611. return
  28612. }
  28613. var respJSON map[string]interface{}
  28614. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28617. return
  28618. }
  28619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28620. userJSONBytes, _ := json.Marshal(respJSON)
  28621. fmt.Println("log")
  28622. fmt.Println(string(userJSONBytes))
  28623. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28624. utils.ErrorLog("解析失败:%v", err)
  28625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28626. return
  28627. }
  28628. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28629. bytesData, _ := json.Marshal(data)
  28630. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28631. resp, _ := client.Do(req)
  28632. defer resp.Body.Close()
  28633. body, ioErr := ioutil.ReadAll(resp.Body)
  28634. if ioErr != nil {
  28635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28637. return
  28638. }
  28639. var respJSON map[string]interface{}
  28640. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28643. return
  28644. }
  28645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28646. userJSONBytes, _ := json.Marshal(respJSON)
  28647. fmt.Println("log")
  28648. fmt.Println(string(userJSONBytes))
  28649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28650. utils.ErrorLog("解析失败:%v", err)
  28651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28652. return
  28653. }
  28654. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28655. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28656. if result3101.Infcode == "0" {
  28657. if len(result3101.Output.Result) > 0 {
  28658. var errMsgs []string
  28659. for _, item := range result3101.Output.Result {
  28660. errMsgs = append(errMsgs, item.VolaCont)
  28661. }
  28662. c.ServeSuccessJSON(map[string]interface{}{
  28663. "failed_code": -10,
  28664. "msg": errMsgs,
  28665. })
  28666. return
  28667. } else {
  28668. if miConfig.MdtrtareaAdmvs == "320921" {
  28669. data["doctor_id"] = "D320923012139"
  28670. } else {
  28671. data["doctor_id"] = "D371621008686"
  28672. }
  28673. bytesData, _ := json.Marshal(data)
  28674. var req *http.Request
  28675. if miConfig.MdtrtareaAdmvs == "320921" {
  28676. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28677. } else {
  28678. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28679. }
  28680. resp, _ := client.Do(req)
  28681. defer resp.Body.Close()
  28682. body, ioErr := ioutil.ReadAll(resp.Body)
  28683. if ioErr != nil {
  28684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28686. return
  28687. }
  28688. var respJSON map[string]interface{}
  28689. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28692. return
  28693. }
  28694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28695. userJSONBytes, _ := json.Marshal(respJSON)
  28696. fmt.Println("log")
  28697. fmt.Println(string(userJSONBytes))
  28698. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28699. utils.ErrorLog("解析失败:%v", err)
  28700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28701. return
  28702. }
  28703. res.InfRefmsgid = resFour10265.InfRefmsgid
  28704. res.Output = resFour10265.Output
  28705. res.ErrMsg = resFour10265.ErrMsg
  28706. res.Cainfo = resFour10265.Cainfo
  28707. res.WarnMsg = resFour10265.WarnMsg
  28708. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28709. res.Infcode = infocode
  28710. }
  28711. }
  28712. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28713. var pagesize int = 5
  28714. var start int = 1
  28715. var stop int
  28716. var pagecount int
  28717. var curpage int
  28718. data["doctor_id"] = doctor_info.DoctorNumber
  28719. var res2 ResultFour
  28720. //var result res.
  28721. //总页数,向上取整,注意除之前要先转换类型为float64
  28722. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  28723. for curpage = 1; curpage <= pagecount; curpage++ {
  28724. if curpage == 1 {
  28725. start = 1
  28726. } else {
  28727. start = (curpage-1)*pagesize + 1
  28728. }
  28729. stop = curpage * pagesize
  28730. if stop > len(prescriptions) {
  28731. stop = len(prescriptions)
  28732. }
  28733. //var requestLog string
  28734. data["pre"] = prescriptions[start-1 : stop]
  28735. fmt.Println(data["pre"])
  28736. bytesData, _ := json.Marshal(data)
  28737. var req *http.Request
  28738. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  28739. resp, _ := client.Do(req)
  28740. defer resp.Body.Close()
  28741. body, ioErr := ioutil.ReadAll(resp.Body)
  28742. if ioErr != nil {
  28743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28745. return
  28746. }
  28747. var respJSON map[string]interface{}
  28748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28751. return
  28752. }
  28753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28754. userJSONBytes, _ := json.Marshal(respJSON)
  28755. fmt.Println("log")
  28756. fmt.Println(string(userJSONBytes))
  28757. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28758. utils.ErrorLog("解析失败:%v", err)
  28759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28760. return
  28761. }
  28762. res.InfRefmsgid = resFour10265.InfRefmsgid
  28763. res.Output = resFour10265.Output
  28764. res.ErrMsg = resFour10265.ErrMsg
  28765. res.Cainfo = resFour10265.Cainfo
  28766. res.WarnMsg = resFour10265.WarnMsg
  28767. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28768. res.Infcode = infocode
  28769. if infocode == 0 {
  28770. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  28771. } else {
  28772. isSuccess = false
  28773. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  28774. res.Infcode = -1
  28775. res.ErrMsg = resFour10265.ErrMsg
  28776. errlog := &models.HisOrderError{
  28777. UserOrgId: adminUser.CurrentOrgId,
  28778. Ctime: time.Now().Unix(),
  28779. Mtime: time.Now().Unix(),
  28780. Number: chrg_bchno,
  28781. ErrMsg: "",
  28782. Status: 1,
  28783. PatientId: id,
  28784. RecordTime: recordDateTime,
  28785. Stage: 4,
  28786. }
  28787. service.CreateErrMsgLog(errlog)
  28788. }
  28789. }
  28790. if isSuccess {
  28791. res.Infcode = 0
  28792. res.Output.Result = res2.Output.Result
  28793. } else {
  28794. order := &models.HisOrder{
  28795. UserOrgId: adminUser.CurrentOrgId,
  28796. HisPatientId: his.ID,
  28797. PatientId: his.PatientId,
  28798. SettleAccountsDate: recordDateTime,
  28799. Ctime: time.Now().Unix(),
  28800. Mtime: time.Now().Unix(),
  28801. MdtrtId: his.Number,
  28802. PsnNo: his.PsnNo,
  28803. MedType: strconv.FormatInt(reg_type, 10),
  28804. Status: 1,
  28805. Number: chrg_bchno,
  28806. Infcode: res.Infcode,
  28807. WarnMsg: res.WarnMsg,
  28808. Cainfo: res.Cainfo,
  28809. ErrMsg: res.ErrMsg,
  28810. RespondTime: res.RefmsgTime,
  28811. InfRefmsgid: res.InfRefmsgid,
  28812. OrderStatus: 1,
  28813. IsMedicineInsurance: 1,
  28814. SettleType: settle_accounts_type,
  28815. SettleStartTime: start_time,
  28816. SettleEndTime: end_time,
  28817. Creator: roles.AdminUserId,
  28818. Modify: roles.AdminUserId,
  28819. PType: 2,
  28820. Diagnosis: diagnosis_id,
  28821. }
  28822. err = service.CreateOrder(order)
  28823. if err != nil {
  28824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28825. return
  28826. }
  28827. c.ServeSuccessJSON(map[string]interface{}{
  28828. "failed_code": -10,
  28829. "msg": res2.ErrMsg,
  28830. })
  28831. return
  28832. }
  28833. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28834. 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)
  28835. var dat map[string]interface{}
  28836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28837. fmt.Println(dat)
  28838. } else {
  28839. fmt.Println(err)
  28840. }
  28841. saveLog(result, request_log, "2204", "上传费用明细")
  28842. userJSONBytes, _ := json.Marshal(dat)
  28843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28844. utils.ErrorLog("解析失败:%v", err)
  28845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28846. return
  28847. }
  28848. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28849. 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, "", "")
  28850. var dat map[string]interface{}
  28851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28852. fmt.Println(dat)
  28853. } else {
  28854. fmt.Println(err)
  28855. }
  28856. saveLog(result, request_log, "2204", "上传费用明细")
  28857. userJSONBytes, _ := json.Marshal(dat)
  28858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28859. utils.ErrorLog("解析失败:%v", err)
  28860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28861. return
  28862. }
  28863. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28864. 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, "", "")
  28865. var dat map[string]interface{}
  28866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28867. fmt.Println(dat)
  28868. } else {
  28869. fmt.Println(err)
  28870. }
  28871. saveLog(result, request_log, "2204", "上传费用明细")
  28872. userJSONBytes, _ := json.Marshal(dat)
  28873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28874. utils.ErrorLog("解析失败:%v", err)
  28875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28876. return
  28877. }
  28878. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28879. bytesData, _ := json.Marshal(data)
  28880. var req *http.Request
  28881. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  28882. resp, _ := client.Do(req)
  28883. defer resp.Body.Close()
  28884. body, ioErr := ioutil.ReadAll(resp.Body)
  28885. if ioErr != nil {
  28886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28888. return
  28889. }
  28890. var respJSON map[string]interface{}
  28891. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28894. return
  28895. }
  28896. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28897. if status == "0" {
  28898. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28899. c.ServeSuccessJSON(map[string]interface{}{
  28900. "failed_code": -10,
  28901. "msg": err_msg,
  28902. })
  28903. return
  28904. }
  28905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28906. userJSONBytes, _ := json.Marshal(respJSON)
  28907. fmt.Println("log")
  28908. fmt.Println(string(userJSONBytes))
  28909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28910. utils.ErrorLog("解析失败:%v", err)
  28911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28912. return
  28913. }
  28914. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28915. bytesData, _ := json.Marshal(data)
  28916. var req *http.Request
  28917. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  28918. resp, _ := client.Do(req)
  28919. defer resp.Body.Close()
  28920. body, ioErr := ioutil.ReadAll(resp.Body)
  28921. if ioErr != nil {
  28922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28924. return
  28925. }
  28926. var respJSON map[string]interface{}
  28927. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28930. return
  28931. }
  28932. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28933. if status == "0" {
  28934. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28935. c.ServeSuccessJSON(map[string]interface{}{
  28936. "failed_code": -10,
  28937. "msg": err_msg,
  28938. })
  28939. return
  28940. }
  28941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28942. userJSONBytes, _ := json.Marshal(respJSON)
  28943. fmt.Println("log")
  28944. fmt.Println(string(userJSONBytes))
  28945. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28946. utils.ErrorLog("解析失败:%v", err)
  28947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28948. return
  28949. }
  28950. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28951. 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, "", "")
  28952. var dat map[string]interface{}
  28953. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28954. fmt.Println(dat)
  28955. } else {
  28956. fmt.Println(err)
  28957. }
  28958. saveLog(result, request_log, "2204", "上传费用明细")
  28959. userJSONBytes, _ := json.Marshal(dat)
  28960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28961. utils.ErrorLog("解析失败:%v", err)
  28962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28963. return
  28964. }
  28965. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28966. bytesData, _ := json.Marshal(data)
  28967. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  28968. resp, _ := client.Do(req)
  28969. defer resp.Body.Close()
  28970. body, ioErr := ioutil.ReadAll(resp.Body)
  28971. if ioErr != nil {
  28972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28974. return
  28975. }
  28976. var respJSON map[string]interface{}
  28977. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28980. return
  28981. }
  28982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28983. userJSONBytes, _ := json.Marshal(respJSON)
  28984. fmt.Println("log")
  28985. fmt.Println(string(userJSONBytes))
  28986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28987. utils.ErrorLog("解析失败:%v", err)
  28988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28989. return
  28990. }
  28991. } else {
  28992. if miConfig.MdtrtareaAdmvs == "441202" {
  28993. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28994. if result3101.Infcode == 0 {
  28995. if len(result3101.Output.Result) > 0 {
  28996. var errMsgs []string
  28997. for _, item := range result3101.Output.Result {
  28998. errMsgs = append(errMsgs, item.VolaCont)
  28999. }
  29000. c.ServeSuccessJSON(map[string]interface{}{
  29001. "failed_code": -10,
  29002. "msg": errMsgs,
  29003. })
  29004. return
  29005. } else {
  29006. 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)
  29007. var dat map[string]interface{}
  29008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29009. fmt.Println(dat)
  29010. } else {
  29011. fmt.Println(err)
  29012. }
  29013. saveLog(result, request_log, "2204", "上传费用明细")
  29014. userJSONBytes, _ := json.Marshal(dat)
  29015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29016. utils.ErrorLog("解析失败:%v", err)
  29017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29018. return
  29019. }
  29020. }
  29021. } else {
  29022. c.ServeSuccessJSON(map[string]interface{}{
  29023. "failed_code": -10,
  29024. "msg": result3101.ErrMsg,
  29025. })
  29026. return
  29027. }
  29028. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29029. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29030. if result3101.Infcode == 0 {
  29031. if len(result3101.Output.Result) > 0 {
  29032. var errMsgs []string
  29033. for _, item := range result3101.Output.Result {
  29034. errMsgs = append(errMsgs, item.VolaCont)
  29035. }
  29036. c.ServeSuccessJSON(map[string]interface{}{
  29037. "failed_code": -10,
  29038. "msg": errMsgs,
  29039. })
  29040. return
  29041. } else {
  29042. 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)
  29043. var dat map[string]interface{}
  29044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29045. fmt.Println(dat)
  29046. } else {
  29047. fmt.Println(err)
  29048. }
  29049. saveLog(result, request_log, "2204", "上传费用明细")
  29050. userJSONBytes, _ := json.Marshal(dat)
  29051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29052. utils.ErrorLog("解析失败:%v", err)
  29053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29054. return
  29055. }
  29056. }
  29057. } else {
  29058. c.ServeSuccessJSON(map[string]interface{}{
  29059. "failed_code": -10,
  29060. "msg": result3101.ErrMsg,
  29061. })
  29062. return
  29063. }
  29064. } else {
  29065. if miConfig.Code == "H15049901371" {
  29066. 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)
  29067. var dat map[string]interface{}
  29068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29069. fmt.Println(dat)
  29070. } else {
  29071. fmt.Println(err)
  29072. }
  29073. saveLog(result, request_log, "2204", "上传费用明细")
  29074. userJSONBytes, _ := json.Marshal(dat)
  29075. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29076. utils.ErrorLog("解析失败:%v", err)
  29077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29078. return
  29079. }
  29080. res.InfRefmsgid = resFour10265.InfRefmsgid
  29081. res.Output = resFour10265.Output
  29082. res.ErrMsg = resFour10265.ErrMsg
  29083. res.Cainfo = resFour10265.Cainfo
  29084. res.WarnMsg = resFour10265.WarnMsg
  29085. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29086. res.Infcode = infocode
  29087. } else {
  29088. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29089. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29090. if result3101.Infcode == 0 {
  29091. if len(result3101.Output.Result) > 0 {
  29092. var errMsgs []string
  29093. for _, item := range result3101.Output.Result {
  29094. errMsgs = append(errMsgs, item.VolaCont)
  29095. }
  29096. c.ServeSuccessJSON(map[string]interface{}{
  29097. "failed_code": -10,
  29098. "msg": errMsgs,
  29099. })
  29100. return
  29101. } else {
  29102. 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)
  29103. var dat map[string]interface{}
  29104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29105. fmt.Println(dat)
  29106. } else {
  29107. fmt.Println(err)
  29108. }
  29109. saveLog(result, request_log, "2204", "上传费用明细")
  29110. userJSONBytes, _ := json.Marshal(dat)
  29111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29112. utils.ErrorLog("解析失败:%v", err)
  29113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29114. return
  29115. }
  29116. }
  29117. } else {
  29118. c.ServeSuccessJSON(map[string]interface{}{
  29119. "failed_code": -10,
  29120. "msg": result3101.ErrMsg,
  29121. })
  29122. return
  29123. }
  29124. } else {
  29125. 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)
  29126. var dat map[string]interface{}
  29127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29128. fmt.Println(dat)
  29129. } else {
  29130. fmt.Println(err)
  29131. }
  29132. saveLog(result, request_log, "2204", "上传费用明细")
  29133. userJSONBytes, _ := json.Marshal(dat)
  29134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29135. utils.ErrorLog("解析失败:%v", err)
  29136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29137. return
  29138. }
  29139. }
  29140. }
  29141. }
  29142. }
  29143. var total_two float64
  29144. if res.Infcode == -1 {
  29145. errlog := &models.HisOrderError{
  29146. UserOrgId: adminUser.CurrentOrgId,
  29147. Ctime: time.Now().Unix(),
  29148. Mtime: time.Now().Unix(),
  29149. Number: chrg_bchno,
  29150. ErrMsg: res.ErrMsg,
  29151. Status: 1,
  29152. PatientId: id,
  29153. RecordTime: recordDateTime,
  29154. Stage: 4,
  29155. }
  29156. service.CreateErrMsgLog(errlog)
  29157. c.ServeSuccessJSON(map[string]interface{}{
  29158. "failed_code": -10,
  29159. "msg": res.ErrMsg,
  29160. })
  29161. return
  29162. }
  29163. if res.Infcode == 0 {
  29164. order := &models.HisOrder{
  29165. UserOrgId: adminUser.CurrentOrgId,
  29166. HisPatientId: his.ID,
  29167. PatientId: his.PatientId,
  29168. SettleAccountsDate: recordDateTime,
  29169. Ctime: time.Now().Unix(),
  29170. Mtime: time.Now().Unix(),
  29171. MdtrtId: his.Number,
  29172. PsnNo: his.PsnNo,
  29173. MedType: strconv.FormatInt(reg_type, 10),
  29174. Status: 1,
  29175. Number: chrg_bchno,
  29176. Infcode: res.Infcode,
  29177. WarnMsg: res.WarnMsg,
  29178. Cainfo: res.Cainfo,
  29179. ErrMsg: res.ErrMsg,
  29180. RespondTime: res.RefmsgTime,
  29181. InfRefmsgid: res.InfRefmsgid,
  29182. OrderStatus: 1,
  29183. IsMedicineInsurance: 1,
  29184. SettleType: settle_accounts_type,
  29185. SettleStartTime: start_time,
  29186. SettleEndTime: end_time,
  29187. Creator: roles.AdminUserId,
  29188. Modify: roles.AdminUserId,
  29189. PType: 2,
  29190. Diagnosis: diagnosis_id,
  29191. }
  29192. err = service.CreateOrder(order)
  29193. if err != nil {
  29194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29195. return
  29196. }
  29197. for _, item := range res.Output.Result {
  29198. temp := strings.Split(item.FeedetlSn, "-")
  29199. var advice_id int64 = 0
  29200. var project_id int64 = 0
  29201. var types int64 = 0
  29202. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29203. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29204. if temp[1] == "1" {
  29205. advice_id = id
  29206. project_id = 0
  29207. } else if temp[1] == "2" {
  29208. advice_id = 0
  29209. project_id = id
  29210. }
  29211. total_two = total_two + item.DetItemFeeSumamt
  29212. info := &models.HisOrderInfo{
  29213. OrderNumber: order.Number,
  29214. FeedetlSn: item.FeedetlSn,
  29215. UploadDate: time.Now().Unix(),
  29216. AdviceId: advice_id,
  29217. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29218. Cnt: item.Cnt,
  29219. Pric: float64(item.Pric),
  29220. PatientId: his.PatientId,
  29221. PricUplmtAmt: item.PricUplmtAmt,
  29222. SelfpayProp: item.SelfpayProp,
  29223. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29224. OverlmtAmt: item.OverlmtAmt,
  29225. PreselfpayAmt: item.PreselfpayAmt,
  29226. BasMednFlag: item.BasMednFlag,
  29227. MedChrgitmType: item.MedChrgitmType,
  29228. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29229. Status: 1,
  29230. Memo: item.Memo,
  29231. Mtime: time.Now().Unix(),
  29232. InscpScpAmt: item.InscpScpAmt,
  29233. DrtReimFlag: item.DrtReimFlag,
  29234. Ctime: time.Now().Unix(),
  29235. ListSpItemFlag: item.ListSpItemFlag,
  29236. ChldMedcFlag: item.ChldMedcFlag,
  29237. LmtUsedFlag: item.LmtUsedFlag,
  29238. ChrgitmLv: item.ChrgitmLv,
  29239. UserOrgId: adminUser.CurrentOrgId,
  29240. HisPatientId: his.ID,
  29241. OrderId: order.ID,
  29242. ProjectId: project_id,
  29243. Type: types,
  29244. }
  29245. service.CreateOrderInfo(info)
  29246. }
  29247. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29248. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29249. var total float64
  29250. for _, item := range prescriptions {
  29251. if item.Type == 1 { //药品
  29252. for _, subItem := range item.HisDoctorAdviceInfo {
  29253. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29254. total_one := price * subItem.PrescribingNumber
  29255. fmt.Println("subItem")
  29256. fmt.Println(subItem.Price)
  29257. fmt.Println("price")
  29258. fmt.Println(price)
  29259. fmt.Println("total_one")
  29260. fmt.Println(total_one)
  29261. total = total + total_one
  29262. fmt.Println(total)
  29263. }
  29264. }
  29265. if item.Type == 2 { //项目
  29266. for _, subItem := range item.HisPrescriptionProject {
  29267. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29268. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29269. total_one := price * cnt
  29270. total = total + total_one
  29271. }
  29272. }
  29273. }
  29274. allTotal := fmt.Sprintf("%.2f", total)
  29275. if res.Infcode == 0 {
  29276. var rf []*ResultFive
  29277. json.Unmarshal([]byte(his.Iinfo), &rf)
  29278. chrg_bchno := chrg_bchno
  29279. cert_no := his.Certno
  29280. var insutypes []string
  29281. var insutype string
  29282. var is390 int = 0
  29283. var is310 int = 0
  29284. for _, item := range rf {
  29285. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29286. insutypes = append(insutypes, item.Insutype)
  29287. }
  29288. }
  29289. if len(insutypes) == 1 {
  29290. insutype = insutypes[0]
  29291. } else {
  29292. for _, i := range insutypes {
  29293. if i == "390" {
  29294. is390 = 1
  29295. }
  29296. if i == "310" {
  29297. is310 = 1
  29298. }
  29299. }
  29300. }
  29301. if is390 == 1 {
  29302. insutype = "390"
  29303. }
  29304. if is310 == 1 {
  29305. insutype = "310"
  29306. }
  29307. if len(insutypes) == 0 {
  29308. insutype = "390"
  29309. }
  29310. if len(insutypes) == 2 {
  29311. insutype = strconv.FormatInt(his.SocialType, 10)
  29312. }
  29313. //insutype = "390"
  29314. if his.IdCardType == 1 {
  29315. cert_no = his.MedicalInsuranceNumber
  29316. } else {
  29317. cert_no = his.Certno
  29318. }
  29319. var res ResultSeven
  29320. var ahres ResultSevenAH
  29321. var resSeven10265 ResultSeven10265
  29322. var resSeven10265Two ResultSeven10265Two
  29323. var gzresSeven10265Two GZResultSeven10265Two
  29324. if miConfig.MdtrtareaAdmvs == "421300" {
  29325. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29326. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29327. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29328. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29329. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29330. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29331. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29332. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29333. resp, requestErr := http.Get(api)
  29334. if requestErr != nil {
  29335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29336. return
  29337. }
  29338. body, ioErr := ioutil.ReadAll(resp.Body)
  29339. if ioErr != nil {
  29340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29342. return
  29343. }
  29344. var respJSON map[string]interface{}
  29345. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29348. return
  29349. }
  29350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29351. result, _ := json.Marshal(respJSON)
  29352. fmt.Println("log")
  29353. fmt.Println(string(result))
  29354. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29355. utils.ErrorLog("解析失败:%v", err)
  29356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29357. return
  29358. }
  29359. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29360. if reg_type == 11 && his.Insutype == "390" {
  29361. reg_type = 110104
  29362. }
  29363. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29364. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29365. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29366. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29367. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29368. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29369. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29370. resp, requestErr := http.Get(api)
  29371. if requestErr != nil {
  29372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29373. return
  29374. }
  29375. body, ioErr := ioutil.ReadAll(resp.Body)
  29376. if ioErr != nil {
  29377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29379. return
  29380. }
  29381. var respJSON map[string]interface{}
  29382. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29385. return
  29386. }
  29387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29388. result, _ := json.Marshal(respJSON)
  29389. fmt.Println("log")
  29390. fmt.Println(string(result))
  29391. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29392. utils.ErrorLog("解析失败:%v", err)
  29393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29394. return
  29395. }
  29396. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29397. if reg_type == 11 && his.Insutype == "390" {
  29398. reg_type = 110104
  29399. }
  29400. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29401. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29402. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29403. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29404. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29405. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29406. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29407. resp, requestErr := http.Get(api)
  29408. if requestErr != nil {
  29409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29410. return
  29411. }
  29412. body, ioErr := ioutil.ReadAll(resp.Body)
  29413. if ioErr != nil {
  29414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29416. return
  29417. }
  29418. var respJSON map[string]interface{}
  29419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29422. return
  29423. }
  29424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29425. result, _ := json.Marshal(respJSON)
  29426. fmt.Println("log")
  29427. fmt.Println(string(result))
  29428. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29429. utils.ErrorLog("解析失败:%v", err)
  29430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29431. return
  29432. }
  29433. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29434. if reg_type == 11 && his.Insutype == "390" {
  29435. reg_type = 110104
  29436. }
  29437. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29438. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29439. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29440. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29441. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29442. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29443. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29444. resp, requestErr := http.Get(api)
  29445. if requestErr != nil {
  29446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29447. return
  29448. }
  29449. body, ioErr := ioutil.ReadAll(resp.Body)
  29450. if ioErr != nil {
  29451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29453. return
  29454. }
  29455. var respJSON map[string]interface{}
  29456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29459. return
  29460. }
  29461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29462. result, _ := json.Marshal(respJSON)
  29463. fmt.Println("log")
  29464. fmt.Println(string(result))
  29465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29466. utils.ErrorLog("解析失败:%v", err)
  29467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29468. return
  29469. }
  29470. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29471. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29472. if result3101.Infcode == "0" {
  29473. if len(result3101.Output.Result) > 0 {
  29474. var errMsgs []string
  29475. for _, item := range result3101.Output.Result {
  29476. errMsgs = append(errMsgs, item.VolaCont)
  29477. }
  29478. c.ServeSuccessJSON(map[string]interface{}{
  29479. "failed_code": -10,
  29480. "msg": errMsgs,
  29481. })
  29482. return
  29483. } else {
  29484. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29485. if his.IdCardType != 4 {
  29486. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29487. bas := strings.Split(psn_info.CardInfo, "|")
  29488. if his.IdCardType == 1 {
  29489. cert_no = bas[2]
  29490. } else {
  29491. cert_no = bas[1]
  29492. }
  29493. } else {
  29494. cert_no = his.Certno
  29495. }
  29496. //江苏地区国家医保医疗类别
  29497. //职工透析:医疗类别选特殊情况门诊9933
  29498. //居民血透门慢: 医疗类别选门诊慢病1402
  29499. //var med_type string
  29500. //if his.Insutype == "310" {
  29501. // if reg_type == 14 {
  29502. // med_type = "9933"
  29503. // } else if reg_type == 11 {
  29504. // med_type = "11"
  29505. //
  29506. // }
  29507. //} else if his.Insutype == "390" {
  29508. // if reg_type == 14 {
  29509. // med_type = "1402"
  29510. // } else if reg_type == 11 {
  29511. // med_type = "11"
  29512. // }
  29513. //}
  29514. var api string
  29515. if miConfig.MdtrtareaAdmvs == "320921" {
  29516. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29517. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29518. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29519. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29520. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29521. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29522. "&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
  29523. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29524. } else {
  29525. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29526. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29527. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29528. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29529. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29530. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29531. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29532. "&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
  29533. }
  29534. resp, requestErr := http.Get(api)
  29535. if requestErr != nil {
  29536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29537. return
  29538. }
  29539. body, ioErr := ioutil.ReadAll(resp.Body)
  29540. if ioErr != nil {
  29541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29543. return
  29544. }
  29545. var respJSON map[string]interface{}
  29546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29549. return
  29550. }
  29551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29552. result, _ := json.Marshal(respJSON)
  29553. fmt.Println("log")
  29554. fmt.Println(string(result))
  29555. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29556. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29557. utils.ErrorLog("解析失败:%v", err)
  29558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29559. return
  29560. }
  29561. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29562. res.Output = resSeven10265.Output
  29563. res.ErrMsg = resSeven10265.ErrMsg
  29564. res.Cainfo = resSeven10265.Cainfo
  29565. res.WarnMsg = resSeven10265.WarnMsg
  29566. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29567. res.Infcode = infocode
  29568. } else {
  29569. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29570. utils.ErrorLog("解析失败:%v", err)
  29571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29572. return
  29573. }
  29574. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29575. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29576. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29577. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29578. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29579. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29580. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29581. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29582. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29583. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29584. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29585. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29586. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29587. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29588. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29589. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29590. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29591. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29592. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29593. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29594. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29595. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29596. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29597. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29598. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29599. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29600. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29601. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29602. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29603. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29604. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29605. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29606. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29607. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29608. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29609. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29610. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29611. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29612. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29613. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29614. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29615. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29616. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29617. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29618. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29619. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29620. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29621. res.ErrMsg = resSeven10265Two.ErrMsg
  29622. res.Cainfo = resSeven10265Two.Cainfo
  29623. res.WarnMsg = resSeven10265Two.WarnMsg
  29624. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29625. res.Infcode = infocode
  29626. }
  29627. }
  29628. }
  29629. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29630. psn_info, _ := service.GetPsnByPatientId(id)
  29631. var verify_number string
  29632. if psn_info.IdCardType == 4 {
  29633. verify_number = psn_info.VerifyNumber
  29634. } else if psn_info.IdCardType == 1 {
  29635. bas := strings.Split(psn_info.CardInfo, "|")
  29636. cardNumber := bas[2]
  29637. verify_number = cardNumber
  29638. } else {
  29639. psn_info.IdCardType = 2
  29640. verify_number = psn_info.Certno
  29641. }
  29642. var api string
  29643. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29644. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29645. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29647. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29648. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29649. "&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
  29650. resp, requestErr := http.Get(api)
  29651. if requestErr != nil {
  29652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29653. return
  29654. }
  29655. body, ioErr := ioutil.ReadAll(resp.Body)
  29656. if ioErr != nil {
  29657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29659. return
  29660. }
  29661. var respJSON map[string]interface{}
  29662. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29665. return
  29666. }
  29667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29668. result, _ := json.Marshal(respJSON)
  29669. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29670. utils.ErrorLog("解析失败:%v", err)
  29671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29672. return
  29673. }
  29674. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29675. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29676. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29677. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29678. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29679. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29680. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29681. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29682. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29683. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29684. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29685. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29686. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29687. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29688. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29689. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29690. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29691. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29692. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29693. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  29694. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29695. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  29696. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  29697. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  29698. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  29699. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  29700. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  29701. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  29702. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  29703. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  29704. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  29705. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  29706. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  29707. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  29708. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29709. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  29710. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  29711. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  29712. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  29713. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  29714. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  29715. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  29716. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  29717. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  29718. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  29719. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  29720. res.ErrMsg = resSeven10265.ErrMsg
  29721. res.Cainfo = resSeven10265.Cainfo
  29722. res.WarnMsg = resSeven10265.WarnMsg
  29723. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29724. res.Infcode = infocode
  29725. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29726. acct_used_flag := "1"
  29727. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  29728. var result string
  29729. var request_log string
  29730. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  29731. 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)
  29732. } else {
  29733. 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)
  29734. }
  29735. var dat map[string]interface{}
  29736. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29737. fmt.Println(dat)
  29738. } else {
  29739. fmt.Println(err)
  29740. }
  29741. saveLog(result, request_log, "2206", "预结算")
  29742. userJSONBytes, _ := json.Marshal(dat)
  29743. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29744. utils.ErrorLog("解析失败:%v", err)
  29745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29746. return
  29747. }
  29748. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29749. var result string
  29750. var request_log string
  29751. if his.IdCardType == 2 {
  29752. 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, "")
  29753. } else if his.IdCardType == 1 {
  29754. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29755. bas := strings.Split(psn_info.CardInfo, "|")
  29756. basNumber := bas[2]
  29757. card_sn := bas[3]
  29758. var rf []*ResultFive
  29759. json.Unmarshal([]byte(his.Iinfo), &rf)
  29760. var psn_type string
  29761. for _, item := range rf {
  29762. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29763. psn_type = item.PsnType
  29764. }
  29765. }
  29766. 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)
  29767. } else {
  29768. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29769. //bas := strings.Split(psn_info.CardInfo, "|")
  29770. //basNumber := bas[2]
  29771. //card_sn := bas[3]
  29772. var rf []*ResultFive
  29773. json.Unmarshal([]byte(his.Iinfo), &rf)
  29774. var psn_type string
  29775. for _, item := range rf {
  29776. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29777. psn_type = item.PsnType
  29778. }
  29779. }
  29780. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29781. 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)
  29782. }
  29783. var dat map[string]interface{}
  29784. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29785. fmt.Println(dat)
  29786. } else {
  29787. fmt.Println(err)
  29788. }
  29789. saveLog(result, request_log, "2206", "预结算")
  29790. userJSONBytes, _ := json.Marshal(dat)
  29791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29792. utils.ErrorLog("解析失败:%v", err)
  29793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29794. return
  29795. }
  29796. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29797. var result string
  29798. var request_log string
  29799. if his.IdCardType == 2 {
  29800. 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, "")
  29801. } else if his.IdCardType == 1 {
  29802. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29803. bas := strings.Split(psn_info.CardInfo, "|")
  29804. basNumber := bas[0]
  29805. card_sn := ""
  29806. var rf []*ResultFive
  29807. json.Unmarshal([]byte(his.Iinfo), &rf)
  29808. var psn_type string
  29809. for _, item := range rf {
  29810. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29811. psn_type = item.PsnType
  29812. }
  29813. }
  29814. 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)
  29815. } else {
  29816. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29817. //bas := strings.Split(psn_info.CardInfo, "|")
  29818. //basNumber := bas[2]
  29819. //card_sn := bas[3]
  29820. var rf []*ResultFive
  29821. json.Unmarshal([]byte(his.Iinfo), &rf)
  29822. var psn_type string
  29823. for _, item := range rf {
  29824. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29825. psn_type = item.PsnType
  29826. }
  29827. }
  29828. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29829. 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)
  29830. }
  29831. var dat map[string]interface{}
  29832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29833. fmt.Println(dat)
  29834. } else {
  29835. fmt.Println(err)
  29836. }
  29837. saveLog(result, request_log, "2206", "预结算")
  29838. userJSONBytes, _ := json.Marshal(dat)
  29839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29840. utils.ErrorLog("解析失败:%v", err)
  29841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29842. return
  29843. }
  29844. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29845. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29846. if his.IdCardType == 4 {
  29847. psn_info.VerifyNumber = psn_info.VerifyNumber
  29848. cert_no = psn_info.VerifyNumber
  29849. } else if his.IdCardType == 2 {
  29850. cert_no = psn_info.Certno
  29851. psn_info.VerifyNumber = psn_info.Certno
  29852. } else {
  29853. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29854. bas := strings.Split(psn_info.CardInfo, "|")
  29855. if his.IdCardType == 1 {
  29856. cert_no = bas[2]
  29857. } else {
  29858. cert_no = bas[1]
  29859. }
  29860. }
  29861. var api string
  29862. var med_type string
  29863. if his.Insutype == "390" {
  29864. if reg_type == 992102 {
  29865. med_type = "992102"
  29866. }
  29867. if reg_type == 140104 {
  29868. med_type = "140104"
  29869. }
  29870. if reg_type == 140201 {
  29871. med_type = "140201"
  29872. }
  29873. if reg_type == 14 {
  29874. med_type = "140104"
  29875. }
  29876. } else if his.Insutype == "310" {
  29877. if reg_type == 992102 {
  29878. med_type = "992102"
  29879. }
  29880. if reg_type == 140104 {
  29881. med_type = "140104"
  29882. }
  29883. if reg_type == 140201 {
  29884. med_type = "140201"
  29885. }
  29886. if reg_type == 14 {
  29887. med_type = "140104"
  29888. }
  29889. }
  29890. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29891. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29892. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29893. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29894. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29895. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29896. "&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
  29897. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29898. resp, requestErr := http.Get(api)
  29899. if requestErr != nil {
  29900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29901. return
  29902. }
  29903. body, ioErr := ioutil.ReadAll(resp.Body)
  29904. if ioErr != nil {
  29905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29907. return
  29908. }
  29909. var respJSON map[string]interface{}
  29910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29913. return
  29914. }
  29915. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29916. if status == "0" {
  29917. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29918. c.ServeSuccessJSON(map[string]interface{}{
  29919. "failed_code": -10,
  29920. "msg": err_msg,
  29921. })
  29922. return
  29923. }
  29924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29925. result, _ := json.Marshal(respJSON)
  29926. fmt.Println("log")
  29927. fmt.Println(string(result))
  29928. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  29929. utils.ErrorLog("解析失败:%v", err)
  29930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29931. return
  29932. }
  29933. res.InfRefmsgid = ahres.InfRefmsgid
  29934. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29935. // 创建对应的Time类型
  29936. t := time.UnixMilli(timestamp)
  29937. // 格式化成指定的日期字符串
  29938. str := t.Format("2006-01-02 15:04:05")
  29939. res.Output.Setlinfo.SetlTime = str
  29940. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29941. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29942. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29943. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29944. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29945. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29946. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29947. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29948. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29949. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  29950. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29951. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29952. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29953. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29954. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29955. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29956. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29957. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29958. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29959. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29960. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29961. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29962. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29963. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29964. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29965. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29966. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29967. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29968. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29969. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29970. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29971. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29972. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29973. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29974. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29975. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29976. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29977. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29978. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29979. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29980. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29981. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29982. //res.Output.Setldetail = ahres.Output.Setldetail
  29983. res.ErrMsg = ahres.ErrMsg
  29984. res.Cainfo = ahres.Cainfo
  29985. res.WarnMsg = ahres.WarnMsg
  29986. res.Infcode = ahres.Infcode
  29987. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29988. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29989. if his.IdCardType == 4 {
  29990. psn_info.VerifyNumber = psn_info.VerifyNumber
  29991. cert_no = psn_info.Certno
  29992. } else if his.IdCardType == 2 {
  29993. cert_no = psn_info.Certno
  29994. psn_info.VerifyNumber = psn_info.Certno
  29995. } else {
  29996. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29997. bas := strings.Split(psn_info.CardInfo, "|")
  29998. if his.IdCardType == 1 {
  29999. cert_no = bas[2]
  30000. } else {
  30001. cert_no = bas[1]
  30002. }
  30003. }
  30004. var api string
  30005. var med_type string
  30006. if his.Insutype == "390" {
  30007. if reg_type == 992102 {
  30008. med_type = "992102"
  30009. }
  30010. if reg_type == 140104 {
  30011. med_type = "140104"
  30012. }
  30013. if reg_type == 140201 {
  30014. med_type = "140201"
  30015. }
  30016. if reg_type == 14 {
  30017. med_type = "14"
  30018. }
  30019. } else if his.Insutype == "310" {
  30020. if reg_type == 992102 {
  30021. med_type = "992102"
  30022. }
  30023. if reg_type == 140104 {
  30024. med_type = "140104"
  30025. }
  30026. if reg_type == 140201 {
  30027. med_type = "140201"
  30028. }
  30029. if reg_type == 14 {
  30030. med_type = "14"
  30031. }
  30032. }
  30033. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30034. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30035. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30036. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30037. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30038. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30039. "&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
  30040. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30041. resp, requestErr := http.Get(api)
  30042. if requestErr != nil {
  30043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30044. return
  30045. }
  30046. body, ioErr := ioutil.ReadAll(resp.Body)
  30047. if ioErr != nil {
  30048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30050. return
  30051. }
  30052. var respJSON map[string]interface{}
  30053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30056. return
  30057. }
  30058. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30059. if status == "0" {
  30060. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30061. c.ServeSuccessJSON(map[string]interface{}{
  30062. "failed_code": -10,
  30063. "msg": err_msg,
  30064. })
  30065. return
  30066. }
  30067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30068. result, _ := json.Marshal(respJSON)
  30069. fmt.Println("log")
  30070. fmt.Println(string(result))
  30071. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30072. utils.ErrorLog("解析失败:%v", err)
  30073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30074. return
  30075. }
  30076. res.InfRefmsgid = ahres.InfRefmsgid
  30077. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30078. // 创建对应的Time类型
  30079. t := time.UnixMilli(timestamp)
  30080. // 格式化成指定的日期字符串
  30081. str := t.Format("2006-01-02 15:04:05")
  30082. res.Output.Setlinfo.SetlTime = str
  30083. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30084. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30085. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30086. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30087. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30088. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30089. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30090. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30091. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30092. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30093. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30094. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30095. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30096. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30097. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30098. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30099. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30100. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30101. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30102. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30103. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30104. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30105. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30106. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30107. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30108. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30109. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30110. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30111. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30112. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30113. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30114. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30115. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30116. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30117. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30118. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30119. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30120. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30121. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30122. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30123. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30124. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30125. //res.Output.Setldetail = ahres.Output.Setldetail
  30126. res.ErrMsg = ahres.ErrMsg
  30127. res.Cainfo = ahres.Cainfo
  30128. res.WarnMsg = ahres.WarnMsg
  30129. res.Infcode = ahres.Infcode
  30130. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30131. var result string
  30132. var request_log string
  30133. if his.IdCardType == 2 {
  30134. 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")
  30135. } else if his.IdCardType == 1 {
  30136. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30137. bas := strings.Split(psn_info.CardInfo, "|")
  30138. basNumber := bas[2]
  30139. card_sn := bas[3]
  30140. 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")
  30141. } else {
  30142. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30143. 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")
  30144. }
  30145. var dat map[string]interface{}
  30146. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30147. fmt.Println(dat)
  30148. } else {
  30149. fmt.Println(err)
  30150. }
  30151. saveLog(result, request_log, "2206", "预结算")
  30152. userJSONBytes, _ := json.Marshal(dat)
  30153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30154. utils.ErrorLog("解析失败:%v", err)
  30155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30156. return
  30157. }
  30158. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30159. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30160. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30161. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30162. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30163. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30164. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30165. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30166. resp, requestErr := http.Get(api)
  30167. if requestErr != nil {
  30168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30169. return
  30170. }
  30171. body, ioErr := ioutil.ReadAll(resp.Body)
  30172. if ioErr != nil {
  30173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30175. return
  30176. }
  30177. var respJSON map[string]interface{}
  30178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30181. return
  30182. }
  30183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30184. result, _ := json.Marshal(respJSON)
  30185. fmt.Println("log")
  30186. fmt.Println(string(result))
  30187. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30188. utils.ErrorLog("解析失败:%v", err)
  30189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30190. return
  30191. }
  30192. } else {
  30193. if miConfig.MdtrtareaAdmvs == "441202" {
  30194. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30195. if result3101.Infcode == 0 {
  30196. if len(result3101.Output.Result) > 0 {
  30197. var errMsgs []string
  30198. for _, item := range result3101.Output.Result {
  30199. errMsgs = append(errMsgs, item.VolaCont)
  30200. }
  30201. c.ServeSuccessJSON(map[string]interface{}{
  30202. "failed_code": -10,
  30203. "msg": errMsgs,
  30204. })
  30205. return
  30206. } else {
  30207. var result string
  30208. var request_log string
  30209. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30210. allTotal = fmt.Sprintf("%.2f", total_two)
  30211. if his.IdCardType == 4 {
  30212. 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)
  30213. } else {
  30214. 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)
  30215. }
  30216. var dat map[string]interface{}
  30217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30218. fmt.Println(dat)
  30219. } else {
  30220. fmt.Println(err)
  30221. }
  30222. saveLog(result, request_log, "2206", "预结算")
  30223. //userJSONBytes, _ := json.Marshal(dat)
  30224. //
  30225. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30226. // utils.ErrorLog("解析失败:%v", err)
  30227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30228. // return
  30229. //}
  30230. userJSONBytes, _ := json.Marshal(dat)
  30231. if miConfig.Code == "H15049901371" {
  30232. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30233. utils.ErrorLog("解析失败:%v", err)
  30234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30235. return
  30236. }
  30237. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30238. res.Output = resSeven10265.Output
  30239. res.ErrMsg = resSeven10265.ErrMsg
  30240. res.Cainfo = resSeven10265.Cainfo
  30241. res.WarnMsg = resSeven10265.WarnMsg
  30242. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30243. res.Infcode = infocode
  30244. } else {
  30245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30246. utils.ErrorLog("解析失败:%v", err)
  30247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30248. return
  30249. }
  30250. }
  30251. }
  30252. } else {
  30253. c.ServeSuccessJSON(map[string]interface{}{
  30254. "failed_code": -10,
  30255. "msg": result3101.ErrMsg,
  30256. })
  30257. return
  30258. }
  30259. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30260. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30261. if result3101.Infcode == 0 {
  30262. if len(result3101.Output.Result) > 0 {
  30263. var errMsgs []string
  30264. for _, item := range result3101.Output.Result {
  30265. errMsgs = append(errMsgs, item.VolaCont)
  30266. }
  30267. c.ServeSuccessJSON(map[string]interface{}{
  30268. "failed_code": -10,
  30269. "msg": errMsgs,
  30270. })
  30271. return
  30272. } else {
  30273. var result string
  30274. var request_log string
  30275. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30276. allTotal = fmt.Sprintf("%.2f", total_two)
  30277. if his.IdCardType == 4 {
  30278. 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)
  30279. } else {
  30280. 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)
  30281. }
  30282. var dat map[string]interface{}
  30283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30284. fmt.Println(dat)
  30285. } else {
  30286. fmt.Println(err)
  30287. }
  30288. saveLog(result, request_log, "2206", "预结算")
  30289. //userJSONBytes, _ := json.Marshal(dat)
  30290. //
  30291. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30292. // utils.ErrorLog("解析失败:%v", err)
  30293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30294. // return
  30295. //}
  30296. userJSONBytes, _ := json.Marshal(dat)
  30297. if miConfig.Code == "H15049901371" {
  30298. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30299. utils.ErrorLog("解析失败:%v", err)
  30300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30301. return
  30302. }
  30303. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30304. res.Output = resSeven10265.Output
  30305. res.ErrMsg = resSeven10265.ErrMsg
  30306. res.Cainfo = resSeven10265.Cainfo
  30307. res.WarnMsg = resSeven10265.WarnMsg
  30308. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30309. res.Infcode = infocode
  30310. } else {
  30311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30312. utils.ErrorLog("解析失败:%v", err)
  30313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30314. return
  30315. }
  30316. }
  30317. }
  30318. } else {
  30319. c.ServeSuccessJSON(map[string]interface{}{
  30320. "failed_code": -10,
  30321. "msg": result3101.ErrMsg,
  30322. })
  30323. return
  30324. }
  30325. } else {
  30326. var result string
  30327. var request_log string
  30328. var dat map[string]interface{}
  30329. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30330. allTotal = fmt.Sprintf("%.2f", total_two)
  30331. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30332. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30333. if result3101.Infcode == 0 {
  30334. if len(result3101.Output.Result) > 0 {
  30335. var errMsgs []string
  30336. for _, item := range result3101.Output.Result {
  30337. errMsgs = append(errMsgs, item.VolaCont)
  30338. }
  30339. c.ServeSuccessJSON(map[string]interface{}{
  30340. "failed_code": -10,
  30341. "msg": errMsgs,
  30342. })
  30343. return
  30344. } else {
  30345. var result string
  30346. var request_log string
  30347. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30348. allTotal = fmt.Sprintf("%.2f", total_two)
  30349. if his.IdCardType == 4 {
  30350. 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)
  30351. } else {
  30352. 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)
  30353. }
  30354. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30355. fmt.Println(dat)
  30356. } else {
  30357. fmt.Println(err)
  30358. }
  30359. saveLog(result, request_log, "2206", "预结算")
  30360. }
  30361. } else {
  30362. c.ServeSuccessJSON(map[string]interface{}{
  30363. "failed_code": -10,
  30364. "msg": result3101.ErrMsg,
  30365. })
  30366. return
  30367. }
  30368. } else {
  30369. if his.IdCardType == 4 {
  30370. 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)
  30371. } else {
  30372. 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)
  30373. }
  30374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30375. fmt.Println(dat)
  30376. } else {
  30377. fmt.Println(err)
  30378. }
  30379. saveLog(result, request_log, "2206", "预结算")
  30380. }
  30381. //userJSONBytes, _ := json.Marshal(dat)
  30382. //
  30383. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30384. // utils.ErrorLog("解析失败:%v", err)
  30385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30386. // return
  30387. //}
  30388. userJSONBytes, _ := json.Marshal(dat)
  30389. if miConfig.Code == "H15049901371" {
  30390. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30391. utils.ErrorLog("解析失败:%v", err)
  30392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30393. return
  30394. }
  30395. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30396. res.Output = resSeven10265.Output
  30397. res.ErrMsg = resSeven10265.ErrMsg
  30398. res.Cainfo = resSeven10265.Cainfo
  30399. res.WarnMsg = resSeven10265.WarnMsg
  30400. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30401. res.Infcode = infocode
  30402. } else {
  30403. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30404. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30405. utils.ErrorLog("解析失败:%v", err)
  30406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30407. return
  30408. }
  30409. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30410. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30411. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30412. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30413. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30414. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30415. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30416. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30417. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30418. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30419. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30420. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30421. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30422. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30423. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30424. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30425. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30426. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30427. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30428. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30429. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30430. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30431. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30432. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30433. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30434. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30435. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30436. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30437. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30438. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30439. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30440. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30441. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30442. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30443. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30444. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30445. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30446. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30447. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30448. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30449. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30450. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30451. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30452. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30453. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30454. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30455. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30456. res.Cainfo = gzresSeven10265Two.Cainfo
  30457. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30458. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30459. //res.Infcode = infocode
  30460. } else {
  30461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30462. utils.ErrorLog("解析失败:%v", err)
  30463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30464. return
  30465. }
  30466. }
  30467. }
  30468. }
  30469. }
  30470. utils.ErrorLog("解析失败:%v", res.Infcode)
  30471. if res.Infcode == -1 {
  30472. errlog := &models.HisOrderError{
  30473. UserOrgId: adminUser.CurrentOrgId,
  30474. Ctime: time.Now().Unix(),
  30475. Mtime: time.Now().Unix(),
  30476. Number: chrg_bchno,
  30477. ErrMsg: res.ErrMsg,
  30478. Status: 1,
  30479. PatientId: id,
  30480. RecordTime: recordDateTime,
  30481. Stage: 20,
  30482. }
  30483. service.CreateErrMsgLog(errlog)
  30484. c.ServeSuccessJSON(map[string]interface{}{
  30485. "failed_code": -10,
  30486. "msg": res.ErrMsg,
  30487. })
  30488. return
  30489. }
  30490. if res.Infcode != 0 {
  30491. errlog := &models.HisOrderError{
  30492. UserOrgId: adminUser.CurrentOrgId,
  30493. Ctime: time.Now().Unix(),
  30494. Mtime: time.Now().Unix(),
  30495. Number: chrg_bchno,
  30496. ErrMsg: res.ErrMsg,
  30497. Status: 1,
  30498. PatientId: id,
  30499. RecordTime: recordDateTime,
  30500. Stage: 20,
  30501. }
  30502. service.CreateErrMsgLog(errlog)
  30503. c.ServeSuccessJSON(map[string]interface{}{
  30504. "failed_code": -10,
  30505. "msg": res.ErrMsg,
  30506. })
  30507. return
  30508. } else {
  30509. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30510. order.OrderStatus = 1
  30511. order.IsPre = 1
  30512. order.Status = 1
  30513. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30514. order.SetlId = res.Output.Setlinfo.SetlID
  30515. order.PsnNo = res.Output.Setlinfo.PsnNo
  30516. order.PsnName = res.Output.Setlinfo.PsnName
  30517. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30518. order.Certno = res.Output.Setlinfo.Certno
  30519. order.Gend = res.Output.Setlinfo.Gend
  30520. order.Naty = res.Output.Setlinfo.Naty
  30521. order.Age = res.Output.Setlinfo.Age
  30522. order.Insutype = res.Output.Setlinfo.Insutype
  30523. order.PsnType = res.Output.Setlinfo.PsnType
  30524. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30525. order.SetlTime = res.Output.Setlinfo.SetlTime
  30526. order.AcctUsedFlag = acct_used_flag
  30527. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30528. if res.Output.Setlinfo.MedType == "140101" {
  30529. order.MedType = "14"
  30530. } else {
  30531. if res.Output.Setlinfo.MedType == "110104" {
  30532. order.MedType = "11"
  30533. } else {
  30534. order.MedType = res.Output.Setlinfo.MedType
  30535. }
  30536. }
  30537. if res.Output.Setlinfo.MedType == "992102" {
  30538. order.MedType = "992102"
  30539. }
  30540. if res.Output.Setlinfo.MedType == "140104" {
  30541. order.MedType = "140104"
  30542. }
  30543. if res.Output.Setlinfo.MedType == "140201" {
  30544. order.MedType = "140201"
  30545. }
  30546. if res.Output.Setlinfo.MedType == "14" {
  30547. order.MedType = "14"
  30548. }
  30549. if reg_type == 1112 {
  30550. order.MedType = "1112"
  30551. }
  30552. if reg_type == 1111 {
  30553. order.MedType = "1111"
  30554. }
  30555. order.ClrType = res.Output.Setlinfo.ClrType
  30556. if adminUser.CurrentOrgId == 10480 {
  30557. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30558. order.ClrType = "11"
  30559. } else {
  30560. order.ClrType = "9903"
  30561. }
  30562. }
  30563. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30564. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30565. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30566. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30567. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30568. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30569. order.HifpPay = res.Output.Setlinfo.HifpPay
  30570. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30571. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30572. order.HifesPay = res.Output.Setlinfo.HifesPay
  30573. order.HifobPay = res.Output.Setlinfo.HifobPay
  30574. order.MafPay = res.Output.Setlinfo.MafPay
  30575. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30576. order.OthPay = res.Output.Setlinfo.OthPay
  30577. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30578. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30579. order.AcctPay = res.Output.Setlinfo.AcctPay
  30580. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30581. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30582. order.Balc = res.Output.Setlinfo.Balc
  30583. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30584. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30585. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30586. order.ClrWay = res.Output.Setlinfo.ClrWay
  30587. order.Creator = order.Creator
  30588. order.Modify = roles.AdminUserId
  30589. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30590. //detailStr := string(setlDetail)
  30591. //order.SetlDetail = detailStr
  30592. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30593. err = service.UpDateOrder(order)
  30594. if err == nil {
  30595. c.ServeSuccessJSON(map[string]interface{}{
  30596. "msg": "预结算成功",
  30597. })
  30598. } else {
  30599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30600. return
  30601. }
  30602. }
  30603. } else {
  30604. adminUser := c.GetAdminUserInfo()
  30605. errlog := &models.HisOrderError{
  30606. UserOrgId: adminUser.CurrentOrgId,
  30607. Ctime: time.Now().Unix(),
  30608. Mtime: time.Now().Unix(),
  30609. ErrMsg: res.ErrMsg,
  30610. Status: 1,
  30611. PatientId: id,
  30612. RecordTime: recordDateTime,
  30613. Stage: 4,
  30614. }
  30615. service.CreateErrMsgLog(errlog)
  30616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30617. return
  30618. }
  30619. } else {
  30620. if miConfig.MdtrtareaAdmvs == "150499" {
  30621. order := &models.HisOrder{
  30622. UserOrgId: adminUser.CurrentOrgId,
  30623. HisPatientId: his.ID,
  30624. PatientId: his.PatientId,
  30625. SettleAccountsDate: recordDateTime,
  30626. Ctime: time.Now().Unix(),
  30627. Mtime: time.Now().Unix(),
  30628. MdtrtId: his.Number,
  30629. PsnNo: his.PsnNo,
  30630. MedType: strconv.FormatInt(reg_type, 10),
  30631. Status: 1,
  30632. Number: chrg_bchno,
  30633. Infcode: res.Infcode,
  30634. WarnMsg: res.WarnMsg,
  30635. Cainfo: res.Cainfo,
  30636. ErrMsg: res.ErrMsg,
  30637. RespondTime: res.RefmsgTime,
  30638. InfRefmsgid: res.InfRefmsgid,
  30639. OrderStatus: 1,
  30640. IsMedicineInsurance: 1,
  30641. SettleType: settle_accounts_type,
  30642. SettleStartTime: start_time,
  30643. SettleEndTime: end_time,
  30644. Creator: roles.AdminUserId,
  30645. Modify: roles.AdminUserId,
  30646. PType: 2,
  30647. Diagnosis: diagnosis_id,
  30648. }
  30649. err = service.CreateOrder(order)
  30650. if err != nil {
  30651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30652. return
  30653. }
  30654. }
  30655. adminUser := c.GetAdminUserInfo()
  30656. errlog := &models.HisOrderError{
  30657. UserOrgId: adminUser.CurrentOrgId,
  30658. Ctime: time.Now().Unix(),
  30659. Mtime: time.Now().Unix(),
  30660. ErrMsg: res.ErrMsg,
  30661. Status: 1,
  30662. PatientId: id,
  30663. RecordTime: recordDateTime,
  30664. Stage: 4,
  30665. }
  30666. service.CreateErrMsgLog(errlog)
  30667. c.ServeSuccessJSON(map[string]interface{}{
  30668. "failed_code": -10,
  30669. "msg": res.ErrMsg,
  30670. })
  30671. return
  30672. }
  30673. }
  30674. }
  30675. }
  30676. // 退款
  30677. func (c *HisApiController) Refund() {
  30678. order_id, _ := c.GetInt64("order_id")
  30679. admin_user_id, _ := c.GetInt64("admin_user_id")
  30680. adminUser := c.GetAdminUserInfo()
  30681. var order models.HisOrder
  30682. order, _ = service.GetHisOrderByID(order_id)
  30683. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  30684. if fapiao.ID > 0 {
  30685. c.ServeSuccessJSON(map[string]interface{}{
  30686. "failed_code": -10,
  30687. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  30688. })
  30689. return
  30690. }
  30691. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30692. if order.ID == 0 {
  30693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30694. return
  30695. }
  30696. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30697. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30698. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30699. if config.IsOpen == 1 { //对接了医保,走医保流程
  30700. var res ResultSixteen
  30701. var ahres ResultSevenAH
  30702. var resSixteen10265 ResultSixteen10265
  30703. var resSixteen10265Two ResultSixteen10265Two
  30704. var gz ResultgzSixteen10265Two
  30705. var src_resquest string
  30706. var result string
  30707. if miConfig.MdtrtareaAdmvs == "421300" {
  30708. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30709. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30710. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30711. resp3, requestErr3 := http.Get(api3)
  30712. if requestErr3 != nil {
  30713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30714. return
  30715. }
  30716. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30717. if ioErr3 != nil {
  30718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30720. return
  30721. }
  30722. var respJSON3 map[string]interface{}
  30723. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30726. return
  30727. }
  30728. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30729. userJSONBytes3, _ := json.Marshal(respJSON3)
  30730. fmt.Println("log")
  30731. fmt.Println(string(userJSONBytes3))
  30732. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30733. utils.ErrorLog("解析失败:%v", err)
  30734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30735. return
  30736. }
  30737. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30738. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30739. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30740. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30741. resp3, requestErr3 := http.Get(api3)
  30742. if requestErr3 != nil {
  30743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30744. return
  30745. }
  30746. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30747. if ioErr3 != nil {
  30748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30750. return
  30751. }
  30752. var respJSON3 map[string]interface{}
  30753. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30756. return
  30757. }
  30758. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30759. userJSONBytes3, _ := json.Marshal(respJSON3)
  30760. fmt.Println("log")
  30761. fmt.Println(string(userJSONBytes3))
  30762. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30763. utils.ErrorLog("解析失败:%v", err)
  30764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30765. return
  30766. }
  30767. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30768. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30769. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30770. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30771. resp3, requestErr3 := http.Get(api3)
  30772. if requestErr3 != nil {
  30773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30774. return
  30775. }
  30776. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30777. if ioErr3 != nil {
  30778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30780. return
  30781. }
  30782. var respJSON3 map[string]interface{}
  30783. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30786. return
  30787. }
  30788. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30789. userJSONBytes3, _ := json.Marshal(respJSON3)
  30790. fmt.Println("log")
  30791. fmt.Println(string(userJSONBytes3))
  30792. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30793. utils.ErrorLog("解析失败:%v", err)
  30794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30795. return
  30796. }
  30797. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30798. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30799. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30800. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30801. resp3, requestErr3 := http.Get(api3)
  30802. if requestErr3 != nil {
  30803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30804. return
  30805. }
  30806. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30807. if ioErr3 != nil {
  30808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30810. return
  30811. }
  30812. var respJSON3 map[string]interface{}
  30813. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30816. return
  30817. }
  30818. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30819. userJSONBytes3, _ := json.Marshal(respJSON3)
  30820. fmt.Println("log")
  30821. fmt.Println(string(userJSONBytes3))
  30822. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30823. utils.ErrorLog("解析失败:%v", err)
  30824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30825. return
  30826. }
  30827. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30828. var api3 string
  30829. if miConfig.MdtrtareaAdmvs == "320921" {
  30830. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  30831. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30832. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30833. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30834. } else {
  30835. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30836. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  30837. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30838. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30839. }
  30840. resp3, requestErr3 := http.Get(api3)
  30841. if requestErr3 != nil {
  30842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30843. return
  30844. }
  30845. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30846. if ioErr3 != nil {
  30847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30849. return
  30850. }
  30851. var respJSON3 map[string]interface{}
  30852. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30855. return
  30856. }
  30857. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30858. userJSONBytes3, _ := json.Marshal(respJSON3)
  30859. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  30860. utils.ErrorLog("解析失败:%v", err)
  30861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30862. return
  30863. }
  30864. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30865. res.Output = resSixteen10265.Output
  30866. res.ErrMsg = resSixteen10265.ErrMsg
  30867. res.Cainfo = resSixteen10265.Cainfo
  30868. res.WarnMsg = resSixteen10265.WarnMsg
  30869. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30870. res.Infcode = infocode
  30871. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30872. var api3 string
  30873. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  30874. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30875. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30876. resp3, requestErr3 := http.Get(api3)
  30877. if requestErr3 != nil {
  30878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30879. return
  30880. }
  30881. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30882. if ioErr3 != nil {
  30883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30885. return
  30886. }
  30887. var respJSON3 map[string]interface{}
  30888. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30891. return
  30892. }
  30893. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30894. userJSONBytes3, _ := json.Marshal(respJSON3)
  30895. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  30896. utils.ErrorLog("解析失败:%v", err)
  30897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30898. return
  30899. }
  30900. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30901. res.Output = resSixteen10265.Output
  30902. res.ErrMsg = resSixteen10265.ErrMsg
  30903. res.Cainfo = resSixteen10265.Cainfo
  30904. res.WarnMsg = resSixteen10265.WarnMsg
  30905. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30906. res.Infcode = infocode
  30907. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30908. 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)
  30909. var dat map[string]interface{}
  30910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30911. fmt.Println(dat)
  30912. } else {
  30913. fmt.Println(err)
  30914. }
  30915. saveLog(result, src_resquest, "2208", "退费")
  30916. userJSONBytes, _ := json.Marshal(dat)
  30917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30918. utils.ErrorLog("解析失败:%v", err)
  30919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30920. return
  30921. }
  30922. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30923. 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, "")
  30924. var dat map[string]interface{}
  30925. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30926. fmt.Println(dat)
  30927. } else {
  30928. fmt.Println(err)
  30929. }
  30930. saveLog(result, src_resquest, "2208", "退费")
  30931. userJSONBytes, _ := json.Marshal(dat)
  30932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30933. utils.ErrorLog("解析失败:%v", err)
  30934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30935. return
  30936. }
  30937. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30938. 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, "")
  30939. var dat map[string]interface{}
  30940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30941. fmt.Println(dat)
  30942. } else {
  30943. fmt.Println(err)
  30944. }
  30945. saveLog(result, src_resquest, "2208", "退费")
  30946. userJSONBytes, _ := json.Marshal(dat)
  30947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30948. utils.ErrorLog("解析失败:%v", err)
  30949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30950. return
  30951. }
  30952. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30953. var api3 string
  30954. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  30955. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30957. resp3, requestErr3 := http.Get(api3)
  30958. if requestErr3 != nil {
  30959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30960. return
  30961. }
  30962. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30963. if ioErr3 != nil {
  30964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30966. return
  30967. }
  30968. var respJSON3 map[string]interface{}
  30969. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30972. return
  30973. }
  30974. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30975. if status == "0" {
  30976. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30977. c.ServeSuccessJSON(map[string]interface{}{
  30978. "failed_code": -10,
  30979. "msg": err_msg,
  30980. })
  30981. return
  30982. }
  30983. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30984. userJSONBytes3, _ := json.Marshal(respJSON3)
  30985. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30986. // utils.ErrorLog("解析失败:%v", err)
  30987. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30988. // return
  30989. //}
  30990. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  30991. utils.ErrorLog("解析失败:%v", err)
  30992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30993. return
  30994. }
  30995. res.InfRefmsgid = ahres.InfRefmsgid
  30996. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30997. // 创建对应的Time类型
  30998. t := time.UnixMilli(timestamp)
  30999. // 格式化成指定的日期字符串
  31000. str := t.Format("2006-01-02 15:04:05")
  31001. res.Output.Setlinfo.SetlTime = str
  31002. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31003. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31004. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31005. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31006. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31007. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31008. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31009. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31010. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31011. //
  31012. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31013. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31014. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31015. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31016. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31017. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31018. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31019. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31020. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31021. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31022. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31023. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31024. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31025. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31026. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31027. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31028. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31029. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31030. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31031. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31032. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31033. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31034. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31035. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31036. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31037. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31038. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31039. //res.Output.Setldetail = ahres.Output.Setldetail
  31040. res.ErrMsg = ahres.ErrMsg
  31041. res.Cainfo = ahres.Cainfo
  31042. res.WarnMsg = ahres.WarnMsg
  31043. res.Infcode = ahres.Infcode
  31044. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31045. var api3 string
  31046. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31047. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31048. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31049. resp3, requestErr3 := http.Get(api3)
  31050. if requestErr3 != nil {
  31051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31052. return
  31053. }
  31054. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31055. if ioErr3 != nil {
  31056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31058. return
  31059. }
  31060. var respJSON3 map[string]interface{}
  31061. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31064. return
  31065. }
  31066. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31067. if status == "0" {
  31068. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31069. c.ServeSuccessJSON(map[string]interface{}{
  31070. "failed_code": -10,
  31071. "msg": err_msg,
  31072. })
  31073. return
  31074. }
  31075. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31076. userJSONBytes3, _ := json.Marshal(respJSON3)
  31077. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31078. // utils.ErrorLog("解析失败:%v", err)
  31079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31080. // return
  31081. //}
  31082. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31083. utils.ErrorLog("解析失败:%v", err)
  31084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31085. return
  31086. }
  31087. res.InfRefmsgid = ahres.InfRefmsgid
  31088. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31089. // 创建对应的Time类型
  31090. t := time.UnixMilli(timestamp)
  31091. // 格式化成指定的日期字符串
  31092. str := t.Format("2006-01-02 15:04:05")
  31093. res.Output.Setlinfo.SetlTime = str
  31094. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31095. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31096. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31097. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31098. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31099. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31100. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31101. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31102. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31103. //
  31104. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31105. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31106. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31107. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31108. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31109. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31110. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31111. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31112. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31113. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31114. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31115. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31116. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31117. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31118. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31119. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31120. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31121. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31122. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31123. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31124. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31125. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31126. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31127. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31128. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31129. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31130. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31131. //res.Output.Setldetail = ahres.Output.Setldetail
  31132. res.ErrMsg = ahres.ErrMsg
  31133. res.Cainfo = ahres.Cainfo
  31134. res.WarnMsg = ahres.WarnMsg
  31135. res.Infcode = ahres.Infcode
  31136. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31137. 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, "")
  31138. var dat map[string]interface{}
  31139. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31140. fmt.Println(dat)
  31141. } else {
  31142. fmt.Println(err)
  31143. }
  31144. saveLog(result, src_resquest, "2208", "退费")
  31145. userJSONBytes, _ := json.Marshal(dat)
  31146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31147. utils.ErrorLog("解析失败:%v", err)
  31148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31149. return
  31150. }
  31151. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31152. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31153. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31154. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31155. resp3, requestErr3 := http.Get(api3)
  31156. if requestErr3 != nil {
  31157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31158. return
  31159. }
  31160. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31161. if ioErr3 != nil {
  31162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31164. return
  31165. }
  31166. var respJSON3 map[string]interface{}
  31167. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31170. return
  31171. }
  31172. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31173. userJSONBytes3, _ := json.Marshal(respJSON3)
  31174. fmt.Println("log")
  31175. fmt.Println(string(userJSONBytes3))
  31176. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31177. utils.ErrorLog("解析失败:%v", err)
  31178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31179. return
  31180. }
  31181. } else {
  31182. if miConfig.Code == "H15049901371" {
  31183. 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)
  31184. var dat map[string]interface{}
  31185. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31186. fmt.Println(dat)
  31187. } else {
  31188. fmt.Println(err)
  31189. }
  31190. saveLog(result, src_resquest, "2208", "退费")
  31191. if strings.Contains(result, "Post") {
  31192. res.Infcode = -1
  31193. res.ErrMsg = result
  31194. }
  31195. userJSONBytes, _ := json.Marshal(dat)
  31196. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31197. utils.ErrorLog("解析失败:%v", err)
  31198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31199. return
  31200. }
  31201. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31202. res.Output = resSixteen10265.Output
  31203. res.ErrMsg = resSixteen10265.ErrMsg
  31204. res.Cainfo = resSixteen10265.Cainfo
  31205. res.WarnMsg = resSixteen10265.WarnMsg
  31206. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31207. res.Infcode = infocode
  31208. } else {
  31209. 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)
  31210. var dat map[string]interface{}
  31211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31212. fmt.Println(dat)
  31213. } else {
  31214. fmt.Println(err)
  31215. }
  31216. saveLog(result, src_resquest, "2208", "退费")
  31217. userJSONBytes, _ := json.Marshal(dat)
  31218. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31219. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31220. utils.ErrorLog("解析失败:%v", err)
  31221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31222. return
  31223. }
  31224. res.Infcode = gz.Infcode
  31225. } else {
  31226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31227. utils.ErrorLog("解析失败:%v", err)
  31228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31229. return
  31230. }
  31231. }
  31232. if strings.Contains(result, "Post") {
  31233. res.Infcode = -1
  31234. res.ErrMsg = result
  31235. }
  31236. }
  31237. }
  31238. if res.Infcode == -1 {
  31239. c.ServeSuccessJSON(map[string]interface{}{
  31240. "failed_code": -10,
  31241. "msg": res.ErrMsg,
  31242. })
  31243. return
  31244. }
  31245. if res.Infcode != -1 {
  31246. var res2 ResultSix
  31247. var resSix10265 ResultSix10265
  31248. if miConfig.MdtrtareaAdmvs == "421300" {
  31249. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31250. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31251. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31252. resp3, requestErr3 := http.Get(api3)
  31253. if requestErr3 != nil {
  31254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31255. return
  31256. }
  31257. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31258. if ioErr3 != nil {
  31259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31261. return
  31262. }
  31263. var respJSON3 map[string]interface{}
  31264. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31267. return
  31268. }
  31269. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31270. userJSONBytes3, _ := json.Marshal(respJSON3)
  31271. fmt.Println("log")
  31272. fmt.Println(string(userJSONBytes3))
  31273. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31274. utils.ErrorLog("解析失败:%v", err)
  31275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31276. return
  31277. }
  31278. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31279. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31280. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31282. resp3, requestErr3 := http.Get(api3)
  31283. if requestErr3 != nil {
  31284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31285. return
  31286. }
  31287. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31288. if ioErr3 != nil {
  31289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31291. return
  31292. }
  31293. var respJSON3 map[string]interface{}
  31294. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31297. return
  31298. }
  31299. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31300. userJSONBytes3, _ := json.Marshal(respJSON3)
  31301. fmt.Println("log")
  31302. fmt.Println(string(userJSONBytes3))
  31303. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31304. utils.ErrorLog("解析失败:%v", err)
  31305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31306. return
  31307. }
  31308. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31309. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31310. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31311. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31312. resp3, requestErr3 := http.Get(api3)
  31313. if requestErr3 != nil {
  31314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31315. return
  31316. }
  31317. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31318. if ioErr3 != nil {
  31319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31321. return
  31322. }
  31323. var respJSON3 map[string]interface{}
  31324. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31327. return
  31328. }
  31329. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31330. userJSONBytes3, _ := json.Marshal(respJSON3)
  31331. fmt.Println("log")
  31332. fmt.Println(string(userJSONBytes3))
  31333. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31334. utils.ErrorLog("解析失败:%v", err)
  31335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31336. return
  31337. }
  31338. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31339. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31340. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31341. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31342. resp3, requestErr3 := http.Get(api3)
  31343. if requestErr3 != nil {
  31344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31345. return
  31346. }
  31347. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31348. if ioErr3 != nil {
  31349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31351. return
  31352. }
  31353. var respJSON3 map[string]interface{}
  31354. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31357. return
  31358. }
  31359. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31360. userJSONBytes3, _ := json.Marshal(respJSON3)
  31361. fmt.Println("log")
  31362. fmt.Println(string(userJSONBytes3))
  31363. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31364. utils.ErrorLog("解析失败:%v", err)
  31365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31366. return
  31367. }
  31368. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31369. var api3 string
  31370. if miConfig.MdtrtareaAdmvs == "320921" {
  31371. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31372. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31373. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31374. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31375. } else {
  31376. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31377. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31378. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31379. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31380. }
  31381. resp3, requestErr3 := http.Get(api3)
  31382. if requestErr3 != nil {
  31383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31384. return
  31385. }
  31386. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31387. if ioErr3 != nil {
  31388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31390. return
  31391. }
  31392. var respJSON3 map[string]interface{}
  31393. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31396. return
  31397. }
  31398. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31399. userJSONBytes3, _ := json.Marshal(respJSON3)
  31400. fmt.Println("log")
  31401. fmt.Println(string(userJSONBytes3))
  31402. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31403. utils.ErrorLog("解析失败:%v", err)
  31404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31405. return
  31406. }
  31407. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31408. res2.Output = resSix10265.Output
  31409. res2.ErrMsg = resSix10265.ErrMsg
  31410. res2.Cainfo = resSix10265.Cainfo
  31411. res2.WarnMsg = resSix10265.WarnMsg
  31412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31413. res2.Infcode = infocode
  31414. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31415. var api3 string
  31416. new_chrg_bchno := order.Number
  31417. if adminUser.CurrentOrgId == 10265 {
  31418. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31419. new_chrg_bchno = "0000"
  31420. }
  31421. }
  31422. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31423. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31424. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31425. resp3, requestErr3 := http.Get(api3)
  31426. if requestErr3 != nil {
  31427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31428. return
  31429. }
  31430. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31431. if ioErr3 != nil {
  31432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31434. return
  31435. }
  31436. var respJSON3 map[string]interface{}
  31437. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31440. return
  31441. }
  31442. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31443. userJSONBytes3, _ := json.Marshal(respJSON3)
  31444. fmt.Println("log")
  31445. fmt.Println(string(userJSONBytes3))
  31446. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31447. utils.ErrorLog("解析失败:%v", err)
  31448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31449. return
  31450. }
  31451. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31452. res2.Output = resSix10265.Output
  31453. res2.ErrMsg = resSix10265.ErrMsg
  31454. res2.Cainfo = resSix10265.Cainfo
  31455. res2.WarnMsg = resSix10265.WarnMsg
  31456. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31457. res2.Infcode = infocode
  31458. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31459. 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)
  31460. var dat map[string]interface{}
  31461. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31462. fmt.Println(dat)
  31463. } else {
  31464. fmt.Println(err)
  31465. }
  31466. saveLog(result2, src_request, "2205", "撤销明细")
  31467. userJSONBytes, _ := json.Marshal(dat)
  31468. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31469. utils.ErrorLog("解析失败:%v", err)
  31470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31471. return
  31472. }
  31473. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31474. 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, "")
  31475. var dat map[string]interface{}
  31476. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31477. fmt.Println(dat)
  31478. } else {
  31479. fmt.Println(err)
  31480. }
  31481. saveLog(result2, src_request, "2205", "撤销明细")
  31482. userJSONBytes, _ := json.Marshal(dat)
  31483. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31484. utils.ErrorLog("解析失败:%v", err)
  31485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31486. return
  31487. }
  31488. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31489. 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, "")
  31490. var dat map[string]interface{}
  31491. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31492. fmt.Println(dat)
  31493. } else {
  31494. fmt.Println(err)
  31495. }
  31496. saveLog(result2, src_request, "2205", "撤销明细")
  31497. userJSONBytes, _ := json.Marshal(dat)
  31498. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31499. utils.ErrorLog("解析失败:%v", err)
  31500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31501. return
  31502. }
  31503. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31504. var api3 string
  31505. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31506. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31507. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31508. resp3, requestErr3 := http.Get(api3)
  31509. if requestErr3 != nil {
  31510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31511. return
  31512. }
  31513. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31514. if ioErr3 != nil {
  31515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31517. return
  31518. }
  31519. var respJSON3 map[string]interface{}
  31520. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31523. return
  31524. }
  31525. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31526. if status == "0" {
  31527. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31528. c.ServeSuccessJSON(map[string]interface{}{
  31529. "failed_code": -10,
  31530. "msg": err_msg,
  31531. })
  31532. return
  31533. }
  31534. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31535. userJSONBytes3, _ := json.Marshal(respJSON3)
  31536. fmt.Println("log")
  31537. fmt.Println(string(userJSONBytes3))
  31538. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31539. utils.ErrorLog("解析失败:%v", err)
  31540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31541. return
  31542. }
  31543. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31544. 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, "")
  31545. var dat map[string]interface{}
  31546. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31547. fmt.Println(dat)
  31548. } else {
  31549. fmt.Println(err)
  31550. }
  31551. saveLog(result2, src_request, "2205", "撤销明细")
  31552. userJSONBytes, _ := json.Marshal(dat)
  31553. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31554. utils.ErrorLog("解析失败:%v", err)
  31555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31556. return
  31557. }
  31558. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31559. 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, "")
  31560. var dat map[string]interface{}
  31561. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31562. fmt.Println(dat)
  31563. } else {
  31564. fmt.Println(err)
  31565. }
  31566. saveLog(result2, src_request, "2205", "撤销明细")
  31567. userJSONBytes, _ := json.Marshal(dat)
  31568. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31569. utils.ErrorLog("解析失败:%v", err)
  31570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31571. return
  31572. }
  31573. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31574. var api3 string
  31575. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31576. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31577. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31578. resp3, requestErr3 := http.Get(api3)
  31579. if requestErr3 != nil {
  31580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31581. return
  31582. }
  31583. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31584. if ioErr3 != nil {
  31585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31587. return
  31588. }
  31589. var respJSON3 map[string]interface{}
  31590. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31593. return
  31594. }
  31595. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31596. if status == "0" {
  31597. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31598. c.ServeSuccessJSON(map[string]interface{}{
  31599. "failed_code": -10,
  31600. "msg": err_msg,
  31601. })
  31602. return
  31603. }
  31604. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31605. userJSONBytes3, _ := json.Marshal(respJSON3)
  31606. fmt.Println("log")
  31607. fmt.Println(string(userJSONBytes3))
  31608. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31609. utils.ErrorLog("解析失败:%v", err)
  31610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31611. return
  31612. }
  31613. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31614. 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, "")
  31615. var dat map[string]interface{}
  31616. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31617. fmt.Println(dat)
  31618. } else {
  31619. fmt.Println(err)
  31620. }
  31621. saveLog(result2, src_request, "2205", "撤销明细")
  31622. userJSONBytes, _ := json.Marshal(dat)
  31623. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31624. utils.ErrorLog("解析失败:%v", err)
  31625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31626. return
  31627. }
  31628. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31629. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31630. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31631. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31632. resp3, requestErr3 := http.Get(api3)
  31633. if requestErr3 != nil {
  31634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31635. return
  31636. }
  31637. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31638. if ioErr3 != nil {
  31639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31641. return
  31642. }
  31643. var respJSON3 map[string]interface{}
  31644. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31647. return
  31648. }
  31649. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31650. userJSONBytes3, _ := json.Marshal(respJSON3)
  31651. fmt.Println("log")
  31652. fmt.Println(string(userJSONBytes3))
  31653. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31654. utils.ErrorLog("解析失败:%v", err)
  31655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31656. return
  31657. }
  31658. } else {
  31659. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31660. res2.Infcode = 0
  31661. } else {
  31662. 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)
  31663. var dat map[string]interface{}
  31664. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31665. fmt.Println(dat)
  31666. } else {
  31667. fmt.Println(err)
  31668. }
  31669. saveLog(result2, src_request, "2205", "撤销明细")
  31670. userJSONBytes, _ := json.Marshal(dat)
  31671. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31672. utils.ErrorLog("解析失败:%v", err)
  31673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31674. return
  31675. }
  31676. }
  31677. }
  31678. if res2.Infcode == -1 {
  31679. c.ServeSuccessJSON(map[string]interface{}{
  31680. "failed_code": -10,
  31681. "msg": res2.ErrMsg,
  31682. })
  31683. return
  31684. }
  31685. if res2.Infcode == 0 {
  31686. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  31687. if err == nil {
  31688. //当押金不为零时产生退费记录
  31689. if order.Decimal != 0 {
  31690. tmp := strconv.FormatInt(order.ID, 10)
  31691. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  31692. if err != nil {
  31693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31694. return
  31695. }
  31696. }
  31697. c.ServeSuccessJSON(map[string]interface{}{
  31698. "msg": "退费成功",
  31699. })
  31700. } else {
  31701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31702. return
  31703. }
  31704. } else {
  31705. c.ServeSuccessJSON(map[string]interface{}{
  31706. "failed_code": -10,
  31707. "msg": res2.ErrMsg,
  31708. })
  31709. }
  31710. } else {
  31711. c.ServeSuccessJSON(map[string]interface{}{
  31712. "failed_code": -10,
  31713. "msg": res.ErrMsg,
  31714. })
  31715. }
  31716. }
  31717. }
  31718. func (c *HisApiController) RefundNumber() {
  31719. record_time := c.GetString("record_time")
  31720. //patient_id, _ := c.GetInt64("patient_id")
  31721. admin_user_id, _ := c.GetInt64("admin_user_id")
  31722. his_patient_id, _ := c.GetInt64("id")
  31723. timeLayout := "2006-01-02"
  31724. loc, _ := time.LoadLocation("Local")
  31725. adminUser := c.GetAdminUserInfo()
  31726. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31727. fmt.Println(err)
  31728. if err != nil {
  31729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31730. return
  31731. }
  31732. recordDateTime := theTime.Unix()
  31733. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31734. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  31735. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31736. //order, _ := service.GetHisOrderByID(order_id)
  31737. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31738. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31739. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31740. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  31741. if count > 0 {
  31742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  31743. return
  31744. }
  31745. if config.IsOpen == 1 { //对接了医保,走医保流程
  31746. var res2 ResultSix
  31747. var res3 GZResultSix
  31748. var resSix10265 ResultSix10265
  31749. if miConfig.MdtrtareaAdmvs == "421300" {
  31750. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31751. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31752. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31753. resp3, requestErr3 := http.Get(api3)
  31754. if requestErr3 != nil {
  31755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31756. return
  31757. }
  31758. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31759. if ioErr3 != nil {
  31760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31762. return
  31763. }
  31764. var respJSON3 map[string]interface{}
  31765. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31768. return
  31769. }
  31770. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31771. userJSONBytes3, _ := json.Marshal(respJSON3)
  31772. fmt.Println("log")
  31773. fmt.Println(string(userJSONBytes3))
  31774. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31775. utils.ErrorLog("解析失败:%v", err)
  31776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31777. return
  31778. }
  31779. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31780. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31781. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31783. resp3, requestErr3 := http.Get(api3)
  31784. if requestErr3 != nil {
  31785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31786. return
  31787. }
  31788. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31789. if ioErr3 != nil {
  31790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31792. return
  31793. }
  31794. var respJSON3 map[string]interface{}
  31795. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31798. return
  31799. }
  31800. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31801. userJSONBytes3, _ := json.Marshal(respJSON3)
  31802. fmt.Println("log")
  31803. fmt.Println(string(userJSONBytes3))
  31804. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31805. utils.ErrorLog("解析失败:%v", err)
  31806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31807. return
  31808. }
  31809. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31810. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  31811. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31812. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31813. resp3, requestErr3 := http.Get(api3)
  31814. if requestErr3 != nil {
  31815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31816. return
  31817. }
  31818. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31819. if ioErr3 != nil {
  31820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31822. return
  31823. }
  31824. var respJSON3 map[string]interface{}
  31825. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31828. return
  31829. }
  31830. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31831. userJSONBytes3, _ := json.Marshal(respJSON3)
  31832. fmt.Println("log")
  31833. fmt.Println(string(userJSONBytes3))
  31834. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31835. utils.ErrorLog("解析失败:%v", err)
  31836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31837. return
  31838. }
  31839. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31840. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  31841. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31842. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31843. resp3, requestErr3 := http.Get(api3)
  31844. if requestErr3 != nil {
  31845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31846. return
  31847. }
  31848. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31849. if ioErr3 != nil {
  31850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31852. return
  31853. }
  31854. var respJSON3 map[string]interface{}
  31855. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31858. return
  31859. }
  31860. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31861. userJSONBytes3, _ := json.Marshal(respJSON3)
  31862. fmt.Println("log")
  31863. fmt.Println(string(userJSONBytes3))
  31864. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31865. utils.ErrorLog("解析失败:%v", err)
  31866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31867. return
  31868. }
  31869. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31870. var api3 string
  31871. if miConfig.MdtrtareaAdmvs == "320921" {
  31872. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  31873. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31874. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31875. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31876. } else {
  31877. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31878. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  31879. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31880. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31881. }
  31882. resp3, requestErr3 := http.Get(api3)
  31883. if requestErr3 != nil {
  31884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31885. return
  31886. }
  31887. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31888. if ioErr3 != nil {
  31889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31891. return
  31892. }
  31893. var respJSON3 map[string]interface{}
  31894. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31897. return
  31898. }
  31899. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31900. userJSONBytes3, _ := json.Marshal(respJSON3)
  31901. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31902. utils.ErrorLog("解析失败:%v", err)
  31903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31904. return
  31905. }
  31906. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31907. res2.Output = resSix10265.Output
  31908. res2.ErrMsg = resSix10265.ErrMsg
  31909. res2.Cainfo = resSix10265.Cainfo
  31910. res2.WarnMsg = resSix10265.WarnMsg
  31911. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31912. res2.Infcode = infocode
  31913. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31914. var api3 string
  31915. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  31916. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31917. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31918. resp3, requestErr3 := http.Get(api3)
  31919. if requestErr3 != nil {
  31920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31921. return
  31922. }
  31923. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31924. if ioErr3 != nil {
  31925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31927. return
  31928. }
  31929. var respJSON3 map[string]interface{}
  31930. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31933. return
  31934. }
  31935. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31936. userJSONBytes3, _ := json.Marshal(respJSON3)
  31937. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31938. utils.ErrorLog("解析失败:%v", err)
  31939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31940. return
  31941. }
  31942. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31943. res2.Output = resSix10265.Output
  31944. res2.ErrMsg = resSix10265.ErrMsg
  31945. res2.Cainfo = resSix10265.Cainfo
  31946. res2.WarnMsg = resSix10265.WarnMsg
  31947. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31948. res2.Infcode = infocode
  31949. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31950. 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)
  31951. var dat map[string]interface{}
  31952. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31953. fmt.Println(dat)
  31954. } else {
  31955. fmt.Println(err)
  31956. }
  31957. saveLog(result, request, "2202", "退号")
  31958. userJSONBytes, _ := json.Marshal(dat)
  31959. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31960. utils.ErrorLog("解析失败:%v", err)
  31961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31962. return
  31963. }
  31964. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31965. 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, "")
  31966. var dat map[string]interface{}
  31967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31968. fmt.Println(dat)
  31969. } else {
  31970. fmt.Println(err)
  31971. }
  31972. saveLog(result, request, "2202", "退号")
  31973. userJSONBytes, _ := json.Marshal(dat)
  31974. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31975. utils.ErrorLog("解析失败:%v", err)
  31976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31977. return
  31978. }
  31979. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31980. 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, "")
  31981. var dat map[string]interface{}
  31982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31983. fmt.Println(dat)
  31984. } else {
  31985. fmt.Println(err)
  31986. }
  31987. saveLog(result, request, "2202", "退号")
  31988. userJSONBytes, _ := json.Marshal(dat)
  31989. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31990. utils.ErrorLog("解析失败:%v", err)
  31991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31992. return
  31993. }
  31994. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31995. var api3 string
  31996. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  31997. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31998. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31999. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32000. resp3, requestErr3 := http.Get(api3)
  32001. if requestErr3 != nil {
  32002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32003. return
  32004. }
  32005. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32006. if ioErr3 != nil {
  32007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32009. return
  32010. }
  32011. var respJSON3 map[string]interface{}
  32012. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32015. return
  32016. }
  32017. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32018. if status == "0" {
  32019. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32020. c.ServeSuccessJSON(map[string]interface{}{
  32021. "failed_code": -10,
  32022. "msg": err_msg,
  32023. })
  32024. return
  32025. }
  32026. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32027. userJSONBytes3, _ := json.Marshal(respJSON3)
  32028. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32029. utils.ErrorLog("解析失败:%v", err)
  32030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32031. return
  32032. }
  32033. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32034. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32035. var api3 string
  32036. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32037. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32038. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32039. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32040. resp3, requestErr3 := http.Get(api3)
  32041. if requestErr3 != nil {
  32042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32043. return
  32044. }
  32045. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32046. if ioErr3 != nil {
  32047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32049. return
  32050. }
  32051. var respJSON3 map[string]interface{}
  32052. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32055. return
  32056. }
  32057. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32058. if status == "0" {
  32059. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32060. c.ServeSuccessJSON(map[string]interface{}{
  32061. "failed_code": -10,
  32062. "msg": err_msg,
  32063. })
  32064. return
  32065. }
  32066. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32067. userJSONBytes3, _ := json.Marshal(respJSON3)
  32068. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32069. utils.ErrorLog("解析失败:%v", err)
  32070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32071. return
  32072. }
  32073. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32074. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32075. 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, "")
  32076. var dat map[string]interface{}
  32077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32078. fmt.Println(dat)
  32079. } else {
  32080. fmt.Println(err)
  32081. }
  32082. saveLog(result, request, "2202", "退号")
  32083. userJSONBytes, _ := json.Marshal(dat)
  32084. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32085. utils.ErrorLog("解析失败:%v", err)
  32086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32087. return
  32088. }
  32089. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32090. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32091. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32092. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32093. resp3, requestErr3 := http.Get(api3)
  32094. if requestErr3 != nil {
  32095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32096. return
  32097. }
  32098. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32099. if ioErr3 != nil {
  32100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32102. return
  32103. }
  32104. var respJSON3 map[string]interface{}
  32105. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32108. return
  32109. }
  32110. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32111. userJSONBytes3, _ := json.Marshal(respJSON3)
  32112. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32113. utils.ErrorLog("解析失败:%v", err)
  32114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32115. return
  32116. }
  32117. } else {
  32118. var api3 string
  32119. if miConfig.Code == "H15049901371" {
  32120. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32121. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32122. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32123. } else {
  32124. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32125. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32126. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32127. }
  32128. resp3, requestErr3 := http.Get(api3)
  32129. if requestErr3 != nil {
  32130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32131. return
  32132. }
  32133. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32134. if ioErr3 != nil {
  32135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32137. return
  32138. }
  32139. var respJSON3 map[string]interface{}
  32140. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32143. return
  32144. }
  32145. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32146. userJSONBytes3, _ := json.Marshal(respJSON3)
  32147. if miConfig.Code == "H15049901371" {
  32148. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32149. utils.ErrorLog("解析失败:%v", err)
  32150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32151. return
  32152. }
  32153. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32154. res2.Output = resSix10265.Output
  32155. res2.ErrMsg = resSix10265.ErrMsg
  32156. res2.Cainfo = resSix10265.Cainfo
  32157. res2.WarnMsg = resSix10265.WarnMsg
  32158. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32159. res2.Infcode = infocode
  32160. } else {
  32161. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32162. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32163. utils.ErrorLog("解析失败:%v", err)
  32164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32165. return
  32166. }
  32167. res2.Infcode = res3.Infcode
  32168. } else {
  32169. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32170. utils.ErrorLog("解析失败:%v", err)
  32171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32172. return
  32173. }
  32174. }
  32175. }
  32176. }
  32177. if res2.Infcode == -1 {
  32178. c.ServeSuccessJSON(map[string]interface{}{
  32179. "failed_code": -10,
  32180. "msg": res2.ErrMsg,
  32181. })
  32182. return
  32183. }
  32184. if res2.Infcode == 0 {
  32185. if err == nil {
  32186. c.ServeSuccessJSON(map[string]interface{}{
  32187. "msg": "退号成功",
  32188. })
  32189. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32190. } else {
  32191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32192. return
  32193. }
  32194. }
  32195. } else {
  32196. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32197. //if err == nil {
  32198. // c.ServeSuccessJSON(map[string]interface{}{
  32199. // "msg": "退费成功",
  32200. // })
  32201. //} else {
  32202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32203. // return
  32204. //}
  32205. }
  32206. }
  32207. func (c *HisApiController) RefundDetail() {
  32208. order_id, _ := c.GetInt64("order_id")
  32209. admin_user_id, _ := c.GetInt64("admin_user_id")
  32210. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32211. number := c.GetString("number")
  32212. record_time := c.GetString("record_time")
  32213. patient_id, _ := c.GetInt64("patient_id")
  32214. //med_type, _ := c.GetInt64("med_type")
  32215. timeLayout := "2006-01-02"
  32216. loc, _ := time.LoadLocation("Local")
  32217. adminUser := c.GetAdminUserInfo()
  32218. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32219. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32220. fmt.Println(err)
  32221. if err != nil {
  32222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32223. return
  32224. }
  32225. recordDateTime := theTime.Unix()
  32226. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32227. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32229. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32230. var order models.HisOrder
  32231. order, _ = service.GetHisOrderByID(order_id)
  32232. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32233. if config.IsOpen == 1 { //对接了医保,走医保流程
  32234. var res2 ResultSix
  32235. if miConfig.MdtrtareaAdmvs == "421300" {
  32236. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32237. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32239. resp3, requestErr3 := http.Get(api3)
  32240. if requestErr3 != nil {
  32241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32242. return
  32243. }
  32244. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32245. if ioErr3 != nil {
  32246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32248. return
  32249. }
  32250. var respJSON3 map[string]interface{}
  32251. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32254. return
  32255. }
  32256. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32257. userJSONBytes3, _ := json.Marshal(respJSON3)
  32258. fmt.Println("log")
  32259. fmt.Println(string(userJSONBytes3))
  32260. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32261. utils.ErrorLog("解析失败:%v", err)
  32262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32263. return
  32264. }
  32265. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32266. if err == nil {
  32267. c.ServeSuccessJSON(map[string]interface{}{
  32268. "msg": "撤销明细成功",
  32269. })
  32270. return
  32271. } else {
  32272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32273. return
  32274. }
  32275. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32276. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32277. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32278. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32279. resp3, requestErr3 := http.Get(api3)
  32280. if requestErr3 != nil {
  32281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32282. return
  32283. }
  32284. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32285. if ioErr3 != nil {
  32286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32288. return
  32289. }
  32290. var respJSON3 map[string]interface{}
  32291. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32294. return
  32295. }
  32296. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32297. userJSONBytes3, _ := json.Marshal(respJSON3)
  32298. fmt.Println("log")
  32299. fmt.Println(string(userJSONBytes3))
  32300. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32301. utils.ErrorLog("解析失败:%v", err)
  32302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32303. return
  32304. }
  32305. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32306. if err == nil {
  32307. c.ServeSuccessJSON(map[string]interface{}{
  32308. "msg": "撤销明细成功",
  32309. })
  32310. return
  32311. } else {
  32312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32313. return
  32314. }
  32315. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32316. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32317. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32318. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32319. resp3, requestErr3 := http.Get(api3)
  32320. if requestErr3 != nil {
  32321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32322. return
  32323. }
  32324. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32325. if ioErr3 != nil {
  32326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32328. return
  32329. }
  32330. var respJSON3 map[string]interface{}
  32331. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32334. return
  32335. }
  32336. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32337. userJSONBytes3, _ := json.Marshal(respJSON3)
  32338. fmt.Println("log")
  32339. fmt.Println(string(userJSONBytes3))
  32340. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32341. utils.ErrorLog("解析失败:%v", err)
  32342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32343. return
  32344. }
  32345. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32346. if err == nil {
  32347. c.ServeSuccessJSON(map[string]interface{}{
  32348. "msg": "撤销明细成功",
  32349. })
  32350. return
  32351. } else {
  32352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32353. return
  32354. }
  32355. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32356. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32357. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32358. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32359. resp3, requestErr3 := http.Get(api3)
  32360. if requestErr3 != nil {
  32361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32362. return
  32363. }
  32364. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32365. if ioErr3 != nil {
  32366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32368. return
  32369. }
  32370. var respJSON3 map[string]interface{}
  32371. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32374. return
  32375. }
  32376. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32377. userJSONBytes3, _ := json.Marshal(respJSON3)
  32378. fmt.Println("log")
  32379. fmt.Println(string(userJSONBytes3))
  32380. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32381. utils.ErrorLog("解析失败:%v", err)
  32382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32383. return
  32384. }
  32385. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32386. if err == nil {
  32387. c.ServeSuccessJSON(map[string]interface{}{
  32388. "msg": "撤销明细成功",
  32389. })
  32390. return
  32391. } else {
  32392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32393. return
  32394. }
  32395. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32396. var resSix10265 ResultSix10265
  32397. var api3 string
  32398. if miConfig.MdtrtareaAdmvs == "320921" {
  32399. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32400. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32402. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32403. } else {
  32404. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32405. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32406. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32407. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32408. }
  32409. resp3, requestErr3 := http.Get(api3)
  32410. utils.ErrorLog("接口: %v", requestErr3)
  32411. if requestErr3 != nil {
  32412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32413. return
  32414. }
  32415. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32416. if ioErr3 != nil {
  32417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32419. return
  32420. }
  32421. var respJSON3 map[string]interface{}
  32422. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32425. return
  32426. }
  32427. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32428. userJSONBytes3, _ := json.Marshal(respJSON3)
  32429. fmt.Println("log")
  32430. fmt.Println(string(userJSONBytes3))
  32431. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32432. utils.ErrorLog("解析失败:%v", err)
  32433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32434. return
  32435. }
  32436. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32437. res2.Output = resSix10265.Output
  32438. res2.ErrMsg = resSix10265.ErrMsg
  32439. res2.Cainfo = resSix10265.Cainfo
  32440. res2.WarnMsg = resSix10265.WarnMsg
  32441. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32442. res2.Infcode = infocode
  32443. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32444. if err == nil {
  32445. c.ServeSuccessJSON(map[string]interface{}{
  32446. "msg": "撤销明细成功",
  32447. })
  32448. return
  32449. } else {
  32450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32451. return
  32452. }
  32453. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32454. var api3 string
  32455. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32456. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32457. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32458. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32459. resp3, requestErr3 := http.Get(api3)
  32460. utils.ErrorLog("接口: %v", requestErr3)
  32461. if requestErr3 != nil {
  32462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32463. return
  32464. }
  32465. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32466. if ioErr3 != nil {
  32467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32469. return
  32470. }
  32471. var respJSON3 map[string]interface{}
  32472. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32475. return
  32476. }
  32477. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32478. if status == "0" {
  32479. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32480. c.ServeSuccessJSON(map[string]interface{}{
  32481. "failed_code": -10,
  32482. "msg": err_msg,
  32483. })
  32484. return
  32485. }
  32486. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32487. userJSONBytes3, _ := json.Marshal(respJSON3)
  32488. fmt.Println("log")
  32489. fmt.Println(string(userJSONBytes3))
  32490. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32491. utils.ErrorLog("解析失败:%v", err)
  32492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32493. return
  32494. }
  32495. fmt.Println(res2.Infcode)
  32496. if res2.Infcode == -1 {
  32497. c.ServeSuccessJSON(map[string]interface{}{
  32498. "failed_code": -10,
  32499. "msg": res2.ErrMsg,
  32500. })
  32501. return
  32502. }
  32503. if res2.Infcode == 0 {
  32504. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32505. if err == nil {
  32506. c.ServeSuccessJSON(map[string]interface{}{
  32507. "msg": "撤销明细成功",
  32508. })
  32509. return
  32510. } else {
  32511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32512. return
  32513. }
  32514. } else {
  32515. c.ServeSuccessJSON(map[string]interface{}{
  32516. "failed_code": -10,
  32517. "msg": res2.ErrMsg,
  32518. })
  32519. }
  32520. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32521. if err == nil {
  32522. c.ServeSuccessJSON(map[string]interface{}{
  32523. "msg": "撤销明细成功",
  32524. })
  32525. return
  32526. } else {
  32527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32528. return
  32529. }
  32530. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32531. var api3 string
  32532. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32533. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32535. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32536. resp3, requestErr3 := http.Get(api3)
  32537. utils.ErrorLog("接口: %v", requestErr3)
  32538. if requestErr3 != nil {
  32539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32540. return
  32541. }
  32542. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32543. if ioErr3 != nil {
  32544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32546. return
  32547. }
  32548. var respJSON3 map[string]interface{}
  32549. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32552. return
  32553. }
  32554. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32555. if status == "0" {
  32556. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32557. c.ServeSuccessJSON(map[string]interface{}{
  32558. "failed_code": -10,
  32559. "msg": err_msg,
  32560. })
  32561. return
  32562. }
  32563. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32564. userJSONBytes3, _ := json.Marshal(respJSON3)
  32565. fmt.Println("log")
  32566. fmt.Println(string(userJSONBytes3))
  32567. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32568. utils.ErrorLog("解析失败:%v", err)
  32569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32570. return
  32571. }
  32572. fmt.Println(res2.Infcode)
  32573. if res2.Infcode == -1 {
  32574. c.ServeSuccessJSON(map[string]interface{}{
  32575. "failed_code": -10,
  32576. "msg": res2.ErrMsg,
  32577. })
  32578. return
  32579. }
  32580. if res2.Infcode == 0 {
  32581. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32582. if err == nil {
  32583. c.ServeSuccessJSON(map[string]interface{}{
  32584. "msg": "撤销明细成功",
  32585. })
  32586. return
  32587. } else {
  32588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32589. return
  32590. }
  32591. } else {
  32592. c.ServeSuccessJSON(map[string]interface{}{
  32593. "failed_code": -10,
  32594. "msg": res2.ErrMsg,
  32595. })
  32596. }
  32597. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32598. if err == nil {
  32599. c.ServeSuccessJSON(map[string]interface{}{
  32600. "msg": "撤销明细成功",
  32601. })
  32602. return
  32603. } else {
  32604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32605. return
  32606. }
  32607. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32608. var resSix10265 ResultSix10265
  32609. new_chrg_bchno := order.Number
  32610. if adminUser.CurrentOrgId == 10265 {
  32611. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32612. new_chrg_bchno = "0000"
  32613. }
  32614. }
  32615. var api3 string
  32616. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32617. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32618. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32619. resp3, requestErr3 := http.Get(api3)
  32620. if requestErr3 != nil {
  32621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32622. return
  32623. }
  32624. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32625. if ioErr3 != nil {
  32626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32628. return
  32629. }
  32630. var respJSON3 map[string]interface{}
  32631. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32634. return
  32635. }
  32636. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32637. userJSONBytes3, _ := json.Marshal(respJSON3)
  32638. fmt.Println("log")
  32639. fmt.Println(string(userJSONBytes3))
  32640. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32641. utils.ErrorLog("解析失败:%v", err)
  32642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32643. return
  32644. }
  32645. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32646. res2.Output = resSix10265.Output
  32647. res2.ErrMsg = resSix10265.ErrMsg
  32648. res2.Cainfo = resSix10265.Cainfo
  32649. res2.WarnMsg = resSix10265.WarnMsg
  32650. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32651. res2.Infcode = infocode
  32652. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32653. if err == nil {
  32654. c.ServeSuccessJSON(map[string]interface{}{
  32655. "msg": "撤销明细成功",
  32656. })
  32657. return
  32658. } else {
  32659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32660. return
  32661. }
  32662. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32663. 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)
  32664. var dat map[string]interface{}
  32665. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32666. fmt.Println(dat)
  32667. } else {
  32668. fmt.Println(err)
  32669. }
  32670. saveLog(result2, src_request, "2205", "撤销明细")
  32671. userJSONBytes, _ := json.Marshal(dat)
  32672. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32673. utils.ErrorLog("解析失败:%v", err)
  32674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32675. return
  32676. }
  32677. if res2.Infcode == 0 {
  32678. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32679. if err == nil {
  32680. c.ServeSuccessJSON(map[string]interface{}{
  32681. "msg": "撤销明细成功",
  32682. })
  32683. return
  32684. } else {
  32685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32686. return
  32687. }
  32688. } else {
  32689. c.ServeSuccessJSON(map[string]interface{}{
  32690. "failed_code": -10,
  32691. "msg": res2.ErrMsg,
  32692. })
  32693. }
  32694. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32695. 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, "")
  32696. var dat map[string]interface{}
  32697. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32698. fmt.Println(dat)
  32699. } else {
  32700. fmt.Println(err)
  32701. }
  32702. saveLog(result2, src_request, "2205", "撤销明细")
  32703. userJSONBytes, _ := json.Marshal(dat)
  32704. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32705. utils.ErrorLog("解析失败:%v", err)
  32706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32707. return
  32708. }
  32709. if res2.Infcode == 0 {
  32710. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32711. if err == nil {
  32712. c.ServeSuccessJSON(map[string]interface{}{
  32713. "msg": "撤销明细成功",
  32714. })
  32715. return
  32716. } else {
  32717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32718. return
  32719. }
  32720. } else {
  32721. c.ServeSuccessJSON(map[string]interface{}{
  32722. "failed_code": -10,
  32723. "msg": res2.ErrMsg,
  32724. })
  32725. }
  32726. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32727. 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, "")
  32728. var dat map[string]interface{}
  32729. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32730. fmt.Println(dat)
  32731. } else {
  32732. fmt.Println(err)
  32733. }
  32734. saveLog(result2, src_request, "2205", "撤销明细")
  32735. userJSONBytes, _ := json.Marshal(dat)
  32736. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32737. utils.ErrorLog("解析失败:%v", err)
  32738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32739. return
  32740. }
  32741. if res2.Infcode == 0 {
  32742. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32743. if err == nil {
  32744. c.ServeSuccessJSON(map[string]interface{}{
  32745. "msg": "撤销明细成功",
  32746. })
  32747. return
  32748. } else {
  32749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32750. return
  32751. }
  32752. } else {
  32753. c.ServeSuccessJSON(map[string]interface{}{
  32754. "failed_code": -10,
  32755. "msg": res2.ErrMsg,
  32756. })
  32757. }
  32758. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32759. 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, "")
  32760. var dat map[string]interface{}
  32761. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32762. fmt.Println(dat)
  32763. } else {
  32764. fmt.Println(err)
  32765. }
  32766. saveLog(result2, src_request, "2205", "撤销明细")
  32767. userJSONBytes, _ := json.Marshal(dat)
  32768. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32769. utils.ErrorLog("解析失败:%v", err)
  32770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32771. return
  32772. }
  32773. if res2.Infcode == 0 {
  32774. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32775. if err == nil {
  32776. c.ServeSuccessJSON(map[string]interface{}{
  32777. "msg": "撤销明细成功",
  32778. })
  32779. return
  32780. } else {
  32781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32782. return
  32783. }
  32784. } else {
  32785. c.ServeSuccessJSON(map[string]interface{}{
  32786. "failed_code": -10,
  32787. "msg": res2.ErrMsg,
  32788. })
  32789. }
  32790. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32791. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  32792. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32793. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32794. resp2, requestErr2 := http.Get(api2)
  32795. if requestErr2 != nil {
  32796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32797. return
  32798. }
  32799. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32800. if ioErr2 != nil {
  32801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32803. return
  32804. }
  32805. var respJSON2 map[string]interface{}
  32806. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32809. return
  32810. }
  32811. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32812. userJSONBytes3, _ := json.Marshal(respJSON2)
  32813. fmt.Println("log")
  32814. fmt.Println(string(userJSONBytes3))
  32815. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32816. utils.ErrorLog("解析失败:%v", err)
  32817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32818. return
  32819. }
  32820. if res2.Infcode == 0 {
  32821. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32822. if err == nil {
  32823. c.ServeSuccessJSON(map[string]interface{}{
  32824. "msg": "撤销明细成功",
  32825. })
  32826. return
  32827. } else {
  32828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32829. return
  32830. }
  32831. } else {
  32832. c.ServeSuccessJSON(map[string]interface{}{
  32833. "failed_code": -10,
  32834. "msg": res2.ErrMsg,
  32835. })
  32836. }
  32837. } else {
  32838. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  32839. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32841. resp2, requestErr2 := http.Get(api2)
  32842. if requestErr2 != nil {
  32843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32844. return
  32845. }
  32846. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32847. if ioErr2 != nil {
  32848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32850. return
  32851. }
  32852. var respJSON2 map[string]interface{}
  32853. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32856. return
  32857. }
  32858. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32859. userJSONBytes3, _ := json.Marshal(respJSON2)
  32860. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32861. utils.ErrorLog("解析失败:%v", err)
  32862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32863. return
  32864. }
  32865. if res2.Infcode == -1 {
  32866. c.ServeSuccessJSON(map[string]interface{}{
  32867. "failed_code": -10,
  32868. "msg": res2.ErrMsg,
  32869. })
  32870. return
  32871. } else {
  32872. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32873. if err == nil {
  32874. c.ServeSuccessJSON(map[string]interface{}{
  32875. "msg": "撤销明细成功",
  32876. })
  32877. return
  32878. } else {
  32879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32880. return
  32881. }
  32882. }
  32883. }
  32884. } else {
  32885. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32886. if err == nil {
  32887. c.ServeSuccessJSON(map[string]interface{}{
  32888. "msg": "退费成功",
  32889. })
  32890. } else {
  32891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32892. return
  32893. }
  32894. }
  32895. }
  32896. // 对账
  32897. func (c *HisApiController) GetCheckAccount() {
  32898. start_time := c.GetString("start_time")
  32899. end_time := c.GetString("end_time")
  32900. insutype := c.GetString("insutype")
  32901. clr_type := c.GetString("clr_type")
  32902. clr_org := c.GetString("clr_optins")
  32903. admin_user_id, _ := c.GetInt64("admin_user_id")
  32904. adminUser := c.GetAdminUserInfo()
  32905. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32906. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32907. if len(clr_org) == 0 {
  32908. clr_org = miConfig.InsuplcAdmdvs
  32909. }
  32910. timeLayout := "2006-01-02"
  32911. loc, _ := time.LoadLocation("Local")
  32912. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  32913. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  32914. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32915. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32916. fixmedins_setl_cnt := int64(len(orders))
  32917. var medfee_sumamt float64
  32918. var acct_pay float64
  32919. var fund_pay_sumamt float64
  32920. for _, item := range orders {
  32921. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32922. acct_pay = acct_pay + item.AcctPay
  32923. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32924. }
  32925. var user_name string
  32926. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32927. if role.ID == 0 {
  32928. user_name = "xxx"
  32929. } else {
  32930. user_name = role.UserName
  32931. }
  32932. var res ResultEight
  32933. var res10188 ResultEightFor10188
  32934. if config.IsOpen == 1 {
  32935. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32936. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  32937. "insutype=" + insutype +
  32938. "&clr_type=" + clr_type +
  32939. "&setl_optins=" + clr_org +
  32940. "&stmt_begndate=" + start_time +
  32941. "&stm_enddate=" + end_time +
  32942. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32943. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32944. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32945. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32946. "&fixmedins_code=" + miConfig.Code +
  32947. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32948. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32949. "&secret_key=" + miConfig.SecretKey +
  32950. "&org_name=" + miConfig.OrgName +
  32951. "&doctor=" + user_name +
  32952. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32953. fmt.Println(api)
  32954. resp, requestErr := http.Get(api)
  32955. if requestErr != nil {
  32956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32957. return
  32958. }
  32959. body, ioErr := ioutil.ReadAll(resp.Body)
  32960. fmt.Println(body)
  32961. if ioErr != nil {
  32962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32964. return
  32965. }
  32966. var respJSON map[string]interface{}
  32967. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32970. return
  32971. }
  32972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32973. userJSONBytes, _ := json.Marshal(respJSON)
  32974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32975. utils.ErrorLog("解析失败:%v", err)
  32976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32977. return
  32978. }
  32979. res.InfRefmsgid = res10188.InfRefmsgid
  32980. res.Output = res10188.Output
  32981. res.ErrMsg = res10188.ErrMsg
  32982. res.Cainfo = res10188.Cainfo
  32983. res.WarnMsg = res10188.WarnMsg
  32984. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  32985. res.Infcode = infocode
  32986. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32987. if clr_type != "9903" {
  32988. clr_type = "99" // 就诊 ID(来自2201接口返回)
  32989. }
  32990. if clr_type == "9903" {
  32991. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  32992. }
  32993. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  32994. "insutype=" + insutype +
  32995. "&clr_type=" + clr_type +
  32996. "&setl_optins=" + clr_org +
  32997. "&stmt_begndate=" + start_time +
  32998. "&stm_enddate=" + end_time +
  32999. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33000. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33001. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33002. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33003. "&fixmedins_code=" + miConfig.Code +
  33004. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33005. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33006. "&secret_key=" + miConfig.SecretKey +
  33007. "&org_name=" + miConfig.OrgName +
  33008. "&doctor=" + user_name
  33009. resp, requestErr := http.Get(api)
  33010. if requestErr != nil {
  33011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33012. return
  33013. }
  33014. body, ioErr := ioutil.ReadAll(resp.Body)
  33015. if ioErr != nil {
  33016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33018. return
  33019. }
  33020. var respJSON map[string]interface{}
  33021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33024. return
  33025. }
  33026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33027. result, _ := json.Marshal(respJSON)
  33028. fmt.Println("log")
  33029. fmt.Println(string(result))
  33030. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33031. utils.ErrorLog("解析失败:%v", err)
  33032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33033. return
  33034. }
  33035. res.InfRefmsgid = res10188.InfRefmsgid
  33036. res.Output = res10188.Output
  33037. res.ErrMsg = res10188.ErrMsg
  33038. res.Cainfo = res10188.Cainfo
  33039. res.WarnMsg = res10188.WarnMsg
  33040. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33041. res.Infcode = infocode
  33042. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33043. var baseParams models.BaseParams
  33044. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33045. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33046. baseParams.SecretKey = miConfig.SecretKey
  33047. baseParams.OrgName = miConfig.OrgName
  33048. baseParams.FixmedinsCode = miConfig.Code
  33049. baseParams.EncKey = miConfig.EncKey
  33050. baseParams.AppSecret = miConfig.AppSecret
  33051. baseParams.SignKey = miConfig.SignKey
  33052. baseParams.AppID = miConfig.Code
  33053. baseParams.Doctor = role.UserName
  33054. baseParams.RequestUrl = miConfig.Url
  33055. businessParams := models.BusinessParams{
  33056. Insutype: insutype,
  33057. ClrType: clr_type,
  33058. SetlOptins: clr_org,
  33059. StmtBegndate: start_time,
  33060. StmtEnddate: end_time,
  33061. MedfeeSumamt: medfee_sumamt,
  33062. FundPaySumamt: fund_pay_sumamt,
  33063. AcctPay: acct_pay,
  33064. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33065. }
  33066. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33067. fmt.Println(requestLog)
  33068. fmt.Println(result)
  33069. fmt.Println(err_msg)
  33070. var dat map[string]interface{}
  33071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33072. fmt.Println(dat)
  33073. } else {
  33074. fmt.Println(err)
  33075. }
  33076. userJSONBytes, _ := json.Marshal(dat)
  33077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33078. utils.ErrorLog("解析失败:%v", err)
  33079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33080. return
  33081. }
  33082. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33083. var baseParams models.BaseParams
  33084. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33085. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33086. baseParams.SecretKey = miConfig.SecretKey
  33087. baseParams.OrgName = miConfig.OrgName
  33088. baseParams.FixmedinsCode = miConfig.Code
  33089. baseParams.EncKey = miConfig.EncKey
  33090. baseParams.AppSecret = miConfig.AppSecret
  33091. baseParams.SignKey = miConfig.SignKey
  33092. baseParams.AppID = miConfig.Code
  33093. baseParams.Doctor = role.UserName
  33094. baseParams.RequestUrl = miConfig.Url
  33095. baseParams.AccessKey = miConfig.AccessKey
  33096. businessParams := models.BusinessParams{
  33097. Insutype: insutype,
  33098. ClrType: clr_type,
  33099. SetlOptins: "430822",
  33100. StmtBegndate: start_time,
  33101. StmtEnddate: end_time,
  33102. MedfeeSumamt: medfee_sumamt,
  33103. FundPaySumamt: fund_pay_sumamt,
  33104. AcctPay: acct_pay,
  33105. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33106. }
  33107. 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)
  33108. fmt.Println(requestLog)
  33109. fmt.Println(result)
  33110. var dat map[string]interface{}
  33111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33112. fmt.Println(dat)
  33113. } else {
  33114. fmt.Println(err)
  33115. }
  33116. userJSONBytes, _ := json.Marshal(dat)
  33117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33118. utils.ErrorLog("解析失败:%v", err)
  33119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33120. return
  33121. }
  33122. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33123. var baseParams models.BaseParams
  33124. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33125. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33126. baseParams.SecretKey = miConfig.SecretKey
  33127. baseParams.OrgName = miConfig.OrgName
  33128. baseParams.FixmedinsCode = miConfig.Code
  33129. baseParams.EncKey = miConfig.EncKey
  33130. baseParams.AppSecret = miConfig.AppSecret
  33131. baseParams.SignKey = miConfig.SignKey
  33132. baseParams.AppID = miConfig.Code
  33133. baseParams.Doctor = role.UserName
  33134. baseParams.RequestUrl = miConfig.Url
  33135. businessParams := models.BusinessParams{
  33136. Insutype: insutype,
  33137. ClrType: clr_type,
  33138. SetlOptins: clr_org,
  33139. StmtBegndate: start_time,
  33140. StmtEnddate: end_time,
  33141. MedfeeSumamt: medfee_sumamt,
  33142. FundPaySumamt: fund_pay_sumamt,
  33143. AcctPay: acct_pay,
  33144. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33145. }
  33146. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33147. fmt.Println(requestLog)
  33148. fmt.Println(result)
  33149. fmt.Println(err_msg)
  33150. var dat map[string]interface{}
  33151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33152. fmt.Println(dat)
  33153. } else {
  33154. fmt.Println(err)
  33155. }
  33156. userJSONBytes, _ := json.Marshal(dat)
  33157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33158. utils.ErrorLog("解析失败:%v", err)
  33159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33160. return
  33161. }
  33162. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33163. if len(clr_type) == 0 {
  33164. clr_type = "11"
  33165. }
  33166. api := miConfig.Url + "gdyb/ten?" +
  33167. "insutype=" + insutype +
  33168. "&clr_type=" + clr_type +
  33169. "&setl_optins=" + clr_org +
  33170. "&stmt_begndate=" + start_time +
  33171. "&stm_enddate=" + end_time +
  33172. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33173. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33174. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33175. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33176. "&fixmedins_code=" + miConfig.Code +
  33177. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33178. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33179. "&secret_key=" + miConfig.SecretKey +
  33180. "&org_name=" + miConfig.OrgName +
  33181. "&doctor=" + user_name
  33182. fmt.Println(api)
  33183. resp, requestErr := http.Get(api)
  33184. if requestErr != nil {
  33185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33186. return
  33187. }
  33188. body, ioErr := ioutil.ReadAll(resp.Body)
  33189. fmt.Println(body)
  33190. if ioErr != nil {
  33191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33193. return
  33194. }
  33195. var respJSON map[string]interface{}
  33196. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33199. return
  33200. }
  33201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33202. userJSONBytes, _ := json.Marshal(respJSON)
  33203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33204. utils.ErrorLog("解析失败:%v", err)
  33205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33206. return
  33207. }
  33208. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33209. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33210. //fixmedins_setl_cnt := int64(len(orders_two))
  33211. //var medfee_sumamt float64
  33212. //var acct_pay float64
  33213. //var fund_pay_sumamt float64
  33214. //for _, item := range orders_two {
  33215. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33216. // acct_pay = acct_pay + item.AcctPay
  33217. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33218. //}
  33219. var baseParams models.BaseParams
  33220. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33221. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33222. baseParams.SecretKey = miConfig.SecretKey
  33223. baseParams.OrgName = miConfig.OrgName
  33224. baseParams.FixmedinsCode = miConfig.Code
  33225. baseParams.EncKey = miConfig.EncKey
  33226. baseParams.AppSecret = miConfig.AppSecret
  33227. baseParams.SignKey = miConfig.SignKey
  33228. baseParams.AppID = miConfig.Code
  33229. baseParams.Doctor = role.UserName
  33230. baseParams.RequestUrl = miConfig.Url
  33231. if clr_type == "9903" {
  33232. clr_type = "9994"
  33233. }
  33234. businessParams := models.BusinessParams{
  33235. Insutype: insutype,
  33236. ClrType: clr_type,
  33237. SetlOptins: "360302",
  33238. StmtBegndate: start_time,
  33239. StmtEnddate: end_time,
  33240. MedfeeSumamt: 0,
  33241. FundPaySumamt: 0,
  33242. AcctPay: 0,
  33243. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33244. }
  33245. 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))
  33246. fmt.Println(requestLog)
  33247. fmt.Println(result)
  33248. var dat map[string]interface{}
  33249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33250. fmt.Println(dat)
  33251. } else {
  33252. fmt.Println(err)
  33253. }
  33254. userJSONBytes, _ := json.Marshal(dat)
  33255. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33256. utils.ErrorLog("解析失败:%v", err)
  33257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33258. return
  33259. }
  33260. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33261. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33262. fixmedins_setl_cnt := int64(len(orders_two))
  33263. var medfee_sumamt float64
  33264. var acct_pay float64
  33265. var fund_pay_sumamt float64
  33266. for _, item := range orders_two {
  33267. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33268. acct_pay = acct_pay + item.AcctPay
  33269. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33270. }
  33271. var baseParams models.BaseParams
  33272. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33273. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33274. baseParams.SecretKey = miConfig.SecretKey
  33275. baseParams.OrgName = miConfig.OrgName
  33276. baseParams.FixmedinsCode = miConfig.Code
  33277. baseParams.EncKey = miConfig.EncKey
  33278. baseParams.AppSecret = miConfig.AppSecret
  33279. baseParams.SignKey = miConfig.SignKey
  33280. baseParams.AppID = miConfig.Code
  33281. baseParams.Doctor = role.UserName
  33282. baseParams.RequestUrl = miConfig.Url
  33283. if clr_type == "9903" {
  33284. clr_type = "9994"
  33285. }
  33286. businessParams := models.BusinessParams{
  33287. Insutype: insutype,
  33288. ClrType: clr_type,
  33289. SetlOptins: "361025",
  33290. StmtBegndate: start_time,
  33291. StmtEnddate: end_time,
  33292. MedfeeSumamt: 0,
  33293. FundPaySumamt: 0,
  33294. AcctPay: 0,
  33295. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33296. }
  33297. 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))
  33298. fmt.Println(requestLog)
  33299. fmt.Println(result)
  33300. var dat map[string]interface{}
  33301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33302. fmt.Println(dat)
  33303. } else {
  33304. fmt.Println(err)
  33305. }
  33306. userJSONBytes, _ := json.Marshal(dat)
  33307. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33308. utils.ErrorLog("解析失败:%v", err)
  33309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33310. return
  33311. }
  33312. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33313. var api string
  33314. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33315. "&clr_type=" + clr_type +
  33316. "&setl_optins=" + clr_org +
  33317. "&stmt_begndate=" + start_time +
  33318. "&stm_enddate=" + end_time +
  33319. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33320. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33321. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33322. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33323. "&fixmedins_code=" + miConfig.Code +
  33324. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33325. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33326. "&secret_key=" + miConfig.SecretKey +
  33327. "&org_name=" + miConfig.OrgName +
  33328. "&doctor=" + user_name + "&url=" + miConfig.Url
  33329. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33330. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33331. resp, requestErr := http.Get(api)
  33332. if requestErr != nil {
  33333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33334. return
  33335. }
  33336. body, ioErr := ioutil.ReadAll(resp.Body)
  33337. if ioErr != nil {
  33338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33340. return
  33341. }
  33342. var respJSON map[string]interface{}
  33343. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33346. return
  33347. }
  33348. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33349. if status == "0" {
  33350. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33351. c.ServeSuccessJSON(map[string]interface{}{
  33352. "failed_code": -10,
  33353. "msg": err_msg,
  33354. })
  33355. return
  33356. }
  33357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33358. userJSONBytes, _ := json.Marshal(respJSON)
  33359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33360. utils.ErrorLog("解析失败:%v", err)
  33361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33362. return
  33363. }
  33364. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33365. var api string
  33366. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33367. "&clr_type=" + clr_type +
  33368. "&setl_optins=" + clr_org +
  33369. "&stmt_begndate=" + start_time +
  33370. "&stm_enddate=" + end_time +
  33371. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33372. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33373. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33374. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33375. "&fixmedins_code=" + miConfig.Code +
  33376. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33377. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33378. "&secret_key=" + miConfig.SecretKey +
  33379. "&org_name=" + miConfig.OrgName +
  33380. "&doctor=" + user_name + "&url=" + miConfig.Url
  33381. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33382. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33383. resp, requestErr := http.Get(api)
  33384. if requestErr != nil {
  33385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33386. return
  33387. }
  33388. body, ioErr := ioutil.ReadAll(resp.Body)
  33389. if ioErr != nil {
  33390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33392. return
  33393. }
  33394. var respJSON map[string]interface{}
  33395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33398. return
  33399. }
  33400. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33401. if status == "0" {
  33402. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33403. c.ServeSuccessJSON(map[string]interface{}{
  33404. "failed_code": -10,
  33405. "msg": err_msg,
  33406. })
  33407. return
  33408. }
  33409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33410. userJSONBytes, _ := json.Marshal(respJSON)
  33411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33412. utils.ErrorLog("解析失败:%v", err)
  33413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33414. return
  33415. }
  33416. } else {
  33417. if len(clr_type) == 0 {
  33418. clr_type = "11"
  33419. }
  33420. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33421. "insutype=" + insutype +
  33422. "&clr_type=" + clr_type +
  33423. "&setl_optins=" + clr_org +
  33424. "&stmt_begndate=" + start_time +
  33425. "&stm_enddate=" + end_time +
  33426. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33427. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33428. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33429. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33430. "&fixmedins_code=" + miConfig.Code +
  33431. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33432. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33433. "&secret_key=" + miConfig.SecretKey +
  33434. "&org_name=" + miConfig.OrgName +
  33435. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33436. fmt.Println(api)
  33437. resp, requestErr := http.Get(api)
  33438. if requestErr != nil {
  33439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33440. return
  33441. }
  33442. body, ioErr := ioutil.ReadAll(resp.Body)
  33443. fmt.Println(body)
  33444. if ioErr != nil {
  33445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33447. return
  33448. }
  33449. var respJSON map[string]interface{}
  33450. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33453. return
  33454. }
  33455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33456. userJSONBytes, _ := json.Marshal(respJSON)
  33457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33458. utils.ErrorLog("解析失败:%v", err)
  33459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33460. return
  33461. }
  33462. }
  33463. if res.Infcode == 0 {
  33464. if res.Output.Stmtinfo.StmtRslt == "0" {
  33465. micc := &models.MedicalInsuranceCostCompare{
  33466. StartTime: startime.Unix(),
  33467. EndTime: endtime.Unix(),
  33468. Insutype: insutype,
  33469. CheckType: 1,
  33470. Num: fixmedins_setl_cnt,
  33471. Mtime: time.Now().Unix(),
  33472. Status: 1,
  33473. UserOrgId: adminUser.CurrentOrgId,
  33474. CostTotal: medfee_sumamt,
  33475. FuncTotal: fund_pay_sumamt,
  33476. PsnPay: acct_pay,
  33477. Creator: admin_user_id,
  33478. Ctime: time.Now().Unix(),
  33479. ClrType: clr_type,
  33480. }
  33481. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33482. if err == nil {
  33483. c.ServeSuccessJSON(map[string]interface{}{
  33484. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33485. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33486. })
  33487. } else {
  33488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33489. }
  33490. } else {
  33491. c.ServeSuccessJSON(map[string]interface{}{
  33492. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33493. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33494. })
  33495. }
  33496. } else {
  33497. c.ServeSuccessJSON(map[string]interface{}{
  33498. "failed_code": -10,
  33499. "msg": res.ErrMsg,
  33500. })
  33501. }
  33502. }
  33503. }
  33504. func (c *HisApiController) Check310() {
  33505. adminUser := c.GetAdminUserInfo()
  33506. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33507. var user_name string
  33508. user_name = "高慧裕"
  33509. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33510. "insutype=" + "310" +
  33511. "&clr_type=" + "" +
  33512. "&setl_optins=" + "441202" +
  33513. "&stmt_begndate=" + "2022-03-01" +
  33514. "&stm_enddate=" + "2022-03-31" +
  33515. "&medfee_sumamt=" + "194930.12" +
  33516. "&fund_pay_sumamt=" + "188741.46" +
  33517. "&acct_pay=" + "0" +
  33518. "&fixmedins_setl_cnt=" + "452" +
  33519. "&fixmedins_code=" + miConfig.Code +
  33520. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33521. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33522. "&secret_key=" + miConfig.SecretKey +
  33523. "&org_name=" + miConfig.OrgName +
  33524. "&doctor=" + user_name
  33525. fmt.Println(api)
  33526. resp, requestErr := http.Get(api)
  33527. if requestErr != nil {
  33528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33529. return
  33530. }
  33531. body, ioErr := ioutil.ReadAll(resp.Body)
  33532. fmt.Println(body)
  33533. if ioErr != nil {
  33534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33536. return
  33537. }
  33538. var respJSON map[string]interface{}
  33539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33542. return
  33543. }
  33544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33545. userJSONBytes, _ := json.Marshal(respJSON)
  33546. var res ResultEight
  33547. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33548. utils.ErrorLog("解析失败:%v", err)
  33549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33550. return
  33551. }
  33552. }
  33553. func (c *HisApiController) Check390() {
  33554. adminUser := c.GetAdminUserInfo()
  33555. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33556. var user_name string
  33557. user_name = "高慧裕"
  33558. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33559. "insutype=" + "390" +
  33560. "&clr_type=" + "" +
  33561. "&setl_optins=" + "441202" +
  33562. "&stmt_begndate=" + "2022-03-01" +
  33563. "&stm_enddate=" + "2022-03-31" +
  33564. "&medfee_sumamt=" + "1068448.89" +
  33565. "&fund_pay_sumamt=" + "1014677.62" +
  33566. "&acct_pay=" + "0" +
  33567. "&fixmedins_setl_cnt=" + "1950" +
  33568. "&fixmedins_code=" + miConfig.Code +
  33569. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33570. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33571. "&secret_key=" + miConfig.SecretKey +
  33572. "&org_name=" + miConfig.OrgName +
  33573. "&doctor=" + user_name
  33574. fmt.Println(api)
  33575. resp, requestErr := http.Get(api)
  33576. if requestErr != nil {
  33577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33578. return
  33579. }
  33580. body, ioErr := ioutil.ReadAll(resp.Body)
  33581. fmt.Println(body)
  33582. if ioErr != nil {
  33583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33585. return
  33586. }
  33587. var respJSON map[string]interface{}
  33588. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33591. return
  33592. }
  33593. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33594. userJSONBytes, _ := json.Marshal(respJSON)
  33595. var res ResultEight
  33596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33597. utils.ErrorLog("解析失败:%v", err)
  33598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33599. return
  33600. }
  33601. }
  33602. // 对账明细
  33603. func (c *HisApiController) GetCheckDetailAccount() {
  33604. start_time := c.GetString("start_time")
  33605. end_time := c.GetString("end_time")
  33606. admin_user_id, _ := c.GetInt64("admin_user_id")
  33607. adminUser := c.GetAdminUserInfo()
  33608. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33609. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33610. timeLayout := "2006-01-02"
  33611. loc, _ := time.LoadLocation("Local")
  33612. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33613. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33614. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33615. rand.Seed(time.Now().UnixNano())
  33616. num := rand.Intn(30000)
  33617. Mkdir(miConfig.OrgName)
  33618. file := strconv.FormatInt(int64(num), 10)
  33619. file_name := file + ".txt"
  33620. zip_name := file + ".zip"
  33621. zip_path := miConfig.OrgName + "/" + zip_name
  33622. file_path := miConfig.OrgName + "/" + file_name
  33623. decimal.DivisionPrecision = 2
  33624. var medfee_sumamt float64
  33625. var psn_cash_pay float64
  33626. var fund_pay_sumamt float64
  33627. fixmedins_setl_cnt := int64(len(orders))
  33628. for _, item := range orders {
  33629. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33630. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33631. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33632. }
  33633. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33634. defer f.Close()
  33635. if err != nil {
  33636. fmt.Println(err.Error())
  33637. } else {
  33638. for _, item := range orders {
  33639. var refd_setl_flag string
  33640. if item.OrderStatus == 2 {
  33641. refd_setl_flag = "0"
  33642. var str string
  33643. str = item.SetlId + " " +
  33644. item.MdtrtId + " " +
  33645. item.PsnNo + " " +
  33646. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33647. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33648. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33649. _, err = f.Write([]byte(str))
  33650. }
  33651. if item.OrderStatus == 3 {
  33652. var str string
  33653. str = item.SetlId + " " +
  33654. item.MdtrtId + " " +
  33655. item.PsnNo + " " +
  33656. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33657. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33658. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33659. _, err = f.Write([]byte(str))
  33660. var str2 string
  33661. str2 = item.SetlId + " " +
  33662. item.MdtrtId + " " +
  33663. item.PsnNo + " " +
  33664. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33665. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33666. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33667. _, err = f.Write([]byte(str2))
  33668. }
  33669. }
  33670. }
  33671. Zip(file_path, zip_path)
  33672. fmt.Println(ReadFile(zip_path))
  33673. fmt.Println(string(ReadFile(zip_path)))
  33674. if config.IsOpen == 1 {
  33675. var user_name string
  33676. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33677. if role.ID == 0 {
  33678. user_name = "管理员"
  33679. } else {
  33680. user_name = role.UserName
  33681. }
  33682. baseParams := models.BaseParams{
  33683. SecretKey: miConfig.SecretKey,
  33684. FixmedinsCode: miConfig.Code,
  33685. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33686. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33687. OrgName: miConfig.OrgName,
  33688. Doctor: user_name,
  33689. }
  33690. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  33691. var dat map[string]interface{}
  33692. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33693. fmt.Println(dat)
  33694. } else {
  33695. fmt.Println(err)
  33696. }
  33697. userJSONBytes, _ := json.Marshal(dat)
  33698. var res ResultNine
  33699. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33700. utils.ErrorLog("解析失败:%v", err)
  33701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33702. return
  33703. }
  33704. if res.Infcode == 0 {
  33705. fileNo := res.Output.FileQuryNo
  33706. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  33707. "file_qury_no=" + fileNo +
  33708. "&setl_optins=" + "定点医保中心" +
  33709. "&stmt_begndate=" + start_time +
  33710. "&stm_enddate=" + end_time +
  33711. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33712. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33713. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  33714. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33715. "&fixmedins_code=" + miConfig.Code +
  33716. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33717. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33718. "&secret_key=" + miConfig.SecretKey +
  33719. "&org_name=" + miConfig.OrgName +
  33720. "&doctor=" + user_name
  33721. resp, requestErr := http.Get(api)
  33722. if requestErr != nil {
  33723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33724. return
  33725. }
  33726. body, ioErr := ioutil.ReadAll(resp.Body)
  33727. if ioErr != nil {
  33728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33730. return
  33731. }
  33732. var respJSON map[string]interface{}
  33733. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33736. return
  33737. }
  33738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33739. userJSONBytes, _ := json.Marshal(respJSON)
  33740. var res ResultTen
  33741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33742. utils.ErrorLog("解析失败:%v", err)
  33743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33744. return
  33745. }
  33746. if res.Infcode == 0 {
  33747. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  33748. micc := &models.MedicalInsuranceCostCompare{
  33749. StartTime: startime.Unix(),
  33750. EndTime: endtime.Unix(),
  33751. Insutype: "0",
  33752. CheckType: 2,
  33753. Num: fixmedins_setl_cnt,
  33754. Mtime: time.Now().Unix(),
  33755. Status: 1,
  33756. UserOrgId: adminUser.CurrentOrgId,
  33757. CostTotal: medfee_sumamt,
  33758. FuncTotal: fund_pay_sumamt,
  33759. PsnPay: psn_cash_pay,
  33760. Creator: admin_user_id,
  33761. Ctime: time.Now().Unix(),
  33762. }
  33763. service.CreateMedicalInsuranceCostCompareRecord(micc)
  33764. c.ServeSuccessJSON(map[string]interface{}{
  33765. "msg": "明细对账成功",
  33766. })
  33767. }
  33768. } else {
  33769. }
  33770. }
  33771. }
  33772. type CustomOrderInfo struct {
  33773. Name string
  33774. Spec string
  33775. Unit string
  33776. Count float64
  33777. Price float64
  33778. Total float64
  33779. }
  33780. func (c *HisApiController) GetBatchSettleAccounts() {
  33781. admin_user_id, _ := c.GetInt64("admin_user_id")
  33782. order_ids := c.GetString("order_ids")
  33783. order_ids_arr := strings.Split(order_ids, ",")
  33784. data3 := []map[string]interface{}{}
  33785. for _, item := range order_ids_arr {
  33786. id, _ := strconv.ParseInt(item, 10, 64)
  33787. order_id := id
  33788. adminUser := c.GetAdminUserInfo()
  33789. order, _ := service.GetHisOrderByID(order_id)
  33790. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33791. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  33792. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  33793. orderInfos = append(orderInfos, orderInfos_two...)
  33794. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  33795. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  33796. var diagnosis_ids []string
  33797. if his.ID > 0 {
  33798. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  33799. } else {
  33800. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  33801. }
  33802. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  33803. var dia_config []*models.HisXtDiagnoseConfig
  33804. var name string
  33805. for _, item := range diagnosis_ids {
  33806. id, _ := strconv.ParseInt(item, 10, 64)
  33807. diagnosisConfig, _ := service.FindDiagnoseById(id)
  33808. dia_config = append(dia_config, &diagnosisConfig)
  33809. if len(name) == 0 {
  33810. name = diagnosisConfig.ClassName
  33811. }
  33812. //} else {
  33813. // name = name + "," + diagnosisConfig.ClassName
  33814. //}
  33815. }
  33816. var bedCostTotal float64 = 0 //床位总费
  33817. var bedCostSelfTotal float64 = 0 //床位自费
  33818. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  33819. var bedSelfTotal float64 = 0 //床位部分项目自费
  33820. var bedInscpTotal float64 = 0 //床位部分项目自费
  33821. var operationCostTotal float64 = 0 //手术费
  33822. var operationCostSelfTotal float64 = 0 //手术费
  33823. var operationCostPartSelfTotal float64 = 0 //手术费
  33824. var operationSelfTotal float64 = 0 //床位部分项目自费
  33825. var operationInscpTotal float64 = 0 //床位部分项目自费
  33826. var otherCostTotal float64 = 0 //其他费用
  33827. var otherCostSelfTotal float64 = 0 //其他费用
  33828. var otherCostPartSelfTotal float64 = 0 //其他费用
  33829. var otherSelfTotal float64 = 0 //床位部分项目自费
  33830. var otherInscpTotal float64 = 0 //床位部分项目自费
  33831. var materialCostTotal float64 = 0 //材料费
  33832. var materialCostSelfTotal float64 = 0 //材料费
  33833. var materialCostPartSelfTotal float64 = 0 //材料费
  33834. var materialSelfTotal float64 = 0 //床位部分项目自费
  33835. var materialInscpTotal float64 = 0 //床位部分项目自费
  33836. var westernMedicineCostTotal float64 = 0 //西药费
  33837. var westernMedicineCostSelfTotal float64 = 0 //西药费
  33838. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  33839. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  33840. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  33841. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  33842. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  33843. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  33844. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  33845. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  33846. var checkCostTotal float64 = 0 //检查费
  33847. var checkCostSelfTotal float64 = 0 //检查费
  33848. var checkCostPartSelfTotal float64 = 0 //检查费
  33849. var checkSelfTotal float64 = 0 //床位部分项目自费
  33850. var checkInscpTotal float64 = 0 //床位部分项目自费
  33851. var laboratoryCostTotal float64 = 0 //化验费
  33852. var laboratoryCostSelfTotal float64 = 0 //化验费
  33853. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  33854. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  33855. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  33856. var treatCostTotal float64 = 0 //治疗费用
  33857. var treatCostSelfTotal float64 = 0 //治疗费用
  33858. var treatCostPartSelfTotal float64 = 0 //治疗费用
  33859. var treatSelfTotal float64 = 0 //床位部分项目自费
  33860. var treatInscpTotal float64 = 0 //床位部分项目自费
  33861. decimal.DivisionPrecision = 2
  33862. for _, item := range orderInfos {
  33863. if item.MedChrgitmType == "01" { //床位费
  33864. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33865. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33866. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33867. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33868. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33869. }
  33870. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  33871. if item.MedChrgitmType == "03" { //检查费
  33872. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33873. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33874. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33875. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33876. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33877. }
  33878. } else {
  33879. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  33880. fmt.Println("------------")
  33881. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33882. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33883. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33884. }
  33885. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  33886. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33887. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33888. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33889. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33890. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33891. }
  33892. }
  33893. if item.MedChrgitmType == "04" { //化验费
  33894. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33895. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33896. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33897. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33898. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33899. }
  33900. if item.MedChrgitmType == "05" { //治疗费
  33901. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33902. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33903. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33904. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33905. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33906. }
  33907. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  33908. fmt.Println("------------")
  33909. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33910. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33911. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33912. }
  33913. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  33914. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33915. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33916. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33917. }
  33918. //if item.MedChrgitmType == "06" { //手术费
  33919. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33920. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33921. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33922. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33923. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33924. //
  33925. //}
  33926. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  33927. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33928. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33929. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33930. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33931. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33932. }
  33933. if item.MedChrgitmType == "09" { //西药费
  33934. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33935. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33936. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33937. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33938. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33939. }
  33940. if item.MedChrgitmType == "11" { //中成费
  33941. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33942. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33943. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33944. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33945. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33946. }
  33947. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  33948. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33949. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33950. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33951. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33952. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33953. }
  33954. }
  33955. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33956. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33957. var user_name string
  33958. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33959. if role.ID == 0 {
  33960. user_name = "管理员"
  33961. } else {
  33962. user_name = role.UserName
  33963. }
  33964. baseParams := models.BaseParams{
  33965. SecretKey: miConfig.SecretKey,
  33966. FixmedinsCode: miConfig.Code,
  33967. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33968. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33969. OrgName: miConfig.OrgName,
  33970. Doctor: user_name,
  33971. RequestUrl: miConfig.Url,
  33972. AccessKey: miConfig.AccessKey,
  33973. }
  33974. businessParams := models.BusinessParams{
  33975. PsnNo: order.PsnNo,
  33976. MdtrtId: order.MdtrtId,
  33977. SetlId: order.SetlId,
  33978. }
  33979. var res ResultEleven
  33980. var resEleven10265 ResultEleven10265
  33981. if config.IsOpen == 1 {
  33982. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  33983. result := service.Gdyb5203(baseParams, businessParams)
  33984. service.Gdyb5204(baseParams, businessParams)
  33985. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  33986. var dat map[string]interface{}
  33987. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33988. fmt.Println(dat)
  33989. } else {
  33990. fmt.Println(err)
  33991. }
  33992. userJSONBytes, _ := json.Marshal(dat)
  33993. if miConfig.Code == "H15049901371" {
  33994. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  33995. utils.ErrorLog("解析失败:%v", err)
  33996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33997. return
  33998. }
  33999. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34000. res.Output = resEleven10265.Output
  34001. res.ErrMsg = resEleven10265.ErrMsg
  34002. res.Cainfo = resEleven10265.Cainfo
  34003. res.WarnMsg = resEleven10265.WarnMsg
  34004. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34005. res.Infcode = infocode
  34006. } else {
  34007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34008. utils.ErrorLog("解析失败:%v", err)
  34009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34010. return
  34011. }
  34012. }
  34013. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34014. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34015. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34016. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34017. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34018. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34019. var doctor_name string
  34020. if roles.ID == 0 {
  34021. doctor_name = "管理员"
  34022. } else {
  34023. doctor_name = roles.UserName
  34024. }
  34025. yiliao_leibie := ""
  34026. switch order.MedType {
  34027. case "11":
  34028. yiliao_leibie = "普通门诊"
  34029. break
  34030. case "12":
  34031. yiliao_leibie = "门诊挂号"
  34032. break
  34033. case "13":
  34034. yiliao_leibie = "急诊"
  34035. break
  34036. case "14":
  34037. yiliao_leibie = "门诊特殊病"
  34038. break
  34039. case "15":
  34040. yiliao_leibie = "门诊统筹"
  34041. break
  34042. case "16":
  34043. yiliao_leibie = "门诊慢性病"
  34044. break
  34045. case "21":
  34046. yiliao_leibie = "普通住院"
  34047. break
  34048. }
  34049. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34050. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34051. if res.Infcode == 0 {
  34052. data2 := map[string]interface{}{
  34053. "diagnosis": name,
  34054. "order_infos": orderInfos,
  34055. "number": order.MdtrtId,
  34056. "date": order.SettleAccountsDate,
  34057. "charge_admin": charge_admin,
  34058. "printor_admin": printor_admin,
  34059. "info": res.Output.Setlinfo,
  34060. "order": order,
  34061. "bedCostTotal": bedCostTotal,
  34062. "bedCostSelfTotal": bedCostSelfTotal,
  34063. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34064. "bedSelfTotal": bedSelfTotal,
  34065. "bedInscpTotal": bedInscpTotal,
  34066. "operationCostTotal": operationCostTotal,
  34067. "operationCostSelfTotal": operationCostSelfTotal,
  34068. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34069. "operationSelfTotal": operationSelfTotal,
  34070. "operationInscpTotal": operationInscpTotal,
  34071. "otherCostTotal": otherCostTotal,
  34072. "otherCostSelfTotal": otherCostSelfTotal,
  34073. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34074. "otherSelfTotal": otherSelfTotal,
  34075. "otherInscpTotal": otherInscpTotal,
  34076. "materialCostTotal": materialCostTotal,
  34077. "materialCostSelfTotal": materialCostSelfTotal,
  34078. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34079. "materialSelfTotal": materialSelfTotal,
  34080. "materialInscpTotal": materialInscpTotal,
  34081. "westernMedicineCostTotal": westernMedicineCostTotal,
  34082. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34083. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34084. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34085. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34086. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34087. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34088. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34089. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34090. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34091. "checkCostTotal": checkCostTotal,
  34092. "checkCostSelfTotal": checkCostSelfTotal,
  34093. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34094. "checkSelfTotal": checkSelfTotal,
  34095. "checkInscpTotal": checkInscpTotal,
  34096. "laboratoryCostTotal": laboratoryCostTotal,
  34097. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34098. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34099. "laboratorySelfTotal": laboratorySelfTotal,
  34100. "laboratoryInscpTotal": laboratoryInscpTotal,
  34101. "treatCostTotal": treatCostTotal,
  34102. "treatCostSelfTotal": treatCostSelfTotal,
  34103. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34104. "treatSelfTotal": treatSelfTotal,
  34105. "treatInscpTotal": treatInscpTotal,
  34106. "doctor_info": doctor_info,
  34107. "doctor_code": adminRole_two.DoctorCode,
  34108. "doctor_name": doctor_name,
  34109. "health_card_no": order.PsnNo,
  34110. "department": departments.Name,
  34111. "yiliao_leibie": yiliao_leibie,
  34112. "after_money": order.AccountPrice,
  34113. "patient": patient,
  34114. "org_name": miConfig.OrgName,
  34115. "org_code": miConfig.Code,
  34116. "order_number": order.Number,
  34117. "his_hospital": his_hospital,
  34118. "his": his,
  34119. "dia_config": dia_config,
  34120. "psn_cash_pay": order.PsnCashPay,
  34121. //"check_order_info": cus_slice,
  34122. }
  34123. data3 = append(data3, data2)
  34124. }
  34125. }
  34126. }
  34127. c.ServeSuccessJSON(map[string]interface{}{
  34128. "infos": data3,
  34129. })
  34130. }
  34131. func (c *HisApiController) GetSettleAccounts() {
  34132. //id, _ := c.GetInt64("id")
  34133. //record_time := c.GetString("record_time")
  34134. order_id, _ := c.GetInt64("order_id")
  34135. admin_user_id, _ := c.GetInt64("admin_user_id")
  34136. //timeLayout := "2006-01-02"
  34137. //loc, _ := time.LoadLocation("Local")
  34138. //
  34139. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34140. //if err != nil {
  34141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34142. // return
  34143. //}Hbyb5203
  34144. //recordDateTime := theTime.Unix()
  34145. adminUser := c.GetAdminUserInfo()
  34146. order, _ := service.GetHisOrderByID(order_id)
  34147. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34148. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34149. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34150. orderInfos = append(orderInfos, orderInfos_two...)
  34151. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34152. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34153. var diagnosis_ids []string
  34154. if his.ID > 0 {
  34155. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34156. } else {
  34157. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34158. }
  34159. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34160. var dia_config []*models.HisXtDiagnoseConfig
  34161. var name string
  34162. for _, item := range diagnosis_ids {
  34163. id, _ := strconv.ParseInt(item, 10, 64)
  34164. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34165. dia_config = append(dia_config, &diagnosisConfig)
  34166. if len(name) == 0 {
  34167. name = diagnosisConfig.ClassName
  34168. } else {
  34169. name = name + "," + diagnosisConfig.ClassName
  34170. }
  34171. }
  34172. if patient.UserOrgId == 10215 {
  34173. name = "慢性肾功能不全(血透治疗)"
  34174. }
  34175. var bedCostTotal float64 = 0 //床位总费
  34176. var bedCostSelfTotal float64 = 0 //床位自费
  34177. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34178. var bedSelfTotal float64 = 0 //床位部分项目自费
  34179. var bedInscpTotal float64 = 0 //床位部分项目自费
  34180. var operationCostTotal float64 = 0 //手术费
  34181. var operationCostSelfTotal float64 = 0 //手术费
  34182. var operationCostPartSelfTotal float64 = 0 //手术费
  34183. var operationSelfTotal float64 = 0 //床位部分项目自费
  34184. var operationInscpTotal float64 = 0 //床位部分项目自费
  34185. var otherCostTotal float64 = 0 //其他费用
  34186. var otherCostSelfTotal float64 = 0 //其他费用
  34187. var otherCostPartSelfTotal float64 = 0 //其他费用
  34188. var otherSelfTotal float64 = 0 //床位部分项目自费
  34189. var otherInscpTotal float64 = 0 //床位部分项目自费
  34190. var materialCostTotal float64 = 0 //材料费
  34191. var materialCostSelfTotal float64 = 0 //材料费
  34192. var materialCostPartSelfTotal float64 = 0 //材料费
  34193. var materialSelfTotal float64 = 0 //床位部分项目自费
  34194. var materialInscpTotal float64 = 0 //床位部分项目自费
  34195. var westernMedicineCostTotal float64 = 0 //西药费
  34196. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34197. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34198. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34199. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34200. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34201. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34202. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34203. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34204. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34205. var checkCostTotal float64 = 0 //检查费
  34206. var checkCostSelfTotal float64 = 0 //检查费
  34207. var checkCostPartSelfTotal float64 = 0 //检查费
  34208. var checkSelfTotal float64 = 0 //床位部分项目自费
  34209. var checkInscpTotal float64 = 0 //床位部分项目自费
  34210. var laboratoryCostTotal float64 = 0 //化验费
  34211. var laboratoryCostSelfTotal float64 = 0 //化验费
  34212. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34213. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34214. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34215. var treatCostTotal float64 = 0 //治疗费用
  34216. var treatCostSelfTotal float64 = 0 //治疗费用
  34217. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34218. var treatSelfTotal float64 = 0 //床位部分项目自费
  34219. var treatInscpTotal float64 = 0 //床位部分项目自费
  34220. var zcCostTotal float64 = 0 //治疗费用
  34221. var zcCostSelfTotal float64 = 0 //治疗费用
  34222. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34223. var zcSelfTotal float64 = 0 //床位部分项目自费
  34224. var zcInscpTotal float64 = 0 //床位部分项目自费
  34225. var huliCostTotal float64 = 0 //治疗费用
  34226. var huliCostSelfTotal float64 = 0 //治疗费用
  34227. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34228. var huliSelfTotal float64 = 0 //床位部分项目自费
  34229. var huliInscpTotal float64 = 0 //床位部分项目自费
  34230. decimal.DivisionPrecision = 2
  34231. for _, item := range orderInfos {
  34232. if item.MedChrgitmType == "01" { //床位费
  34233. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34234. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34235. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34236. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34237. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34238. }
  34239. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34240. if item.MedChrgitmType == "03" { //检查费
  34241. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34242. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34243. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34244. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34245. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34246. }
  34247. } else {
  34248. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34249. fmt.Println("------------")
  34250. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34251. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34252. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34253. }
  34254. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34255. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34256. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34257. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34258. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34259. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34260. }
  34261. }
  34262. if item.MedChrgitmType == "04" { //化验费
  34263. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34264. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34265. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34266. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34267. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34268. }
  34269. if item.MedChrgitmType == "05" { //治疗费
  34270. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34271. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34272. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34273. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34274. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34275. }
  34276. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34277. fmt.Println("------------")
  34278. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34279. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34280. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34281. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34282. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34283. }
  34284. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34285. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34286. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34287. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34288. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34289. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34290. }
  34291. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34292. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34293. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34294. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34295. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34296. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34297. }
  34298. if item.MedChrgitmType == "09" { //西药费
  34299. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34300. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34301. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34302. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34303. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34304. }
  34305. if item.MedChrgitmType == "11" { //中成费
  34306. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34307. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34308. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34309. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34310. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34311. }
  34312. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34313. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34314. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34315. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34316. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34317. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34318. }
  34319. if item.MedChrgitmType == "02" { //其他费
  34320. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34321. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34322. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34323. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34324. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34325. }
  34326. if item.MedChrgitmType == "07" { //其他费
  34327. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34328. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34329. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34330. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34331. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34332. }
  34333. }
  34334. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34335. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34336. var user_name string
  34337. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34338. if role.ID == 0 {
  34339. user_name = "管理员"
  34340. } else {
  34341. user_name = role.UserName
  34342. }
  34343. baseParams := models.BaseParams{
  34344. SecretKey: miConfig.SecretKey,
  34345. FixmedinsCode: miConfig.Code,
  34346. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34347. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34348. OrgName: miConfig.OrgName,
  34349. Doctor: user_name,
  34350. RequestUrl: miConfig.Url,
  34351. AccessKey: miConfig.AccessKey,
  34352. }
  34353. businessParams := models.BusinessParams{
  34354. PsnNo: order.PsnNo,
  34355. MdtrtId: order.MdtrtId,
  34356. SetlId: order.SetlId,
  34357. }
  34358. var res ResultEleven
  34359. var resah ResultElevenah
  34360. var resEleven10265 ResultEleven10265
  34361. if config.IsOpen == 1 {
  34362. if miConfig.MdtrtareaAdmvs == "421300" {
  34363. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34364. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34365. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34366. resp, requestErr := http.Get(api)
  34367. if requestErr != nil {
  34368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34369. return
  34370. }
  34371. body, ioErr := ioutil.ReadAll(resp.Body)
  34372. if ioErr != nil {
  34373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34375. return
  34376. }
  34377. var respJSON map[string]interface{}
  34378. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34381. return
  34382. }
  34383. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34384. result, _ := json.Marshal(respJSON)
  34385. fmt.Println("log")
  34386. fmt.Println(string(result))
  34387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34388. utils.ErrorLog("解析失败:%v", err)
  34389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34390. return
  34391. }
  34392. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34393. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34394. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34395. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34396. resp, requestErr := http.Get(api)
  34397. if requestErr != nil {
  34398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34399. return
  34400. }
  34401. body, ioErr := ioutil.ReadAll(resp.Body)
  34402. if ioErr != nil {
  34403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34405. return
  34406. }
  34407. var respJSON map[string]interface{}
  34408. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34411. return
  34412. }
  34413. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34414. result, _ := json.Marshal(respJSON)
  34415. fmt.Println("log")
  34416. fmt.Println(string(result))
  34417. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34418. utils.ErrorLog("解析失败:%v", err)
  34419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34420. return
  34421. }
  34422. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34423. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34424. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34425. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34426. resp, requestErr := http.Get(api)
  34427. if requestErr != nil {
  34428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34429. return
  34430. }
  34431. body, ioErr := ioutil.ReadAll(resp.Body)
  34432. if ioErr != nil {
  34433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34435. return
  34436. }
  34437. var respJSON map[string]interface{}
  34438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34441. return
  34442. }
  34443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34444. result, _ := json.Marshal(respJSON)
  34445. fmt.Println("log")
  34446. fmt.Println(string(result))
  34447. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34448. utils.ErrorLog("解析失败:%v", err)
  34449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34450. return
  34451. }
  34452. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34453. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34454. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34455. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34456. resp, requestErr := http.Get(api)
  34457. if requestErr != nil {
  34458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34459. return
  34460. }
  34461. body, ioErr := ioutil.ReadAll(resp.Body)
  34462. if ioErr != nil {
  34463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34465. return
  34466. }
  34467. var respJSON map[string]interface{}
  34468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34471. return
  34472. }
  34473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34474. result, _ := json.Marshal(respJSON)
  34475. fmt.Println("log")
  34476. fmt.Println(string(result))
  34477. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34478. utils.ErrorLog("解析失败:%v", err)
  34479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34480. return
  34481. }
  34482. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34483. var api string
  34484. if miConfig.MdtrtareaAdmvs == "320921" {
  34485. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34486. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34487. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34488. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34489. } else {
  34490. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34491. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34492. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34493. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34494. }
  34495. resp, requestErr := http.Get(api)
  34496. if requestErr != nil {
  34497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34498. return
  34499. }
  34500. body, ioErr := ioutil.ReadAll(resp.Body)
  34501. if ioErr != nil {
  34502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34504. return
  34505. }
  34506. var respJSON map[string]interface{}
  34507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34510. return
  34511. }
  34512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34513. result, _ := json.Marshal(respJSON)
  34514. fmt.Println("log")
  34515. fmt.Println(string(result))
  34516. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34517. utils.ErrorLog("解析失败:%v", err)
  34518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34519. return
  34520. }
  34521. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34522. res.Output = resEleven10265.Output
  34523. res.ErrMsg = resEleven10265.ErrMsg
  34524. res.Cainfo = resEleven10265.Cainfo
  34525. res.WarnMsg = resEleven10265.WarnMsg
  34526. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34527. res.Infcode = infocode
  34528. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34529. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34530. saveLog(result, requestLog, "5203", "结算单")
  34531. var dat map[string]interface{}
  34532. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34533. fmt.Println(dat)
  34534. } else {
  34535. fmt.Println(err)
  34536. }
  34537. userJSONBytes, _ := json.Marshal(dat)
  34538. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34539. utils.ErrorLog("解析失败:%v", err)
  34540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34541. return
  34542. }
  34543. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34544. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34545. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34546. saveLog(result, requestLog, "5203", "结算单")
  34547. var dat map[string]interface{}
  34548. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34549. fmt.Println(dat)
  34550. } else {
  34551. fmt.Println(err)
  34552. }
  34553. userJSONBytes, _ := json.Marshal(dat)
  34554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34555. utils.ErrorLog("解析失败:%v", err)
  34556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34557. return
  34558. }
  34559. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34560. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34561. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34562. saveLog(result, requestLog, "5203", "结算单")
  34563. var dat map[string]interface{}
  34564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34565. fmt.Println(dat)
  34566. } else {
  34567. fmt.Println(err)
  34568. }
  34569. userJSONBytes, _ := json.Marshal(dat)
  34570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34571. utils.ErrorLog("解析失败:%v", err)
  34572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34573. return
  34574. }
  34575. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34576. var api string
  34577. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34578. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34579. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34580. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34581. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34582. resp, requestErr := http.Get(api)
  34583. if requestErr != nil {
  34584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34585. return
  34586. }
  34587. body, ioErr := ioutil.ReadAll(resp.Body)
  34588. if ioErr != nil {
  34589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34591. return
  34592. }
  34593. var respJSON map[string]interface{}
  34594. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34597. return
  34598. }
  34599. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34600. if status == "0" {
  34601. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34602. c.ServeSuccessJSON(map[string]interface{}{
  34603. "failed_code": -10,
  34604. "msg": err_msg,
  34605. })
  34606. return
  34607. }
  34608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34609. result, _ := json.Marshal(respJSON)
  34610. fmt.Println("log")
  34611. fmt.Println(string(result))
  34612. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34613. utils.ErrorLog("解析失败:%v", err)
  34614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34615. return
  34616. }
  34617. res.InfRefmsgid = resah.InfRefmsgid
  34618. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34619. // 创建对应的Time类型
  34620. t := time.UnixMilli(timestamp)
  34621. // 格式化成指定的日期字符串
  34622. str := t.Format("2006-01-02 15:04:05")
  34623. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34624. // 创建对应的Time类型
  34625. t3 := time.UnixMilli(timestamp2)
  34626. // 格式化成指定的日期字符串
  34627. str2 := t3.Format("2006-01-02 15:04:05")
  34628. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34629. // 创建对应的Time类型
  34630. t4 := time.UnixMilli(timestamp3)
  34631. // 格式化成指定的日期字符串
  34632. str3 := t4.Format("2006-01-02 15:04:05")
  34633. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34634. // 创建对应的Time类型
  34635. t5 := time.UnixMilli(timestamp4)
  34636. // 格式化成指定的日期字符串
  34637. str5 := t5.Format("2006-01-02 15:04:05")
  34638. res.Output.Setlinfo.Brdy = str2
  34639. res.Output.Setlinfo.SetlTime = str
  34640. res.Output.Setlinfo.Begndate = str3
  34641. res.Output.Setlinfo.Enddate = str5
  34642. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34643. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34644. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34645. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34646. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34647. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34648. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34649. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34650. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34651. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34652. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34653. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34654. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34655. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34656. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34657. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34658. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34659. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34660. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34661. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34662. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34663. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34664. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34665. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34666. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34667. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34668. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34669. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34670. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34671. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34672. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34673. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34674. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34675. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34676. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34677. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34678. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34679. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34680. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34681. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34682. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34683. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34684. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34685. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34686. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34687. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34688. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34689. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34690. //res.Output.Setldetail = resah.Output.Setldetail
  34691. res.ErrMsg = resah.ErrMsg
  34692. res.Cainfo = resah.Cainfo
  34693. res.WarnMsg = resah.WarnMsg
  34694. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34695. var api string
  34696. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34697. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34698. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34699. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34700. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34701. resp, requestErr := http.Get(api)
  34702. if requestErr != nil {
  34703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34704. return
  34705. }
  34706. body, ioErr := ioutil.ReadAll(resp.Body)
  34707. if ioErr != nil {
  34708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34710. return
  34711. }
  34712. var respJSON map[string]interface{}
  34713. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34716. return
  34717. }
  34718. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34719. if status == "0" {
  34720. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34721. c.ServeSuccessJSON(map[string]interface{}{
  34722. "failed_code": -10,
  34723. "msg": err_msg,
  34724. })
  34725. return
  34726. }
  34727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34728. result, _ := json.Marshal(respJSON)
  34729. fmt.Println("log")
  34730. fmt.Println(string(result))
  34731. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34732. utils.ErrorLog("解析失败:%v", err)
  34733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34734. return
  34735. }
  34736. res.InfRefmsgid = resah.InfRefmsgid
  34737. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34738. // 创建对应的Time类型
  34739. t := time.UnixMilli(timestamp)
  34740. // 格式化成指定的日期字符串
  34741. str := t.Format("2006-01-02 15:04:05")
  34742. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34743. // 创建对应的Time类型
  34744. t3 := time.UnixMilli(timestamp2)
  34745. // 格式化成指定的日期字符串
  34746. str2 := t3.Format("2006-01-02 15:04:05")
  34747. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34748. // 创建对应的Time类型
  34749. t4 := time.UnixMilli(timestamp3)
  34750. // 格式化成指定的日期字符串
  34751. str3 := t4.Format("2006-01-02 15:04:05")
  34752. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34753. // 创建对应的Time类型
  34754. t5 := time.UnixMilli(timestamp4)
  34755. // 格式化成指定的日期字符串
  34756. str5 := t5.Format("2006-01-02 15:04:05")
  34757. res.Output.Setlinfo.Brdy = str2
  34758. res.Output.Setlinfo.SetlTime = str
  34759. res.Output.Setlinfo.Begndate = str3
  34760. res.Output.Setlinfo.Enddate = str5
  34761. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34762. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34763. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34764. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34765. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34766. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34767. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34768. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34769. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34770. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34771. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34772. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34773. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34774. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34775. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34776. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34777. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34778. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34779. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34780. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34781. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34782. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34783. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34784. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34785. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34786. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34787. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34788. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34789. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34790. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34791. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34792. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34793. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34794. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34795. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34796. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34797. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34798. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34799. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34800. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34801. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34802. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34803. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34804. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34805. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34806. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34807. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34808. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34809. //res.Output.Setldetail = resah.Output.Setldetail
  34810. res.ErrMsg = resah.ErrMsg
  34811. res.Cainfo = resah.Cainfo
  34812. res.WarnMsg = resah.WarnMsg
  34813. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34814. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  34815. saveLog(result, requestLog, "5203", "结算单")
  34816. var dat map[string]interface{}
  34817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34818. fmt.Println(dat)
  34819. } else {
  34820. fmt.Println(err)
  34821. }
  34822. userJSONBytes, _ := json.Marshal(dat)
  34823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34824. utils.ErrorLog("解析失败:%v", err)
  34825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34826. return
  34827. }
  34828. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34829. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34830. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34831. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34832. resp, requestErr := http.Get(api)
  34833. if requestErr != nil {
  34834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34835. return
  34836. }
  34837. body, ioErr := ioutil.ReadAll(resp.Body)
  34838. if ioErr != nil {
  34839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34841. return
  34842. }
  34843. var respJSON map[string]interface{}
  34844. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34847. return
  34848. }
  34849. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34850. result, _ := json.Marshal(respJSON)
  34851. fmt.Println("log")
  34852. fmt.Println(string(result))
  34853. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34854. utils.ErrorLog("解析失败:%v", err)
  34855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34856. return
  34857. }
  34858. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34859. res.Output = resEleven10265.Output
  34860. res.ErrMsg = resEleven10265.ErrMsg
  34861. res.Cainfo = resEleven10265.Cainfo
  34862. res.WarnMsg = resEleven10265.WarnMsg
  34863. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34864. res.Infcode = infocode
  34865. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34866. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34867. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34868. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34869. resp, requestErr := http.Get(api)
  34870. if requestErr != nil {
  34871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34872. return
  34873. }
  34874. body, ioErr := ioutil.ReadAll(resp.Body)
  34875. if ioErr != nil {
  34876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34878. return
  34879. }
  34880. var respJSON map[string]interface{}
  34881. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34884. return
  34885. }
  34886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34887. result, _ := json.Marshal(respJSON)
  34888. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34889. utils.ErrorLog("解析失败:%v", err)
  34890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34891. return
  34892. }
  34893. } else if miConfig.MdtrtareaAdmvs == "450721" {
  34894. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  34895. //return
  34896. } else {
  34897. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34898. if len(his.InsuplcAdmdvs) == 0 {
  34899. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34900. } else {
  34901. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34902. }
  34903. result := service.Gdyb5203(baseParams, businessParams)
  34904. //service.Gdyb5204(baseParams, businessParams)
  34905. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34906. var dat map[string]interface{}
  34907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34908. fmt.Println(dat)
  34909. } else {
  34910. fmt.Println(err)
  34911. }
  34912. userJSONBytes, _ := json.Marshal(dat)
  34913. if miConfig.Code == "H15049901371" {
  34914. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34915. utils.ErrorLog("解析失败:%v", err)
  34916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34917. return
  34918. }
  34919. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34920. res.Output = resEleven10265.Output
  34921. res.ErrMsg = resEleven10265.ErrMsg
  34922. res.Cainfo = resEleven10265.Cainfo
  34923. res.WarnMsg = resEleven10265.WarnMsg
  34924. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34925. res.Infcode = infocode
  34926. } else {
  34927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34928. utils.ErrorLog("解析失败:%v", err)
  34929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34930. return
  34931. }
  34932. }
  34933. }
  34934. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34935. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34936. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34937. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34938. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34939. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34940. var doctor_name string
  34941. if roles.ID == 0 {
  34942. doctor_name = "管理员"
  34943. } else {
  34944. doctor_name = roles.UserName
  34945. }
  34946. yiliao_leibie := ""
  34947. switch order.MedType {
  34948. case "11":
  34949. yiliao_leibie = "普通门诊"
  34950. break
  34951. case "12":
  34952. yiliao_leibie = "门诊挂号"
  34953. break
  34954. case "13":
  34955. yiliao_leibie = "急诊"
  34956. break
  34957. case "14":
  34958. yiliao_leibie = "门诊特殊病"
  34959. break
  34960. case "15":
  34961. yiliao_leibie = "门诊统筹"
  34962. break
  34963. case "16":
  34964. yiliao_leibie = "门诊慢性病"
  34965. break
  34966. case "21":
  34967. yiliao_leibie = "普通住院"
  34968. break
  34969. }
  34970. //var rf []CustomFundPay
  34971. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  34972. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34973. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  34974. if res.Infcode == 0 {
  34975. 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 {
  34976. c.ServeSuccessJSON(map[string]interface{}{
  34977. "diagnosis": name,
  34978. "order_infos": orderInfos,
  34979. "number": order.MdtrtId,
  34980. "date": order.SettleAccountsDate,
  34981. "charge_admin": charge_admin,
  34982. "printor_admin": printor_admin,
  34983. "info": res.Output.Setlinfo,
  34984. "order": order,
  34985. "bedCostTotal": bedCostTotal,
  34986. "bedCostSelfTotal": bedCostSelfTotal,
  34987. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34988. "bedSelfTotal": bedSelfTotal,
  34989. "bedInscpTotal": bedInscpTotal,
  34990. "operationCostTotal": operationCostTotal,
  34991. "operationCostSelfTotal": operationCostSelfTotal,
  34992. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34993. "operationSelfTotal": operationSelfTotal,
  34994. "operationInscpTotal": operationInscpTotal,
  34995. "otherCostTotal": otherCostTotal,
  34996. "otherCostSelfTotal": otherCostSelfTotal,
  34997. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34998. "otherSelfTotal": otherSelfTotal,
  34999. "otherInscpTotal": otherInscpTotal,
  35000. "materialCostTotal": materialCostTotal,
  35001. "materialCostSelfTotal": materialCostSelfTotal,
  35002. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35003. "materialSelfTotal": materialSelfTotal,
  35004. "materialInscpTotal": materialInscpTotal,
  35005. "westernMedicineCostTotal": westernMedicineCostTotal,
  35006. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35007. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35008. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35009. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35010. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35011. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35012. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35013. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35014. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35015. "checkCostTotal": checkCostTotal,
  35016. "checkCostSelfTotal": checkCostSelfTotal,
  35017. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35018. "checkSelfTotal": checkSelfTotal,
  35019. "checkInscpTotal": checkInscpTotal,
  35020. "laboratoryCostTotal": laboratoryCostTotal,
  35021. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35022. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35023. "laboratorySelfTotal": laboratorySelfTotal,
  35024. "laboratoryInscpTotal": laboratoryInscpTotal,
  35025. "treatCostTotal": treatCostTotal,
  35026. "treatCostSelfTotal": treatCostSelfTotal,
  35027. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35028. "treatSelfTotal": treatSelfTotal,
  35029. "treatInscpTotal": treatInscpTotal,
  35030. "doctor_info": doctor_info,
  35031. "doctor_code": adminRole_two.DoctorCode,
  35032. "doctor_name": doctor_name,
  35033. "health_card_no": order.PsnNo,
  35034. "department": departments.Name,
  35035. "yiliao_leibie": yiliao_leibie,
  35036. "after_money": order.AccountPrice,
  35037. "patient": patient,
  35038. "org_name": miConfig.OrgName,
  35039. "org_code": miConfig.Code,
  35040. "order_number": order.Number,
  35041. "his_hospital": his_hospital,
  35042. "his": his,
  35043. "dia_config": dia_config,
  35044. "psn_cash_pay": order.PsnCashPay,
  35045. "zcCostTotal": zcCostTotal,
  35046. "zcCostSelfTotal": zcCostSelfTotal,
  35047. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35048. "zcSelfTotal": zcSelfTotal,
  35049. "zcInscpTotal": zcInscpTotal,
  35050. "huliCostTotal": huliCostTotal,
  35051. "huliCostSelfTotal": huliCostSelfTotal,
  35052. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35053. "huliSelfTotal": huliSelfTotal,
  35054. "huliInscpTotal": huliInscpTotal,
  35055. //"funds": rf,
  35056. //"check_order_info": cus_slice,
  35057. })
  35058. } else {
  35059. c.ServeSuccessJSON(map[string]interface{}{
  35060. "diagnosis": name,
  35061. "order_infos": orderInfos,
  35062. "number": order.MdtrtId,
  35063. "date": order.SettleAccountsDate,
  35064. "charge_admin": charge_admin,
  35065. "printor_admin": printor_admin,
  35066. "info": order,
  35067. "order": order,
  35068. "bedCostTotal": bedCostTotal,
  35069. "bedCostSelfTotal": bedCostSelfTotal,
  35070. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35071. "bedSelfTotal": bedSelfTotal,
  35072. "bedInscpTotal": bedInscpTotal,
  35073. "operationCostTotal": operationCostTotal,
  35074. "operationCostSelfTotal": operationCostSelfTotal,
  35075. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35076. "operationSelfTotal": operationSelfTotal,
  35077. "operationInscpTotal": operationInscpTotal,
  35078. "otherCostTotal": otherCostTotal,
  35079. "otherCostSelfTotal": otherCostSelfTotal,
  35080. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35081. "otherSelfTotal": otherSelfTotal,
  35082. "otherInscpTotal": otherInscpTotal,
  35083. "materialCostTotal": materialCostTotal,
  35084. "materialCostSelfTotal": materialCostSelfTotal,
  35085. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35086. "materialSelfTotal": materialSelfTotal,
  35087. "materialInscpTotal": materialInscpTotal,
  35088. "westernMedicineCostTotal": westernMedicineCostTotal,
  35089. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35090. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35091. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35092. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35093. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35094. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35095. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35096. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35097. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35098. "checkCostTotal": checkCostTotal,
  35099. "checkCostSelfTotal": checkCostSelfTotal,
  35100. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35101. "checkSelfTotal": checkSelfTotal,
  35102. "checkInscpTotal": checkInscpTotal,
  35103. "laboratoryCostTotal": laboratoryCostTotal,
  35104. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35105. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35106. "laboratorySelfTotal": laboratorySelfTotal,
  35107. "laboratoryInscpTotal": laboratoryInscpTotal,
  35108. "treatCostTotal": treatCostTotal,
  35109. "treatCostSelfTotal": treatCostSelfTotal,
  35110. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35111. "treatSelfTotal": treatSelfTotal,
  35112. "treatInscpTotal": treatInscpTotal,
  35113. "doctor_info": doctor_info,
  35114. "doctor_code": adminRole_two.DoctorCode,
  35115. "doctor_name": doctor_name,
  35116. "health_card_no": order.PsnNo,
  35117. "department": departments.Name,
  35118. "yiliao_leibie": yiliao_leibie,
  35119. "after_money": order.AccountPrice,
  35120. "patient": patient,
  35121. "org_name": miConfig.OrgName,
  35122. "org_code": miConfig.Code,
  35123. "order_number": order.Number,
  35124. "his_hospital": his_hospital,
  35125. "his": his,
  35126. "dia_config": dia_config,
  35127. "psn_cash_pay": order.PsnCashPay,
  35128. "zcCostTotal": zcCostTotal,
  35129. "zcCostSelfTotal": zcCostSelfTotal,
  35130. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35131. "zcSelfTotal": zcSelfTotal,
  35132. "zcInscpTotal": zcInscpTotal,
  35133. "huliCostTotal": huliCostTotal,
  35134. "huliCostSelfTotal": huliCostSelfTotal,
  35135. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35136. "huliSelfTotal": huliSelfTotal,
  35137. "huliInscpTotal": huliInscpTotal,
  35138. //"funds": rf,
  35139. //"check_order_info": cus_slice,
  35140. })
  35141. }
  35142. }
  35143. }
  35144. }
  35145. //func (c *HisApiController) CheckTreatment() {
  35146. // patient_id, _ := c.GetInt64("patient_id")
  35147. // id_card_no := c.GetString("id_card_no")
  35148. // insutype := c.GetString("insutype")
  35149. // med_type := c.GetString("med_type")
  35150. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35151. //
  35152. // adminUser := c.GetAdminUserInfo()
  35153. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35154. //
  35155. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35156. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35157. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35158. //
  35159. // if miConfig.MdtrtareaAdmvs == "421300" {
  35160. // var res ResultTwo
  35161. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35162. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35163. // "&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)
  35164. // resp, requestErr := http.Get(api)
  35165. // if requestErr != nil {
  35166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35167. // return
  35168. // }
  35169. //
  35170. // body, ioErr := ioutil.ReadAll(resp.Body)
  35171. // if ioErr != nil {
  35172. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35174. // return
  35175. // }
  35176. // var respJSON map[string]interface{}
  35177. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35178. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35180. // return
  35181. // }
  35182. //
  35183. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35184. // result, _ := json.Marshal(respJSON)
  35185. //
  35186. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35187. // utils.ErrorLog("解析失败:%v", err)
  35188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35189. // return
  35190. // }
  35191. //
  35192. // if res.Infcode == 0 {
  35193. //
  35194. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35195. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35196. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35197. // resp, requestErr := http.Get(api)
  35198. // if requestErr != nil {
  35199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35200. // return
  35201. // }
  35202. //
  35203. // body, ioErr := ioutil.ReadAll(resp.Body)
  35204. // if ioErr != nil {
  35205. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35207. // return
  35208. // }
  35209. // var respJSON map[string]interface{}
  35210. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35211. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35213. // return
  35214. // }
  35215. // var res Result2001
  35216. //
  35217. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35218. // result2, _ := json.Marshal(respJSON)
  35219. //
  35220. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35221. // utils.ErrorLog("解析失败:%v", err)
  35222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35223. // return
  35224. // }
  35225. //
  35226. // if res.Infcode == 0 {
  35227. // c.ServeSuccessJSON(map[string]interface{}{
  35228. // "msg": res.Output.Trtinfo,
  35229. // })
  35230. // }
  35231. //
  35232. // } else {
  35233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35234. // return
  35235. // }
  35236. //
  35237. // } else {
  35238. //
  35239. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35240. // var dat map[string]interface{}
  35241. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35242. // fmt.Println(dat)
  35243. // } else {
  35244. // fmt.Println(err)
  35245. // }
  35246. // userJSONBytes, _ := json.Marshal(dat)
  35247. // var res ResultTwo
  35248. // var res10265 ResultTwo10265
  35249. // if miConfig.Code == "H15049901371" {
  35250. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35251. // utils.ErrorLog("解析失败:%v", err)
  35252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35253. // return
  35254. // }
  35255. // res.ErrMsg = res10265.ErrMsg
  35256. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35257. // res.Infcode = infocode
  35258. // res.Output = res10265.Output
  35259. // res.InfRefmsgid = res10265.InfRefmsgid
  35260. // } else {
  35261. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35262. // utils.ErrorLog("解析失败:%v", err)
  35263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35264. // return
  35265. // }
  35266. // }
  35267. //
  35268. // var user_name string
  35269. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35270. // if role.ID == 0 {
  35271. // user_name = "xxx"
  35272. // } else {
  35273. // user_name = role.UserName
  35274. // }
  35275. //
  35276. // baseParams := models.BaseParams{
  35277. // SecretKey: miConfig.SecretKey,
  35278. // FixmedinsCode: miConfig.Code,
  35279. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35280. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35281. // OrgName: miConfig.OrgName,
  35282. // Doctor: user_name,
  35283. // }
  35284. //
  35285. // if config.IsOpen == 1 {
  35286. // if miConfig.Code == "H15049901371" {
  35287. // if med_type == "14" {
  35288. // if insutype == "390" {
  35289. // med_type = "9933"
  35290. // } else if insutype == "310" {
  35291. // med_type = "990502"
  35292. // }
  35293. // } else if med_type == "11" {
  35294. // med_type = "11"
  35295. // }
  35296. // }
  35297. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35298. // var dat map[string]interface{}
  35299. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35300. // fmt.Println(dat)
  35301. // } else {
  35302. // fmt.Println(err)
  35303. // }
  35304. // var res Result2001
  35305. // var res10265 Result2001Org10265
  35306. // if miConfig.Code == "H15049901371" {
  35307. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35308. // utils.ErrorLog("解析失败:%v", err)
  35309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35310. // return
  35311. // }
  35312. // res.ErrMsg = res10265.ErrMsg
  35313. // res.Output = res10265.Output
  35314. // res.InfRefmsgid = res10265.InfRefmsgid
  35315. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35316. // res.Infcode = infocode
  35317. // } else {
  35318. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35319. // utils.ErrorLog("解析失败:%v", err)
  35320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35321. // return
  35322. // }
  35323. // }
  35324. // if res.Infcode == 0 {
  35325. // c.ServeSuccessJSON(map[string]interface{}{
  35326. // "msg": res.Output.Trtinfo,
  35327. // })
  35328. // }
  35329. // }
  35330. // }
  35331. //}
  35332. //func (c *HisApiController) PutRecord() {
  35333. // id, _ := c.GetInt64("id")
  35334. // record_time := c.GetString("record_time")
  35335. // timeLayout := "2006-01-02"
  35336. // loc, _ := time.LoadLocation("Local")
  35337. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35338. // if err != nil {
  35339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35340. // return
  35341. // }
  35342. // recordDateTime := theTime.Unix()
  35343. //
  35344. // adminInfo := c.GetAdminUserInfo()
  35345. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35346. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35347. //
  35348. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35349. //
  35350. // fmt.Println(miConfig.SecretKey)
  35351. //
  35352. // if patient == nil {
  35353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35354. // return
  35355. // }
  35356. // if len(patient.IdCardNo) == 0 {
  35357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35358. // return
  35359. // }
  35360. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35361. // if config.IsOpen == 1 {
  35362. // 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
  35363. // resp, requestErr := http.Get(api)
  35364. // if requestErr != nil {
  35365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35366. // return
  35367. // }
  35368. // defer resp.Body.Close()
  35369. // body, ioErr := ioutil.ReadAll(resp.Body)
  35370. // if ioErr != nil {
  35371. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35373. // return
  35374. // }
  35375. // var respJSON map[string]interface{}
  35376. //
  35377. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35380. // return
  35381. // }
  35382. //
  35383. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35384. // userJSONBytes, _ := json.Marshal(userJSON)
  35385. // var res ResultTwo
  35386. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35387. // utils.ErrorLog("解析失败:%v", err)
  35388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35389. // return
  35390. // }
  35391. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35392. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35393. // infoStr := string(Iinfos)
  35394. // idetinfoStr := string(Idetinfos)
  35395. //
  35396. // if res.Infcode == 0 {
  35397. // his := models.VMHisPatient{
  35398. // Status: 1,
  35399. // Ctime: time.Now().Unix(),
  35400. // Mtime: time.Now().Unix(),
  35401. // PsnNo: res.Output.Baseinfo.PsnNo,
  35402. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35403. // Certno: res.Output.Baseinfo.Certno,
  35404. // PsnName: res.Output.Baseinfo.PsnName,
  35405. // Gend: res.Output.Baseinfo.Gend,
  35406. // Naty: res.Output.Baseinfo.Naty,
  35407. // Brdy: res.Output.Baseinfo.Brdy,
  35408. // Age: res.Output.Baseinfo.Age,
  35409. // Iinfo: infoStr,
  35410. // Idetinfo: idetinfoStr,
  35411. // PatientId: patient.ID,
  35412. // RecordDate: theTime.Unix(),
  35413. // UserOrgId: adminInfo.CurrentOrgId,
  35414. // AdminUserId: adminInfo.AdminUser.Id,
  35415. // IsReturn: 1,
  35416. // }
  35417. //
  35418. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35419. // //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")
  35420. // //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")
  35421. //
  35422. // //var dat map[string]interface{}
  35423. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35424. // // fmt.Println(dat)
  35425. // //} else {
  35426. // // fmt.Println(err)
  35427. // //}
  35428. //
  35429. // var dat2 map[string]interface{}
  35430. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35431. // fmt.Println(dat2)
  35432. // } else {
  35433. // fmt.Println(err)
  35434. // }
  35435. //
  35436. // } else {
  35437. // adminUser := c.GetAdminUserInfo()
  35438. // errlog := &models.HisOrderError{
  35439. // UserOrgId: adminUser.CurrentOrgId,
  35440. // Ctime: time.Now().Unix(),
  35441. // Mtime: time.Now().Unix(),
  35442. // ErrMsg: res.ErrMsg,
  35443. // Status: 1,
  35444. // PatientId: id,
  35445. // RecordTime: recordDateTime,
  35446. // Stage: 1,
  35447. // }
  35448. // service.CreateErrMsgLog(errlog)
  35449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35450. // return
  35451. // }
  35452. // }
  35453. //
  35454. //}
  35455. //func (c *HisApiController) GetUploadDiag() {
  35456. // id, _ := c.GetInt64("id")
  35457. // record_time := c.GetString("record_time")
  35458. //
  35459. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35460. // sick_type, _ := c.GetInt64("sick_type")
  35461. // reg_type, _ := c.GetInt64("reg_type")
  35462. //
  35463. // timeLayout := "2006-01-02"
  35464. // loc, _ := time.LoadLocation("Local")
  35465. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35466. // if err != nil {
  35467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35468. // return
  35469. // }
  35470. //
  35471. // var patientPrescription models.HisPrescriptionInfo
  35472. // recordDateTime := theTime.Unix()
  35473. // adminInfo := c.GetAdminUserInfo()
  35474. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35475. //
  35476. // if patientPrescription.ID == 0 {
  35477. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35478. // }
  35479. //
  35480. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35481. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35482. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35483. // sickConfig, _ := service.FindSickById(sick_type)
  35484. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35485. //
  35486. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35487. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35488. // "&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 +
  35489. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35490. // resp2, requestErr2 := http.Get(api2)
  35491. // if requestErr2 != nil {
  35492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35493. // return
  35494. // }
  35495. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35496. // if ioErr2 != nil {
  35497. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35499. // return
  35500. // }
  35501. // var respJSON2 map[string]interface{}
  35502. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35503. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35505. // return
  35506. // }
  35507. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35508. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35509. //
  35510. // var res2 ResultSix
  35511. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35512. // utils.ErrorLog("解析失败:%v", err)
  35513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35514. // return
  35515. // }
  35516. // if res2.Infcode != 0 {
  35517. // adminUser := c.GetAdminUserInfo()
  35518. // errlog := &models.HisOrderError{
  35519. // UserOrgId: adminUser.CurrentOrgId,
  35520. // Ctime: time.Now().Unix(),
  35521. // Mtime: time.Now().Unix(),
  35522. // ErrMsg: res2.ErrMsg,
  35523. // Status: 1,
  35524. // PatientId: id,
  35525. // RecordTime: recordDateTime,
  35526. // Stage: 3,
  35527. // }
  35528. // service.CreateErrMsgLog(errlog)
  35529. //
  35530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35531. // return
  35532. // }
  35533. //
  35534. // c.ServeSuccessJSON(map[string]interface{}{
  35535. // "msg": "上传成功",
  35536. // })
  35537. //
  35538. //}
  35539. type QueryResult struct {
  35540. ID int64
  35541. Name string
  35542. Code string
  35543. List_type_code string
  35544. }
  35545. func (c *HisApiController) GetCheckCode() {
  35546. ids_str := c.GetString("ids")
  35547. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35548. ids_arr := strings.Split(ids_str, ",")
  35549. var queryResult []QueryResult
  35550. ids := make([]int64, 0)
  35551. for _, item := range ids_arr {
  35552. id, _ := strconv.ParseInt(item, 10, 64)
  35553. ids = append(ids, id)
  35554. }
  35555. if record_type == 1 {
  35556. drugs, _ := service.GetBatchDrugList(ids)
  35557. for _, item := range drugs {
  35558. result := QueryResult{
  35559. ID: item.ID,
  35560. Name: item.DrugName,
  35561. Code: item.MedicalInsuranceNumber,
  35562. List_type_code: "101",
  35563. }
  35564. queryResult = append(queryResult, result)
  35565. }
  35566. } else if record_type == 2 {
  35567. goods, _ := service.GetBatchGoodInformationList(ids)
  35568. fmt.Println(goods)
  35569. for _, item := range goods {
  35570. result := QueryResult{
  35571. ID: item.ID,
  35572. Name: item.GoodName,
  35573. Code: item.SocialSecurityDirectoryCode,
  35574. List_type_code: "301",
  35575. }
  35576. queryResult = append(queryResult, result)
  35577. }
  35578. } else if record_type == 3 {
  35579. projects, _ := service.GetBathchMyPorjecgList(ids)
  35580. for _, item := range projects {
  35581. result := QueryResult{
  35582. ID: item.ID,
  35583. Name: item.ProjectName,
  35584. Code: item.MedicalCode,
  35585. List_type_code: "201",
  35586. }
  35587. queryResult = append(queryResult, result)
  35588. }
  35589. }
  35590. admin_user_id, _ := c.GetInt64("admin_user_id")
  35591. adminUser := c.GetAdminUserInfo()
  35592. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35593. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35594. var user_name string
  35595. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35596. if role.ID == 0 {
  35597. user_name = "管理员"
  35598. } else {
  35599. user_name = role.UserName
  35600. }
  35601. baseParams := models.BaseParams{
  35602. SecretKey: miConfig.SecretKey,
  35603. FixmedinsCode: miConfig.Code,
  35604. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35605. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35606. OrgName: miConfig.OrgName,
  35607. Doctor: user_name,
  35608. }
  35609. var result string
  35610. if miConfig.MdtrtareaAdmvs == "430800" {
  35611. for _, item := range queryResult {
  35612. if record_type == 1 {
  35613. 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)
  35614. } else if record_type == 2 {
  35615. fmt.Println(item.Code)
  35616. 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)
  35617. } else if record_type == 3 {
  35618. 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)
  35619. }
  35620. var dat map[string]interface{}
  35621. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35622. fmt.Println(dat)
  35623. } else {
  35624. fmt.Println(err)
  35625. }
  35626. userJSONBytes, _ := json.Marshal(dat)
  35627. var res ResultSix
  35628. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35629. utils.ErrorLog("解析失败:%v", err)
  35630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35631. return
  35632. }
  35633. if res.Infcode == 0 {
  35634. if record_type == 1 {
  35635. service.UpdateBaseDrugById(item.ID)
  35636. } else if record_type == 2 {
  35637. service.UpdateGoodInformaitonByDetail(item.ID)
  35638. } else if record_type == 3 {
  35639. service.UpdateProjectById(item.ID)
  35640. }
  35641. c.ServeSuccessJSON(map[string]interface{}{
  35642. "failed_code": 0,
  35643. "msg": "目录对照成功",
  35644. })
  35645. } else {
  35646. c.ServeSuccessJSON(map[string]interface{}{
  35647. "failed_code": -10,
  35648. "msg": res.ErrMsg,
  35649. })
  35650. }
  35651. }
  35652. } else {
  35653. for _, item := range queryResult {
  35654. var result string
  35655. if record_type == 1 {
  35656. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35657. } else if record_type == 2 {
  35658. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35659. } else if record_type == 3 {
  35660. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35661. }
  35662. var dat map[string]interface{}
  35663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35664. fmt.Println(dat)
  35665. } else {
  35666. fmt.Println(err)
  35667. }
  35668. userJSONBytes, _ := json.Marshal(dat)
  35669. var res ResultSix
  35670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35671. utils.ErrorLog("解析失败:%v", err)
  35672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35673. return
  35674. }
  35675. if res.Infcode == 0 {
  35676. if record_type == 1 {
  35677. service.UpdateBaseDrugById(item.ID)
  35678. } else if record_type == 2 {
  35679. service.UpdateGoodInformaitonByDetail(item.ID)
  35680. } else if record_type == 3 {
  35681. service.UpdateProjectById(item.ID)
  35682. }
  35683. c.ServeSuccessJSON(map[string]interface{}{
  35684. "failed_code": 0,
  35685. "msg": "目录对照成功",
  35686. })
  35687. } else {
  35688. c.ServeSuccessJSON(map[string]interface{}{
  35689. "failed_code": -10,
  35690. "msg": res.ErrMsg,
  35691. })
  35692. }
  35693. }
  35694. }
  35695. }
  35696. func (c *HisApiController) UnCheckCode() {
  35697. ids_str := c.GetString("ids")
  35698. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35699. admin_user_id, _ := c.GetInt64("admin_user_id")
  35700. ids_arr := strings.Split(ids_str, ",")
  35701. var queryResult []QueryResult
  35702. ids := make([]int64, 0)
  35703. for _, item := range ids_arr {
  35704. id, _ := strconv.ParseInt(item, 10, 64)
  35705. ids = append(ids, id)
  35706. }
  35707. if record_type == 1 {
  35708. drugs, _ := service.GetBatchDrugList(ids)
  35709. for _, item := range drugs {
  35710. result := QueryResult{
  35711. ID: item.ID,
  35712. Name: item.DrugName,
  35713. Code: item.MedicalInsuranceNumber,
  35714. List_type_code: "101",
  35715. }
  35716. queryResult = append(queryResult, result)
  35717. }
  35718. } else if record_type == 2 {
  35719. goods, _ := service.GetBatchGoodInformationList(ids)
  35720. for _, item := range goods {
  35721. result := QueryResult{
  35722. ID: item.ID,
  35723. Name: item.GoodName,
  35724. Code: item.SocialSecurityDirectoryCode,
  35725. List_type_code: "301",
  35726. }
  35727. queryResult = append(queryResult, result)
  35728. }
  35729. } else if record_type == 3 {
  35730. projects, _ := service.GetBathchMyPorjecgList(ids)
  35731. for _, item := range projects {
  35732. result := QueryResult{
  35733. ID: item.ID,
  35734. Name: item.ProjectName,
  35735. Code: item.MedicalCode,
  35736. List_type_code: "201",
  35737. }
  35738. queryResult = append(queryResult, result)
  35739. }
  35740. }
  35741. adminUser := c.GetAdminUserInfo()
  35742. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35743. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35744. var user_name string
  35745. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35746. if role.ID == 0 {
  35747. user_name = "xxx"
  35748. } else {
  35749. user_name = role.UserName
  35750. }
  35751. baseParams := &models.BaseParams{
  35752. SecretKey: miConfig.SecretKey,
  35753. FixmedinsCode: miConfig.Code,
  35754. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35755. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35756. OrgName: miConfig.OrgName,
  35757. Doctor: user_name,
  35758. }
  35759. if config.IsOpen == 1 {
  35760. if miConfig.MdtrtareaAdmvs == "430800" {
  35761. for _, item := range queryResult {
  35762. var result string
  35763. if record_type == 1 {
  35764. 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)
  35765. } else if record_type == 2 {
  35766. fmt.Println(item.Code)
  35767. 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)
  35768. } else if record_type == 3 {
  35769. 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)
  35770. }
  35771. var dat map[string]interface{}
  35772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35773. fmt.Println(dat)
  35774. } else {
  35775. fmt.Println(err)
  35776. }
  35777. userJSONBytes, _ := json.Marshal(dat)
  35778. var res ResultSix
  35779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35780. utils.ErrorLog("解析失败:%v", err)
  35781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35782. return
  35783. }
  35784. if res.Infcode == 0 {
  35785. if record_type == 1 {
  35786. service.UpdateBaseDrugById(item.ID)
  35787. } else if record_type == 2 {
  35788. service.UpdateGoodInformaitonByDetail(item.ID)
  35789. } else if record_type == 3 {
  35790. service.UpdateProjectById(item.ID)
  35791. }
  35792. c.ServeSuccessJSON(map[string]interface{}{
  35793. "failed_code": 0,
  35794. "msg": "目录对照成功",
  35795. })
  35796. } else {
  35797. c.ServeSuccessJSON(map[string]interface{}{
  35798. "failed_code": -10,
  35799. "msg": res.ErrMsg,
  35800. })
  35801. }
  35802. }
  35803. } else {
  35804. for _, item := range queryResult {
  35805. var result string
  35806. if record_type == 1 {
  35807. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35808. } else if record_type == 2 {
  35809. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35810. } else if record_type == 3 {
  35811. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35812. }
  35813. var dat2 map[string]interface{}
  35814. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  35815. fmt.Println(dat2)
  35816. } else {
  35817. fmt.Println(err)
  35818. }
  35819. userJSONBytes, _ := json.Marshal(dat2)
  35820. var res ResultSix
  35821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35822. utils.ErrorLog("解析失败:%v", err)
  35823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35824. return
  35825. }
  35826. if res.Infcode == 0 {
  35827. if record_type == 1 {
  35828. service.UpdateDrugByIdDetail(item.ID)
  35829. } else if record_type == 2 {
  35830. service.UpdateGoodInfoById(item.ID)
  35831. } else if record_type == 3 {
  35832. service.UpdateMyProjectById(item.ID)
  35833. }
  35834. c.ServeSuccessJSON(map[string]interface{}{
  35835. "failed_code": 0,
  35836. "msg": "撤销目录对照成功",
  35837. })
  35838. } else {
  35839. c.ServeSuccessJSON(map[string]interface{}{
  35840. "failed_code": -10,
  35841. "msg": res.ErrMsg,
  35842. })
  35843. }
  35844. }
  35845. }
  35846. }
  35847. }
  35848. func (c *HisApiController) GetPatientInfo() {
  35849. id_card_no := c.GetString("id_card_no")
  35850. admin_user_id, _ := c.GetInt64("admin_user_id")
  35851. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  35852. if patient.ID == 0 {
  35853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35854. return
  35855. }
  35856. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  35857. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35858. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  35859. var res ResultTwo
  35860. var res10265 ResultTwo10265
  35861. if config.IsOpen == 1 {
  35862. if miConfig.MdtrtareaAdmvs == "150499" {
  35863. //请求内网数据
  35864. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  35865. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  35866. "&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
  35867. resp, requestErr := http.Get(api)
  35868. if requestErr != nil {
  35869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35870. return
  35871. }
  35872. body, ioErr := ioutil.ReadAll(resp.Body)
  35873. if ioErr != nil {
  35874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35876. return
  35877. }
  35878. var respJSON map[string]interface{}
  35879. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35882. return
  35883. }
  35884. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35885. result_byte, _ := json.Marshal(respJSON)
  35886. result := string(result_byte)
  35887. var dat map[string]interface{}
  35888. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35889. fmt.Println(dat)
  35890. } else {
  35891. fmt.Println(err)
  35892. }
  35893. userJSONBytes, _ := json.Marshal(dat)
  35894. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35895. utils.ErrorLog("解析失败:%v", err)
  35896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35897. return
  35898. }
  35899. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35900. res.Infcode = Infcode
  35901. res.ErrMsg = res10265.ErrMsg
  35902. res.Output = res10265.Output
  35903. res.InfRefmsgid = res10265.InfRefmsgid
  35904. res.RespondTime = res10265.RespondTime
  35905. res.WarnInfo = res10265.WarnInfo
  35906. } else {
  35907. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35908. var dat map[string]interface{}
  35909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35910. fmt.Println(dat)
  35911. } else {
  35912. fmt.Println(err)
  35913. }
  35914. userJSONBytes, _ := json.Marshal(dat)
  35915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35916. utils.ErrorLog("解析失败:%v", err)
  35917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35918. return
  35919. }
  35920. }
  35921. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35922. // utils.ErrorLog("解析失败:%v", err)
  35923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35924. // return
  35925. //}
  35926. for index, item := range res.Output.Iinfo {
  35927. if item.PsnInsuStas == "2" {
  35928. fmt.Println("--------")
  35929. res.Output.Iinfo[index].Insutype = "300"
  35930. res.Output.Iinfo[index].PsnInsuStas = "1"
  35931. }
  35932. }
  35933. fmt.Println(res.Output.Iinfo)
  35934. if res.Infcode != 0 {
  35935. c.ServeSuccessJSON(map[string]interface{}{
  35936. "failed_code": -10,
  35937. "msg": res.ErrMsg,
  35938. })
  35939. } else {
  35940. c.ServeSuccessJSON(map[string]interface{}{
  35941. "failed_code": 0,
  35942. "info": res,
  35943. })
  35944. }
  35945. }
  35946. }
  35947. func (c *HisApiController) PsnPutOnRecord() {
  35948. record_type, _ := c.GetInt64("type")
  35949. patient_id, _ := c.GetInt64("patient_id")
  35950. admin_user_id, _ := c.GetInt64("admin_user_id")
  35951. start_time := c.GetString("start_time")
  35952. end_time := c.GetString("end_time")
  35953. adminUser := c.GetAdminUserInfo()
  35954. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35955. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35956. var patients []*models.Patients
  35957. if record_type == 1 { //全部备案
  35958. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  35959. patients = append(patients, patient...)
  35960. } else { //单个备案
  35961. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35962. patients = append(patients, patient)
  35963. }
  35964. var user_name string
  35965. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35966. if role.ID == 0 {
  35967. user_name = "xxx"
  35968. } else {
  35969. user_name = role.UserName
  35970. }
  35971. if config.IsOpen == 1 {
  35972. for _, item := range patients {
  35973. 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
  35974. resp, requestErr := http.Get(api)
  35975. if requestErr != nil {
  35976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35977. return
  35978. }
  35979. defer resp.Body.Close()
  35980. body, ioErr := ioutil.ReadAll(resp.Body)
  35981. if ioErr != nil {
  35982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35984. return
  35985. }
  35986. var respJSON map[string]interface{}
  35987. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35990. return
  35991. }
  35992. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35993. userJSONBytes, _ := json.Marshal(userJSON)
  35994. var res ResultTwo
  35995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35996. utils.ErrorLog("解析失败:%v", err)
  35997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35998. return
  35999. }
  36000. if res.Infcode == 0 {
  36001. 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)
  36002. var dat map[string]interface{}
  36003. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36004. fmt.Println(dat)
  36005. } else {
  36006. fmt.Println(err)
  36007. }
  36008. userJSONBytes, _ := json.Marshal(dat)
  36009. var res2 ResultThirteen
  36010. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36011. utils.ErrorLog("解析失败:%v", err)
  36012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36013. return
  36014. }
  36015. if res2.Infcode == 0 {
  36016. psnResult := &models.GdybPsnRecord{
  36017. UserOrgId: adminUser.CurrentOrgId,
  36018. PatientId: item.ID,
  36019. PsnNo: res.Output.Baseinfo.PsnNo,
  36020. Ctime: time.Now().Unix(),
  36021. Mtime: time.Now().Unix(),
  36022. Status: 1,
  36023. IsCancel: 1,
  36024. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36025. }
  36026. service.CreatePsnRecord(psnResult)
  36027. } else {
  36028. c.ServeSuccessJSON(map[string]interface{}{
  36029. "failed_code": -10,
  36030. "msg": res2.ErrMsg,
  36031. })
  36032. return
  36033. }
  36034. }
  36035. }
  36036. }
  36037. }
  36038. func (c *HisApiController) PsnUnPutOnRecord() {
  36039. id, _ := c.GetInt64("id")
  36040. //record_type, _ := c.GetInt64("type")
  36041. admin_user_id, _ := c.GetInt64("admin_user_id")
  36042. adminUser := c.GetAdminUserInfo()
  36043. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36044. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36045. var user_name string
  36046. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36047. if role.ID == 0 {
  36048. user_name = "xxx"
  36049. } else {
  36050. user_name = role.UserName
  36051. }
  36052. psn_record, _ := service.GetPsnRecordById(id)
  36053. if psn_record.ID == 0 {
  36054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36055. return
  36056. }
  36057. if config.IsOpen == 1 {
  36058. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36059. var dat map[string]interface{}
  36060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36061. fmt.Println(dat)
  36062. } else {
  36063. fmt.Println(err)
  36064. }
  36065. userJSONBytes, _ := json.Marshal(dat)
  36066. var res ResultFourteen
  36067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36068. utils.ErrorLog("解析失败:%v", err)
  36069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36070. return
  36071. }
  36072. if res.Infcode == 0 {
  36073. psn_record.IsCancel = 2
  36074. service.CreatePsnRecord(&psn_record)
  36075. } else {
  36076. c.ServeSuccessJSON(map[string]interface{}{
  36077. "failed_code": -10,
  36078. "msg": res.ErrMsg,
  36079. })
  36080. return
  36081. }
  36082. }
  36083. }
  36084. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36085. patient_id, _ := c.GetInt64("patient_id")
  36086. insutype_two := c.GetString("insutype")
  36087. psn_no := c.GetString("psn_no")
  36088. doctor_id, _ := c.GetInt64("doctor_id")
  36089. sick_id, _ := c.GetInt64("sick_id")
  36090. department_id, _ := c.GetInt64("department_id")
  36091. start_time := c.GetString("start_time")
  36092. end_time := c.GetString("end_time")
  36093. check_time := c.GetString("check_time")
  36094. hospital_code := c.GetString("hospital_code")
  36095. hospital_name := c.GetString("hospital_name")
  36096. adminUser := c.GetAdminUserInfo()
  36097. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36098. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36099. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36100. sick, _ := service.FindSickById(sick_id)
  36101. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36102. if len(hospital_code) == 0 {
  36103. hospital_code = miConfig.Code
  36104. }
  36105. if len(hospital_name) == 0 {
  36106. hospital_name = miConfig.OrgName
  36107. }
  36108. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36109. var res ResultTwo
  36110. var res10265 ResultTwo10265
  36111. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36112. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36113. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36114. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36115. "&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
  36116. resp, requestErr := http.Get(api)
  36117. if requestErr != nil {
  36118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36119. return
  36120. }
  36121. body, ioErr := ioutil.ReadAll(resp.Body)
  36122. if ioErr != nil {
  36123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36125. return
  36126. }
  36127. var respJSON map[string]interface{}
  36128. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36131. return
  36132. }
  36133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36134. result, _ := json.Marshal(respJSON)
  36135. fmt.Println("log")
  36136. fmt.Println(string(result))
  36137. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36138. utils.ErrorLog("解析失败:%v", err)
  36139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36140. return
  36141. }
  36142. res.ErrMsg = res10265.ErrMsg
  36143. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36144. res.Infcode = infocode
  36145. res.Output = res10265.Output
  36146. res.InfRefmsgid = res10265.InfRefmsgid
  36147. } else {
  36148. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36149. if miConfig.Code == "H15049901371" {
  36150. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36151. utils.ErrorLog("解析失败:%v", err)
  36152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36153. return
  36154. }
  36155. res.ErrMsg = res10265.ErrMsg
  36156. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36157. res.Infcode = infocode
  36158. res.Output = res10265.Output
  36159. res.InfRefmsgid = res10265.InfRefmsgid
  36160. } else {
  36161. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36162. utils.ErrorLog("解析失败:%v", err)
  36163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36164. return
  36165. }
  36166. }
  36167. }
  36168. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36169. infoStr := string(Iinfos)
  36170. var rf []*ResultFive
  36171. json.Unmarshal([]byte(infoStr), &rf)
  36172. var insuplc_admdvs string
  36173. var insutype string
  36174. var is390 int = 0
  36175. var is310 int = 0
  36176. var insutypes []*ResultFive
  36177. for _, item := range rf {
  36178. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36179. insutypes = append(insutypes, item)
  36180. }
  36181. }
  36182. if len(insutypes) == 1 {
  36183. insutype = insutypes[0].Insutype
  36184. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36185. } else {
  36186. for _, i := range insutypes {
  36187. if i.Insutype == "390" {
  36188. is390 = 1
  36189. }
  36190. if i.Insutype == "310" {
  36191. is310 = 1
  36192. }
  36193. }
  36194. }
  36195. if is390 == 1 {
  36196. insutype = "390"
  36197. }
  36198. if is310 == 1 {
  36199. insutype = "310"
  36200. }
  36201. if len(insutypes) == 2 {
  36202. insutype = insutype_two
  36203. }
  36204. if len(insutypes) == 0 {
  36205. insutype = "310"
  36206. }
  36207. insutype = insutype_two
  36208. fmt.Println(insutype)
  36209. for _, item := range rf {
  36210. fmt.Println(item.Insutype)
  36211. fmt.Println(insutype)
  36212. if item.Insutype == insutype {
  36213. fmt.Println(item.Insutype)
  36214. fmt.Println(insutype)
  36215. insuplc_admdvs = item.InsuplcAdmdvs
  36216. }
  36217. }
  36218. fmt.Println(insuplc_admdvs)
  36219. var res2 ResultThirteen
  36220. var res10265_2 ResultThirteen10265
  36221. if config.IsOpen == 1 {
  36222. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36223. } else {
  36224. if miConfig.MdtrtareaAdmvs == "150499" {
  36225. //
  36226. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36227. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36228. // "&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
  36229. //resp, requestErr := http.Get(api)
  36230. //if requestErr != nil {
  36231. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36232. // return
  36233. //}
  36234. //
  36235. //body, ioErr := ioutil.ReadAll(resp.Body)
  36236. //if ioErr != nil {
  36237. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36239. // return
  36240. //}
  36241. //var respJSON map[string]interface{}
  36242. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36243. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36245. // return
  36246. //}
  36247. //
  36248. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36249. //result, _ := json.Marshal(respJSON)
  36250. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36251. // utils.ErrorLog("解析失败:%v", err)
  36252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36253. // return
  36254. //}
  36255. //infocode = resThree.Infcode
  36256. //result, _ := json.Marshal(respJSON)
  36257. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36258. // utils.ErrorLog("解析失败:%v", err)
  36259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36260. // return
  36261. //}
  36262. //
  36263. //resThree.ErrMsg = resThree10265.ErrMsg
  36264. //
  36265. //resThree.Output = resThree10265.Output
  36266. //
  36267. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36268. //
  36269. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36270. //
  36271. } else {
  36272. 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)
  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 miConfig.Code == "H15049901371" {
  36281. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36282. utils.ErrorLog("解析失败:%v", err)
  36283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36284. return
  36285. }
  36286. res2.ErrMsg = res10265_2.ErrMsg
  36287. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36288. res2.Infcode = infocode
  36289. res2.Output = res10265_2.Output
  36290. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36291. } else {
  36292. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36293. utils.ErrorLog("解析失败:%v", err)
  36294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36295. return
  36296. }
  36297. }
  36298. }
  36299. }
  36300. if res2.Infcode == 0 {
  36301. psnResult := &models.GdybPsnNcdsRecord{
  36302. UserOrgId: adminUser.CurrentOrgId,
  36303. PatientId: patient.ID,
  36304. PsnNo: psn_no,
  36305. DoctorId: doctor.AdminUserId,
  36306. DepartmentId: department_id,
  36307. SickType: sick_id,
  36308. Insutype: insutype,
  36309. Ctime: time.Now().Unix(),
  36310. Mtime: time.Now().Unix(),
  36311. Status: 1,
  36312. IsCancel: 1,
  36313. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36314. }
  36315. service.CreatePsnNCDSRecord(psnResult)
  36316. c.ServeSuccessJSON(map[string]interface{}{
  36317. "failed_code": 0,
  36318. "msg": "备案成功",
  36319. "result": psnResult,
  36320. })
  36321. } else {
  36322. c.ServeSuccessJSON(map[string]interface{}{
  36323. "failed_code": -10,
  36324. "msg": res2.ErrMsg,
  36325. })
  36326. return
  36327. }
  36328. }
  36329. }
  36330. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36331. id, _ := c.GetInt64("id")
  36332. admin_user_id, _ := c.GetInt64("admin_user_id")
  36333. adminUser := c.GetAdminUserInfo()
  36334. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36335. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36336. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36337. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36338. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36339. //var user_name string
  36340. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36341. //if role.ID == 0 {
  36342. // user_name = "xxx"
  36343. //} else {
  36344. // user_name = role.UserName
  36345. //}
  36346. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36347. if psn_record.ID == 0 {
  36348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36349. return
  36350. }
  36351. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36352. var res ResultTwo
  36353. var res10265 ResultTwo10265
  36354. if miConfig.Code == "H15049901371" {
  36355. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36356. utils.ErrorLog("解析失败:%v", err)
  36357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36358. return
  36359. }
  36360. res.ErrMsg = res10265.ErrMsg
  36361. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36362. res.Infcode = infocode
  36363. res.Output = res10265.Output
  36364. res.InfRefmsgid = res10265.InfRefmsgid
  36365. } else {
  36366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36367. utils.ErrorLog("解析失败:%v", err)
  36368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36369. return
  36370. }
  36371. }
  36372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36373. infoStr := string(Iinfos)
  36374. var rf []*ResultFive
  36375. json.Unmarshal([]byte(infoStr), &rf)
  36376. var insuplc_admdvs string
  36377. var insutype string
  36378. var is390 int = 0
  36379. var is310 int = 0
  36380. var insutypes []*ResultFive
  36381. for _, item := range rf {
  36382. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36383. insutypes = append(insutypes, item)
  36384. }
  36385. }
  36386. if len(insutypes) == 1 {
  36387. insutype = insutypes[0].Insutype
  36388. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36389. } else {
  36390. for _, i := range insutypes {
  36391. if i.Insutype == "390" {
  36392. is390 = 1
  36393. }
  36394. if i.Insutype == "310" {
  36395. is310 = 1
  36396. }
  36397. }
  36398. }
  36399. if is390 == 1 {
  36400. insutype = "390"
  36401. }
  36402. if is310 == 1 {
  36403. insutype = "310"
  36404. }
  36405. if len(insutypes) == 0 {
  36406. insutype = "310"
  36407. }
  36408. insutype = psn_record.Insutype
  36409. for _, item := range rf {
  36410. if item.Insutype == insutype {
  36411. insuplc_admdvs = item.InsuplcAdmdvs
  36412. }
  36413. }
  36414. if config.IsOpen == 1 {
  36415. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36416. var dat map[string]interface{}
  36417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36418. fmt.Println(dat)
  36419. } else {
  36420. fmt.Println(err)
  36421. }
  36422. userJSONBytes, _ := json.Marshal(dat)
  36423. var res ResultFourteen
  36424. var res10265 ResultFourteen10265
  36425. if miConfig.Code == "H15049901371" {
  36426. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36427. utils.ErrorLog("解析失败:%v", err)
  36428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36429. return
  36430. }
  36431. res.ErrMsg = res10265.ErrMsg
  36432. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36433. res.Infcode = infocode
  36434. res.Output = res10265.Output
  36435. res.InfRefmsgid = res10265.InfRefmsgid
  36436. } else {
  36437. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36438. utils.ErrorLog("解析失败:%v", err)
  36439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36440. return
  36441. }
  36442. }
  36443. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36444. // utils.ErrorLog("解析失败:%v", err)
  36445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36446. // return
  36447. //}
  36448. if res.Infcode == 0 {
  36449. psn_record.IsCancel = 2
  36450. service.CreatePsnNCDSRecord(&psn_record)
  36451. c.ServeSuccessJSON(map[string]interface{}{
  36452. "failed_code": 0,
  36453. "msg": "撤销备案成功",
  36454. })
  36455. } else {
  36456. c.ServeSuccessJSON(map[string]interface{}{
  36457. "failed_code": -10,
  36458. "msg": res.ErrMsg,
  36459. })
  36460. return
  36461. }
  36462. }
  36463. }
  36464. func (c *HisApiController) TestTest() {
  36465. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36466. fmt.Println(patient.Iinfo)
  36467. }
  36468. type CustomData struct {
  36469. MsgId string
  36470. PsnNo string
  36471. Info string
  36472. }
  36473. func (c *HisApiController) ReversalData() {
  36474. var customData []*CustomData
  36475. custom := &CustomData{
  36476. MsgId: "H44022900158202103301714472004",
  36477. PsnNo: "44020000001101329945",
  36478. Info: "2207",
  36479. }
  36480. customData = append(customData, custom)
  36481. custom1 := &CustomData{
  36482. MsgId: "H4402290015820210330172057803",
  36483. PsnNo: "44020000001101161813",
  36484. Info: "2207",
  36485. }
  36486. customData = append(customData, custom1)
  36487. custom2 := &CustomData{
  36488. MsgId: "H44022900158202103301705198813",
  36489. PsnNo: "44190000133097375417",
  36490. Info: "2207",
  36491. }
  36492. customData = append(customData, custom2)
  36493. custom3 := &CustomData{
  36494. MsgId: "H44022900158202103301715524756",
  36495. PsnNo: "44020000001100187221",
  36496. Info: "2207",
  36497. }
  36498. customData = append(customData, custom3)
  36499. custom4 := &CustomData{
  36500. MsgId: "H44022900158202103301730376224",
  36501. PsnNo: "44020000001101959155",
  36502. Info: "2207",
  36503. }
  36504. customData = append(customData, custom4)
  36505. custom5 := &CustomData{
  36506. MsgId: "H44022900158202103301748008725",
  36507. PsnNo: "44020000001104246641",
  36508. Info: "2207",
  36509. }
  36510. customData = append(customData, custom5)
  36511. custom6 := &CustomData{
  36512. MsgId: "H44022900158202103301718096755",
  36513. PsnNo: "44020000001102211860",
  36514. Info: "2207",
  36515. }
  36516. customData = append(customData, custom6)
  36517. custom7 := &CustomData{
  36518. MsgId: "H44022900158202103301736551640",
  36519. PsnNo: "44020000001102687718",
  36520. Info: "2207",
  36521. }
  36522. customData = append(customData, custom7)
  36523. custom8 := &CustomData{
  36524. MsgId: "H44022900158202103301743097676",
  36525. PsnNo: "44020000001102127785",
  36526. Info: "2207",
  36527. }
  36528. customData = append(customData, custom8)
  36529. custom9 := &CustomData{
  36530. MsgId: "H44022900158202103301712304203",
  36531. PsnNo: "44020000001101518097",
  36532. Info: "2207",
  36533. }
  36534. customData = append(customData, custom9)
  36535. custom10 := &CustomData{
  36536. MsgId: "H44022900158202103301738448785",
  36537. PsnNo: "44020000001100500813",
  36538. Info: "2207",
  36539. }
  36540. customData = append(customData, custom10)
  36541. custom11 := &CustomData{
  36542. MsgId: "H44022900158202103301732455843",
  36543. PsnNo: "44020000001102690557",
  36544. Info: "2207",
  36545. }
  36546. customData = append(customData, custom11)
  36547. custom12 := &CustomData{
  36548. MsgId: "H44022900158202103301745421708",
  36549. PsnNo: "44020000001102211928",
  36550. Info: "2207",
  36551. }
  36552. customData = append(customData, custom12)
  36553. custom1212 := &CustomData{
  36554. MsgId: "H440229001582021033017351627",
  36555. PsnNo: "44020000001102481733",
  36556. Info: "2207",
  36557. }
  36558. customData = append(customData, custom1212)
  36559. custom13 := &CustomData{
  36560. MsgId: "H44022900158202103301740327951",
  36561. PsnNo: "44020000001103174866",
  36562. Info: "2207",
  36563. }
  36564. customData = append(customData, custom13)
  36565. custom14 := &CustomData{
  36566. MsgId: "H4402290015820210330174922668",
  36567. PsnNo: "44020000001102927272",
  36568. Info: "2207",
  36569. }
  36570. customData = append(customData, custom14)
  36571. custom15 := &CustomData{
  36572. MsgId: "H44022900158202103301752362273",
  36573. PsnNo: "44020000001102942890",
  36574. Info: "2207",
  36575. }
  36576. customData = append(customData, custom15)
  36577. custom16 := &CustomData{
  36578. MsgId: "H44022900158202103301751082917",
  36579. PsnNo: "44020000001101662162",
  36580. Info: "2207",
  36581. }
  36582. customData = append(customData, custom16)
  36583. custom17 := &CustomData{
  36584. MsgId: "H44022900158202103301754147728",
  36585. PsnNo: "44020000000229014511",
  36586. Info: "2207",
  36587. }
  36588. customData = append(customData, custom17)
  36589. adminUser := c.GetAdminUserInfo()
  36590. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36591. for _, item := range customData {
  36592. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36593. fmt.Println(result)
  36594. }
  36595. }
  36596. func (c *HisApiController) GetAllopatry() {
  36597. year := c.GetString("year")
  36598. month := c.GetString("month")
  36599. admin_user_id, _ := c.GetInt64("admin_user_id")
  36600. adminUser := c.GetAdminUserInfo()
  36601. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36602. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36603. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36604. var dat map[string]interface{}
  36605. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36606. fmt.Println(dat)
  36607. } else {
  36608. fmt.Println(err)
  36609. }
  36610. userJSONBytes, _ := json.Marshal(dat)
  36611. var res models.Result9001
  36612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36613. utils.ErrorLog("解析失败:%v", err)
  36614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36615. return
  36616. }
  36617. fmt.Println(res.Output.Signinoutb)
  36618. fmt.Println(res.Output.Signinoutb.SignNo)
  36619. fmt.Println(string(userJSONBytes))
  36620. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36621. var dat3 map[string]interface{}
  36622. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36623. fmt.Println(dat3)
  36624. } else {
  36625. fmt.Println(err)
  36626. }
  36627. userJSONBytes3, _ := json.Marshal(dat3)
  36628. var res3 models.Result3260
  36629. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36630. utils.ErrorLog("解析失败:%v", err)
  36631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36632. return
  36633. }
  36634. var curpage int
  36635. var pagesize int = 100
  36636. var start int = 1
  36637. //var stop int
  36638. //pagecount := 10
  36639. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36640. var res22 []models.Result3260
  36641. for curpage = 1; curpage <= pagecount; curpage++ {
  36642. if curpage == 1 {
  36643. start = 0
  36644. } else {
  36645. start = (curpage-1)*pagesize + 1
  36646. }
  36647. fmt.Println(start)
  36648. //stop = curpage * pagesize
  36649. //if stop > int(res3.Output.Totalrow) {
  36650. // stop =int(res3.Output.Totalrow)
  36651. //}
  36652. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36653. var dat2 map[string]interface{}
  36654. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36655. fmt.Println(dat)
  36656. } else {
  36657. fmt.Println(err)
  36658. }
  36659. userJSONBytes2, _ := json.Marshal(dat2)
  36660. var res2 models.Result3260
  36661. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36662. utils.ErrorLog("解析失败:%v", err)
  36663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36664. return
  36665. }
  36666. if res2.Infcode == 0 {
  36667. res22 = append(res22, res2)
  36668. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36669. //var dat2 map[string]interface{}
  36670. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36671. // fmt.Println(dat)
  36672. //} else {
  36673. // fmt.Println(err)
  36674. //}
  36675. //c.ServeSuccessJSON(map[string]interface{}{
  36676. // "list": res2.Output.Data,
  36677. //})
  36678. //continue
  36679. }
  36680. }
  36681. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36682. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36683. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  36684. //var dat2 map[string]interface{}
  36685. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36686. // fmt.Println(dat)
  36687. //} else {
  36688. // fmt.Println(err)
  36689. //}
  36690. //userJSONBytes2, _ := json.Marshal(dat2)
  36691. //var res2 models.Result3260
  36692. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36693. // utils.ErrorLog("解析失败:%v", err)
  36694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36695. // return
  36696. //}
  36697. //if res2.Infcode == 0 {
  36698. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36699. // var dat2 map[string]interface{}
  36700. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36701. // fmt.Println(dat)
  36702. // } else {
  36703. // fmt.Println(err)
  36704. // }
  36705. // c.ServeSuccessJSON(map[string]interface{}{
  36706. // "list": res2.Output.Data,
  36707. // })
  36708. //}
  36709. }
  36710. func (c *HisApiController) ComfirmAllopatry() {
  36711. year := c.GetString("year")
  36712. month := c.GetString("month")
  36713. admin_user_id, _ := c.GetInt64("admin_user_id")
  36714. adminUser := c.GetAdminUserInfo()
  36715. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36716. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36717. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36718. var dat map[string]interface{}
  36719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36720. fmt.Println(dat)
  36721. } else {
  36722. fmt.Println(err)
  36723. }
  36724. userJSONBytes, _ := json.Marshal(dat)
  36725. var res models.Result9001
  36726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36727. utils.ErrorLog("解析失败:%v", err)
  36728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36729. return
  36730. }
  36731. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36732. var dat2 map[string]interface{}
  36733. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36734. fmt.Println(dat)
  36735. } else {
  36736. fmt.Println(err)
  36737. }
  36738. userJSONBytes2, _ := json.Marshal(dat2)
  36739. var res2 models.Result3260
  36740. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36741. utils.ErrorLog("解析失败:%v", err)
  36742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36743. return
  36744. }
  36745. //if res2.Infcode == 0 {
  36746. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36747. // var dat map[string]interface{}
  36748. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36749. // fmt.Println(dat)
  36750. // } else {
  36751. // fmt.Println(err)
  36752. // }
  36753. // userJSONBytes, _ := json.Marshal(dat)
  36754. // var res3 models.Result3261
  36755. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  36756. // utils.ErrorLog("解析失败:%v", err)
  36757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36758. // return
  36759. // }
  36760. //
  36761. // if res3.Infcode == 0 {
  36762. // record := &models.HisYidiClearRecord{
  36763. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36764. // Ctime: time.Now().Unix(),
  36765. // Mtime: time.Now().Unix(),
  36766. // Status: 1,
  36767. // MsgId: msgId,
  36768. // }
  36769. // service.SaveClearRecord(record)
  36770. // c.ServeSuccessJSON(map[string]interface{}{
  36771. // "msg": "提取成功",
  36772. // })
  36773. // }
  36774. //}
  36775. }
  36776. func (c *HisApiController) RefundAllopatry() {
  36777. year := c.GetString("year")
  36778. month := c.GetString("month")
  36779. //id, _ := c.GetInt64("id")
  36780. admin_user_id, _ := c.GetInt64("admin_user_id")
  36781. adminUser := c.GetAdminUserInfo()
  36782. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36783. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36784. //record, _ := service.GetClearRecordById(id)
  36785. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36786. var dat map[string]interface{}
  36787. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  36788. fmt.Println(dat)
  36789. } else {
  36790. fmt.Println(err)
  36791. }
  36792. userJSONBytes, _ := json.Marshal(dat)
  36793. var res models.Result9001
  36794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36795. utils.ErrorLog("解析失败:%v", err)
  36796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36797. return
  36798. }
  36799. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  36800. var dat2 map[string]interface{}
  36801. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36802. fmt.Println(dat)
  36803. } else {
  36804. fmt.Println(err)
  36805. }
  36806. userJSONBytes2, _ := json.Marshal(dat2)
  36807. var empty ResultFourteen
  36808. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  36809. utils.ErrorLog("解析失败:%v", err)
  36810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36811. return
  36812. }
  36813. if empty.Infcode == 0 {
  36814. c.ServeSuccessJSON(map[string]interface{}{
  36815. "msg": "撤销成功",
  36816. })
  36817. return
  36818. }
  36819. }
  36820. func (c *HisApiController) ReversalOtherData() {
  36821. var customData []*CustomData
  36822. custom := &CustomData{
  36823. MsgId: "H44022900158202103301714472004",
  36824. PsnNo: "44020000001101329945",
  36825. Info: "2208",
  36826. }
  36827. customData = append(customData, custom)
  36828. custom1 := &CustomData{
  36829. MsgId: "H4402290015820210330172057803",
  36830. PsnNo: "44020000001101161813",
  36831. Info: "2208",
  36832. }
  36833. customData = append(customData, custom1)
  36834. custom2 := &CustomData{
  36835. MsgId: "H44022900158202103301705198813",
  36836. PsnNo: "44190000133097375417",
  36837. Info: "2208",
  36838. }
  36839. customData = append(customData, custom2)
  36840. custom3 := &CustomData{
  36841. MsgId: "H44022900158202103301715524756",
  36842. PsnNo: "44020000001100187221",
  36843. Info: "2208",
  36844. }
  36845. customData = append(customData, custom3)
  36846. custom4 := &CustomData{
  36847. MsgId: "H44022900158202103301730376224",
  36848. PsnNo: "44020000001101959155",
  36849. Info: "2208",
  36850. }
  36851. customData = append(customData, custom4)
  36852. custom5 := &CustomData{
  36853. MsgId: "H44022900158202103301748008725",
  36854. PsnNo: "44020000001104246641",
  36855. Info: "2208",
  36856. }
  36857. customData = append(customData, custom5)
  36858. custom6 := &CustomData{
  36859. MsgId: "H44022900158202103301718096755",
  36860. PsnNo: "44020000001102211860",
  36861. Info: "2208",
  36862. }
  36863. customData = append(customData, custom6)
  36864. custom7 := &CustomData{
  36865. MsgId: "H44022900158202103301736551640",
  36866. PsnNo: "44020000001102687718",
  36867. Info: "2208",
  36868. }
  36869. customData = append(customData, custom7)
  36870. custom8 := &CustomData{
  36871. MsgId: "H44022900158202103301743097676",
  36872. PsnNo: "44020000001102127785",
  36873. Info: "2208",
  36874. }
  36875. customData = append(customData, custom8)
  36876. custom9 := &CustomData{
  36877. MsgId: "H44022900158202103301712304203",
  36878. PsnNo: "44020000001101518097",
  36879. Info: "2208",
  36880. }
  36881. customData = append(customData, custom9)
  36882. custom10 := &CustomData{
  36883. MsgId: "H44022900158202103301738448785",
  36884. PsnNo: "44020000001100500813",
  36885. Info: "2208",
  36886. }
  36887. customData = append(customData, custom10)
  36888. custom11 := &CustomData{
  36889. MsgId: "H44022900158202103301732455843",
  36890. PsnNo: "44020000001102690557",
  36891. Info: "2208",
  36892. }
  36893. customData = append(customData, custom11)
  36894. custom12 := &CustomData{
  36895. MsgId: "H44022900158202103301745421708",
  36896. PsnNo: "44020000001102211928",
  36897. Info: "2208",
  36898. }
  36899. customData = append(customData, custom12)
  36900. custom1212 := &CustomData{
  36901. MsgId: "H440229001582021033017351627",
  36902. PsnNo: "44020000001102481733",
  36903. Info: "2208",
  36904. }
  36905. customData = append(customData, custom1212)
  36906. custom13 := &CustomData{
  36907. MsgId: "H44022900158202103301740327951",
  36908. PsnNo: "44020000001103174866",
  36909. Info: "2208",
  36910. }
  36911. customData = append(customData, custom13)
  36912. custom14 := &CustomData{
  36913. MsgId: "H4402290015820210330174922668",
  36914. PsnNo: "44020000001102927272",
  36915. Info: "2208",
  36916. }
  36917. customData = append(customData, custom14)
  36918. custom15 := &CustomData{
  36919. MsgId: "H44022900158202103301752362273",
  36920. PsnNo: "44020000001102942890",
  36921. Info: "2208",
  36922. }
  36923. customData = append(customData, custom15)
  36924. custom16 := &CustomData{
  36925. MsgId: "H44022900158202103301751082917",
  36926. PsnNo: "44020000001101662162",
  36927. Info: "2208",
  36928. }
  36929. customData = append(customData, custom16)
  36930. custom17 := &CustomData{
  36931. MsgId: "H44022900158202103301754147728",
  36932. PsnNo: "44020000000229014511",
  36933. Info: "2208",
  36934. }
  36935. customData = append(customData, custom17)
  36936. adminUser := c.GetAdminUserInfo()
  36937. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36938. for _, item := range customData {
  36939. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36940. fmt.Println(result)
  36941. }
  36942. }
  36943. func PathExists(path string) (bool, error) {
  36944. _, err := os.Stat(path)
  36945. if err == nil {
  36946. return true, nil
  36947. }
  36948. if os.IsNotExist(err) {
  36949. return false, nil
  36950. }
  36951. return false, err
  36952. }
  36953. // 创建文件夹
  36954. func Mkdir(dir string) {
  36955. // 创建文件夹
  36956. exist, err := PathExists(dir)
  36957. if err != nil {
  36958. fmt.Println(err.Error())
  36959. } else {
  36960. if exist {
  36961. fmt.Println(dir + "文件夹已存在!")
  36962. } else {
  36963. // 文件夹名称,权限
  36964. err := os.Mkdir(dir, os.ModePerm)
  36965. if err != nil {
  36966. fmt.Println(dir+"文件夹创建失败:", err.Error())
  36967. } else {
  36968. fmt.Println(dir + "文件夹创建成功!")
  36969. }
  36970. }
  36971. }
  36972. }
  36973. // 压缩文件
  36974. func Zip(srcFile string, destZip string) error {
  36975. zipfile, err := os.Create(destZip)
  36976. if err != nil {
  36977. return err
  36978. }
  36979. defer zipfile.Close()
  36980. archive := zip.NewWriter(zipfile)
  36981. defer archive.Close()
  36982. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  36983. if err != nil {
  36984. return err
  36985. }
  36986. header, err := zip.FileInfoHeader(info)
  36987. if err != nil {
  36988. return err
  36989. }
  36990. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  36991. // header.Name = path
  36992. if info.IsDir() {
  36993. header.Name += "/"
  36994. } else {
  36995. header.Method = zip.Deflate
  36996. }
  36997. writer, err := archive.CreateHeader(header)
  36998. if err != nil {
  36999. return err
  37000. }
  37001. if !info.IsDir() {
  37002. file, err := os.Open(path)
  37003. if err != nil {
  37004. return err
  37005. }
  37006. defer file.Close()
  37007. _, err = io.Copy(writer, file)
  37008. }
  37009. return err
  37010. })
  37011. return err
  37012. }
  37013. func ReadFile(filePath string) []byte {
  37014. f, err := os.Open(filePath)
  37015. if err != nil {
  37016. fmt.Println("read file fail", err)
  37017. return nil
  37018. }
  37019. defer f.Close()
  37020. fd, err := ioutil.ReadAll(f)
  37021. if err != nil {
  37022. fmt.Println("read to fd fail", err)
  37023. return nil
  37024. }
  37025. return fd
  37026. }
  37027. func saveLogq(result string, request string, infno string, desc string) {
  37028. dir := "日志"
  37029. utils.Mkdir(dir)
  37030. month := time.Unix(1557042972, 0).Format("1")
  37031. year := time.Now().Format("2006")
  37032. month = time.Now().Format("01")
  37033. day := time.Now().Format("02")
  37034. hour := time.Now().Format("15")
  37035. min := time.Now().Format("04")
  37036. sec := time.Now().Format("05")
  37037. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37038. file := year + month + day + "_log"
  37039. file_name := file + ".txt"
  37040. file_path := "日志" + "/" + file_name
  37041. exist, _ := utils.PathExists(file_path)
  37042. if exist { //存在
  37043. fmt.Println("存在")
  37044. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37045. if err != nil {
  37046. fmt.Println("read fail")
  37047. }
  37048. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37049. n, _ := f.Seek(0, 2)
  37050. _, err = f.WriteAt([]byte(content), n)
  37051. } else { //不存在
  37052. fmt.Println("文件不存在,创建文件")
  37053. f, err := os.Create("日志" + "/" + file_name)
  37054. defer f.Close()
  37055. if err != nil {
  37056. } else {
  37057. _, err = f.Write([]byte("记录日志"))
  37058. }
  37059. }
  37060. }
  37061. func saveLog(result string, request string, infno string, desc string) {
  37062. org_id, _ := beego.AppConfig.Int64("org_id")
  37063. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37064. dir := miConfig.OrgName + "日志"
  37065. utils.Mkdir(dir)
  37066. month := time.Unix(1557042972, 0).Format("1")
  37067. year := time.Now().Format("2006")
  37068. month = time.Now().Format("01")
  37069. day := time.Now().Format("02")
  37070. hour := time.Now().Format("15")
  37071. min := time.Now().Format("04")
  37072. sec := time.Now().Format("05")
  37073. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37074. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37075. file_name := file + ".txt"
  37076. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37077. exist, _ := utils.PathExists(file_path)
  37078. if exist { //存在
  37079. fmt.Println("存在")
  37080. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37081. if err != nil {
  37082. fmt.Println("read fail")
  37083. }
  37084. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37085. n, _ := f.Seek(0, 2)
  37086. _, err = f.WriteAt([]byte(content), n)
  37087. } else { //不存在
  37088. fmt.Println("文件不存在,创建文件")
  37089. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37090. defer f.Close()
  37091. if err != nil {
  37092. } else {
  37093. _, err = f.Write([]byte("记录日志"))
  37094. }
  37095. }
  37096. }
  37097. type Charset string
  37098. const (
  37099. UTF8 = Charset("UTF-8")
  37100. GB18030 = Charset("GB18030")
  37101. )
  37102. func ConvertToString(src string, srcCode string, tagCode string) string {
  37103. srcCoder := mahonia.NewDecoder(srcCode)
  37104. srcResult := srcCoder.ConvertString(src)
  37105. tagCoder := mahonia.NewDecoder(tagCode)
  37106. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37107. result := string(cdata)
  37108. return result
  37109. }
  37110. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37111. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37112. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37113. var token string
  37114. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37115. var api string
  37116. if miConfig.MdtrtareaAdmvs == "320921" {
  37117. 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 +
  37118. "&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
  37119. fmt.Println(api)
  37120. } else {
  37121. 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 +
  37122. "&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
  37123. }
  37124. resp, requestErr := http.Get(api)
  37125. if requestErr != nil {
  37126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37127. return ""
  37128. }
  37129. body, ioErr := ioutil.ReadAll(resp.Body)
  37130. if ioErr != nil {
  37131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37133. return ""
  37134. }
  37135. var respJSON map[string]interface{}
  37136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37139. return ""
  37140. }
  37141. var status string
  37142. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37143. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37144. var res ResultTwo //1101结果
  37145. var res10265 ResultTwo10265 //1101结果
  37146. if status == "0" { //读卡成功
  37147. var card_info string //卡信息
  37148. var busi_card_info string
  37149. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37150. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37151. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37152. fmt.Println(card_info)
  37153. fmt.Println(busi_card_info)
  37154. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37155. result, _ := json.Marshal(respJSON)
  37156. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37157. utils.ErrorLog("解析失败:%v", err)
  37158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37159. return ""
  37160. }
  37161. res.ErrMsg = res10265.ErrMsg
  37162. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37163. res.Infcode = infocode
  37164. res.Output = res10265.Output
  37165. res.InfRefmsgid = res10265.InfRefmsgid
  37166. if res.Infcode == 0 {
  37167. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37168. if err == gorm.ErrRecordNotFound {
  37169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37170. return ""
  37171. } else if err != nil {
  37172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37173. return ""
  37174. } else {
  37175. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37176. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37177. infoStr := string(Iinfos)
  37178. idetinfoStr := string(Idetinfos)
  37179. psn := &models.HisPsn{
  37180. PsnNo: res.Output.Baseinfo.PsnNo,
  37181. PatientId: patient.ID,
  37182. Certno: res.Output.Baseinfo.Certno,
  37183. Gend: res.Output.Baseinfo.Gend,
  37184. Naty: res.Output.Baseinfo.Naty,
  37185. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37186. PsnName: res.Output.Baseinfo.PsnName,
  37187. Idetinfo: idetinfoStr,
  37188. Insuinfo: infoStr,
  37189. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37190. CardInfo: card_info,
  37191. VerifyNumber: token,
  37192. }
  37193. service.CreateHisPsn(psn)
  37194. return token
  37195. }
  37196. }
  37197. } else {
  37198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37199. return ""
  37200. }
  37201. } else { //读卡失败
  37202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37203. return ""
  37204. }
  37205. return token
  37206. }
  37207. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37208. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37209. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37210. var token string
  37211. var api string
  37212. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37213. "&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
  37214. fmt.Println(api)
  37215. resp, requestErr := http.Get(api)
  37216. if requestErr != nil {
  37217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37218. return ""
  37219. }
  37220. body, ioErr := ioutil.ReadAll(resp.Body)
  37221. if ioErr != nil {
  37222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37224. return ""
  37225. }
  37226. var respJSON map[string]interface{}
  37227. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37230. return ""
  37231. }
  37232. var status string
  37233. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37234. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37235. var res ResultTwo //1101结果
  37236. if status == "1" { //读卡成功
  37237. var card_info string //卡信息
  37238. var busi_card_info string
  37239. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37240. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37241. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37242. fmt.Println(card_info)
  37243. fmt.Println(busi_card_info)
  37244. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37245. result, _ := json.Marshal(respJSON)
  37246. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37247. utils.ErrorLog("解析失败:%v", err)
  37248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37249. return ""
  37250. }
  37251. if res.Infcode == 0 {
  37252. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37253. if err == gorm.ErrRecordNotFound {
  37254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37255. return ""
  37256. } else if err != nil {
  37257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37258. return ""
  37259. } else {
  37260. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37261. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37262. infoStr := string(Iinfos)
  37263. idetinfoStr := string(Idetinfos)
  37264. psn := &models.HisPsn{
  37265. PsnNo: res.Output.Baseinfo.PsnNo,
  37266. PatientId: patient.ID,
  37267. Certno: res.Output.Baseinfo.Certno,
  37268. Gend: res.Output.Baseinfo.Gend,
  37269. Naty: res.Output.Baseinfo.Naty,
  37270. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37271. PsnName: res.Output.Baseinfo.PsnName,
  37272. Idetinfo: idetinfoStr,
  37273. Insuinfo: infoStr,
  37274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37275. CardInfo: card_info,
  37276. VerifyNumber: token,
  37277. }
  37278. service.CreateHisPsn(psn)
  37279. return token
  37280. }
  37281. }
  37282. } else {
  37283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37284. return ""
  37285. }
  37286. return token
  37287. }
  37288. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37289. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37290. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37291. var token string
  37292. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37293. var api string
  37294. if miConfig.MdtrtareaAdmvs == "320921" {
  37295. 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 +
  37296. "&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
  37297. fmt.Println(api)
  37298. } else {
  37299. 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 +
  37300. "&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
  37301. }
  37302. resp, requestErr := http.Get(api)
  37303. if requestErr != nil {
  37304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37305. return ""
  37306. }
  37307. body, ioErr := ioutil.ReadAll(resp.Body)
  37308. if ioErr != nil {
  37309. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37311. return ""
  37312. }
  37313. var respJSON map[string]interface{}
  37314. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37317. return ""
  37318. }
  37319. var status string
  37320. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37321. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37322. var res ResultTwo //1101结果
  37323. var res10265 ResultTwo10265 //1101结果
  37324. if status == "0" { //读卡成功
  37325. var card_info string //卡信息
  37326. var busi_card_info string
  37327. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37328. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37329. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37330. fmt.Println(card_info)
  37331. fmt.Println(busi_card_info)
  37332. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37333. result, _ := json.Marshal(respJSON)
  37334. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37335. utils.ErrorLog("解析失败:%v", err)
  37336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37337. return ""
  37338. }
  37339. res.ErrMsg = res10265.ErrMsg
  37340. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37341. res.Infcode = infocode
  37342. res.Output = res10265.Output
  37343. res.InfRefmsgid = res10265.InfRefmsgid
  37344. if res.Infcode == 0 {
  37345. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37346. if err == gorm.ErrRecordNotFound {
  37347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37348. return ""
  37349. } else if err != nil {
  37350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37351. return ""
  37352. } else {
  37353. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37354. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37355. infoStr := string(Iinfos)
  37356. idetinfoStr := string(Idetinfos)
  37357. psn := &models.HisPsn{
  37358. PsnNo: res.Output.Baseinfo.PsnNo,
  37359. PatientId: patient.ID,
  37360. Certno: res.Output.Baseinfo.Certno,
  37361. Gend: res.Output.Baseinfo.Gend,
  37362. Naty: res.Output.Baseinfo.Naty,
  37363. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37364. PsnName: res.Output.Baseinfo.PsnName,
  37365. Idetinfo: idetinfoStr,
  37366. Insuinfo: infoStr,
  37367. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37368. CardInfo: card_info,
  37369. VerifyNumber: token,
  37370. }
  37371. service.CreateHisPsn(psn)
  37372. return token
  37373. }
  37374. }
  37375. } else {
  37376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37377. return ""
  37378. }
  37379. } else { //读卡失败
  37380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37381. return ""
  37382. }
  37383. return token
  37384. }
  37385. func DeleteExtraSpaceTwo(s string) string {
  37386. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37387. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37388. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37389. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37390. s2 := make([]byte, len(s1)) //定义字符数组切片
  37391. copy(s2, s1) //将字符串复制到切片
  37392. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37393. for len(spc_index) > 0 { //找到适配项
  37394. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37395. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37396. }
  37397. return string(s2)
  37398. }
  37399. func Remove0000(s string) string {
  37400. str := make([]rune, 0, len(s))
  37401. for _, v := range []rune(s) {
  37402. if v == 0 {
  37403. continue
  37404. }
  37405. str = append(str, v)
  37406. }
  37407. return string(str)
  37408. }
  37409. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37410. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37411. readCard := DllDef.MustFindProc("EcQuery")
  37412. pCardInfo := make([]byte, 8192)
  37413. pBusiCardInfo := make([]byte, 8192)
  37414. data := make(map[string]interface{})
  37415. //pData := make(map[string]interface{})
  37416. inputData := make(map[string]interface{})
  37417. inputData["orgId"] = code
  37418. inputData["businessType"] = "01101"
  37419. inputData["operatorId"] = operator_id
  37420. inputData["operatorName"] = operator_name
  37421. inputData["officeId"] = "001"
  37422. inputData["officeName"] = "血透室"
  37423. //
  37424. data["data"] = inputData
  37425. data["transType"] = "ec.query"
  37426. data["orgId"] = code
  37427. bytesData, _ := json.Marshal(data)
  37428. pCardInfo = bytesData
  37429. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37430. fmt.Println(ret2)
  37431. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37432. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37433. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37434. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37435. if ret2 != 0 {
  37436. return "", ""
  37437. }
  37438. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37439. }
  37440. func DeleteExtraSpace(s string) string {
  37441. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37442. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37443. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37444. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37445. s2 := make([]byte, len(s1)) //定义字符数组切片
  37446. copy(s2, s1) //将字符串复制到切片
  37447. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37448. for len(spc_index) > 0 { //找到适配项
  37449. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37450. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37451. }
  37452. return string(s2)
  37453. }
  37454. // 对账
  37455. func (c *HisApiController) Post3202() {
  37456. start_time := c.GetString("start_time")
  37457. end_time := c.GetString("end_time")
  37458. //insutype := c.GetString("insutype")
  37459. clr_type := c.GetString("clr_type")
  37460. clr_org := c.GetString("clr_optins")
  37461. admin_user_id, _ := c.GetInt64("admin_user_id")
  37462. adminUser := c.GetAdminUserInfo()
  37463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37464. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37465. if len(clr_org) == 0 {
  37466. clr_org = miConfig.MdtrtareaAdmvs
  37467. }
  37468. timeLayout := "2006-01-02"
  37469. loc, _ := time.LoadLocation("Local")
  37470. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37471. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37472. var orders []*models.HisOrder
  37473. if clr_org == "421300" {
  37474. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37475. } else if clr_org == "420902" {
  37476. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37477. } else {
  37478. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37479. }
  37480. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37481. //fixmedins_setl_cnt := int64(len(orders))
  37482. var medfee_sumamt float64
  37483. var acct_pay float64
  37484. var fund_pay_sumamt float64
  37485. for _, item := range orders {
  37486. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37487. acct_pay = acct_pay + item.AcctPay
  37488. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37489. }
  37490. //var medfee_sumamt_two float64
  37491. //var acct_pay_two float64
  37492. //var fund_pay_sumamt_two float64
  37493. //for _, item := range orders_two {
  37494. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37495. // acct_pay_two = acct_pay_two + item.AcctPay
  37496. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37497. //}
  37498. //var user_name string
  37499. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37500. //if role.ID == 0 {
  37501. // user_name = "xxx"
  37502. //} else {
  37503. // user_name = role.UserName
  37504. //}
  37505. var res ResultSix
  37506. if config.IsOpen == 1 {
  37507. var bps []*models.BusinessParamsTwo
  37508. var bp models.BusinessParamsTwo
  37509. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37510. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37511. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37512. bp.MedfeeSumamt = medfee_sumamt_str
  37513. bp.AcctPay = acct_pay_str
  37514. bp.FundPaySumamt = fund_pay_sumamt_str
  37515. bp.Insutype = ""
  37516. bp.StmtBegndate = start_time
  37517. bp.ClrType = clr_type
  37518. bp.SetlOptins = clr_org
  37519. bp.StmtEnddate = end_time
  37520. bps = append(bps, &bp)
  37521. data := make(map[string]interface{})
  37522. data["bps"] = bps
  37523. data["org_name"] = miConfig.OrgName
  37524. data["doctor"] = role.UserName
  37525. data["fixmedins_code"] = miConfig.Code
  37526. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37527. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37528. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37529. if miConfig.MdtrtareaAdmvs == "421300" {
  37530. client := &http.Client{}
  37531. bytesData, _ := json.Marshal(data)
  37532. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37533. resp, _ := client.Do(req)
  37534. defer resp.Body.Close()
  37535. body, ioErr := ioutil.ReadAll(resp.Body)
  37536. if ioErr != nil {
  37537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37539. return
  37540. }
  37541. var respJSON map[string]interface{}
  37542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37545. return
  37546. }
  37547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37548. userJSONBytes, _ := json.Marshal(respJSON)
  37549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37550. utils.ErrorLog("解析失败:%v", err)
  37551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37552. return
  37553. }
  37554. }
  37555. if miConfig.MdtrtareaAdmvs == "420200" {
  37556. client := &http.Client{}
  37557. bytesData, _ := json.Marshal(data)
  37558. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37559. resp, _ := client.Do(req)
  37560. defer resp.Body.Close()
  37561. body, ioErr := ioutil.ReadAll(resp.Body)
  37562. if ioErr != nil {
  37563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37565. return
  37566. }
  37567. var respJSON map[string]interface{}
  37568. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37571. return
  37572. }
  37573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37574. userJSONBytes, _ := json.Marshal(respJSON)
  37575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37576. utils.ErrorLog("解析失败:%v", err)
  37577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37578. return
  37579. }
  37580. }
  37581. if miConfig.MdtrtareaAdmvs == "421182" {
  37582. client := &http.Client{}
  37583. bytesData, _ := json.Marshal(data)
  37584. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37585. resp, _ := client.Do(req)
  37586. defer resp.Body.Close()
  37587. body, ioErr := ioutil.ReadAll(resp.Body)
  37588. if ioErr != nil {
  37589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37591. return
  37592. }
  37593. var respJSON map[string]interface{}
  37594. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37597. return
  37598. }
  37599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37600. userJSONBytes, _ := json.Marshal(respJSON)
  37601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37602. utils.ErrorLog("解析失败:%v", err)
  37603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37604. return
  37605. }
  37606. }
  37607. if miConfig.MdtrtareaAdmvs == "420902" {
  37608. client := &http.Client{}
  37609. bytesData, _ := json.Marshal(data)
  37610. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37611. resp, _ := client.Do(req)
  37612. defer resp.Body.Close()
  37613. body, ioErr := ioutil.ReadAll(resp.Body)
  37614. if ioErr != nil {
  37615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37617. return
  37618. }
  37619. var respJSON map[string]interface{}
  37620. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37623. return
  37624. }
  37625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37626. userJSONBytes, _ := json.Marshal(respJSON)
  37627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37628. utils.ErrorLog("解析失败:%v", err)
  37629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37630. return
  37631. }
  37632. }
  37633. if res.Infcode == 0 {
  37634. c.ServeSuccessJSON(map[string]interface{}{
  37635. "msg": "发起成功",
  37636. })
  37637. } else {
  37638. c.ServeSuccessJSON(map[string]interface{}{
  37639. "failed_code": -10,
  37640. "msg": res.ErrMsg,
  37641. })
  37642. }
  37643. }
  37644. }
  37645. func (c *HisApiController) Post3204a() {
  37646. start_time := c.GetString("start_time")
  37647. end_time := c.GetString("end_time")
  37648. //insutype := c.GetString("insutype")
  37649. clr_type := c.GetString("clr_type")
  37650. clr_org := c.GetString("clr_optins")
  37651. admin_user_id, _ := c.GetInt64("admin_user_id")
  37652. adminUser := c.GetAdminUserInfo()
  37653. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37654. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37655. if len(clr_org) == 0 {
  37656. clr_org = miConfig.MdtrtareaAdmvs
  37657. }
  37658. timeLayout := "2006-01-02"
  37659. loc, _ := time.LoadLocation("Local")
  37660. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37661. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37662. var orders []*models.HisOrder
  37663. if clr_org == "421300" {
  37664. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37665. } else if clr_org == "420902" {
  37666. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37667. } else {
  37668. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37669. }
  37670. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37671. //fixmedins_setl_cnt := int64(len(orders))
  37672. var medfee_sumamt float64
  37673. var acct_pay float64
  37674. var fund_pay_sumamt float64
  37675. for _, item := range orders {
  37676. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37677. acct_pay = acct_pay + item.AcctPay
  37678. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37679. }
  37680. //var medfee_sumamt_two float64
  37681. //var acct_pay_two float64
  37682. //var fund_pay_sumamt_two float64
  37683. //for _, item := range orders_two {
  37684. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37685. // acct_pay_two = acct_pay_two + item.AcctPay
  37686. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37687. //}
  37688. //var user_name string
  37689. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37690. //if role.ID == 0 {
  37691. // user_name = "xxx"
  37692. //} else {
  37693. // user_name = role.UserName
  37694. //}
  37695. var res ResultSix
  37696. if config.IsOpen == 1 {
  37697. var bps []*models.BusinessParamsTwo
  37698. var bp models.BusinessParamsTwo
  37699. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37700. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37701. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37702. bp.MedfeeSumamt = medfee_sumamt_str
  37703. bp.AcctPay = acct_pay_str
  37704. bp.FundPaySumamt = fund_pay_sumamt_str
  37705. bp.Insutype = ""
  37706. bp.StmtBegndate = start_time
  37707. bp.ClrType = clr_type
  37708. bp.SetlOptins = clr_org
  37709. bp.StmtEnddate = end_time
  37710. bps = append(bps, &bp)
  37711. data := make(map[string]interface{})
  37712. data["bps"] = bps
  37713. data["org_name"] = miConfig.OrgName
  37714. data["doctor"] = role.UserName
  37715. data["fixmedins_code"] = miConfig.Code
  37716. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37717. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37718. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37719. if miConfig.MdtrtareaAdmvs == "421300" {
  37720. client := &http.Client{}
  37721. bytesData, _ := json.Marshal(data)
  37722. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37723. resp, _ := client.Do(req)
  37724. defer resp.Body.Close()
  37725. body, ioErr := ioutil.ReadAll(resp.Body)
  37726. if ioErr != nil {
  37727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37729. return
  37730. }
  37731. var respJSON map[string]interface{}
  37732. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37735. return
  37736. }
  37737. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37738. userJSONBytes, _ := json.Marshal(respJSON)
  37739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37740. utils.ErrorLog("解析失败:%v", err)
  37741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37742. return
  37743. }
  37744. }
  37745. if miConfig.MdtrtareaAdmvs == "420200" {
  37746. client := &http.Client{}
  37747. bytesData, _ := json.Marshal(data)
  37748. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37749. resp, _ := client.Do(req)
  37750. defer resp.Body.Close()
  37751. body, ioErr := ioutil.ReadAll(resp.Body)
  37752. if ioErr != nil {
  37753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37755. return
  37756. }
  37757. var respJSON map[string]interface{}
  37758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37761. return
  37762. }
  37763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37764. userJSONBytes, _ := json.Marshal(respJSON)
  37765. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37766. utils.ErrorLog("解析失败:%v", err)
  37767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37768. return
  37769. }
  37770. }
  37771. if miConfig.MdtrtareaAdmvs == "421182" {
  37772. client := &http.Client{}
  37773. bytesData, _ := json.Marshal(data)
  37774. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37775. resp, _ := client.Do(req)
  37776. defer resp.Body.Close()
  37777. body, ioErr := ioutil.ReadAll(resp.Body)
  37778. if ioErr != nil {
  37779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37781. return
  37782. }
  37783. var respJSON map[string]interface{}
  37784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37787. return
  37788. }
  37789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37790. userJSONBytes, _ := json.Marshal(respJSON)
  37791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37792. utils.ErrorLog("解析失败:%v", err)
  37793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37794. return
  37795. }
  37796. }
  37797. if miConfig.MdtrtareaAdmvs == "420902" {
  37798. client := &http.Client{}
  37799. bytesData, _ := json.Marshal(data)
  37800. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37801. resp, _ := client.Do(req)
  37802. defer resp.Body.Close()
  37803. body, ioErr := ioutil.ReadAll(resp.Body)
  37804. if ioErr != nil {
  37805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37807. return
  37808. }
  37809. var respJSON map[string]interface{}
  37810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37813. return
  37814. }
  37815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37816. userJSONBytes, _ := json.Marshal(respJSON)
  37817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37818. utils.ErrorLog("解析失败:%v", err)
  37819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37820. return
  37821. }
  37822. }
  37823. if res.Infcode == 0 {
  37824. c.ServeSuccessJSON(map[string]interface{}{
  37825. "msg": "撤销成功",
  37826. })
  37827. } else {
  37828. c.ServeSuccessJSON(map[string]interface{}{
  37829. "failed_code": -10,
  37830. "msg": res.ErrMsg,
  37831. })
  37832. }
  37833. }
  37834. }
  37835. func (c *HisApiController) Post3204() {
  37836. admin_user_id, _ := c.GetInt64("admin_user_id")
  37837. id := c.GetString("id")
  37838. adminUser := c.GetAdminUserInfo()
  37839. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37840. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37841. //clr_org := miConfig.MdtrtareaAdmvs
  37842. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37843. var res ResultSix
  37844. if config.IsOpen == 1 {
  37845. data := make(map[string]interface{})
  37846. data["id"] = id
  37847. data["org_name"] = miConfig.OrgName
  37848. data["doctor"] = role.UserName
  37849. data["fixmedins_code"] = miConfig.Code
  37850. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37851. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37852. client := &http.Client{}
  37853. bytesData, _ := json.Marshal(data)
  37854. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  37855. resp, _ := client.Do(req)
  37856. defer resp.Body.Close()
  37857. body, ioErr := ioutil.ReadAll(resp.Body)
  37858. if ioErr != nil {
  37859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37861. return
  37862. }
  37863. var respJSON map[string]interface{}
  37864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37867. return
  37868. }
  37869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37870. userJSONBytes, _ := json.Marshal(respJSON)
  37871. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37872. utils.ErrorLog("解析失败:%v", err)
  37873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37874. return
  37875. }
  37876. if res.Infcode == 0 {
  37877. c.ServeSuccessJSON(map[string]interface{}{
  37878. "msg": "发起成功",
  37879. })
  37880. } else {
  37881. c.ServeSuccessJSON(map[string]interface{}{
  37882. "failed_code": -10,
  37883. "msg": res.ErrMsg,
  37884. })
  37885. }
  37886. }
  37887. }
  37888. func (c *HisApiController) Post8404() {
  37889. admin_user_id, _ := c.GetInt64("admin_user_id")
  37890. month := c.GetString("month")
  37891. adminUser := c.GetAdminUserInfo()
  37892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37893. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37894. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37895. var res ResultSix
  37896. if config.IsOpen == 1 {
  37897. data := make(map[string]interface{})
  37898. data["month"] = month
  37899. data["org_name"] = miConfig.OrgName
  37900. data["doctor"] = role.UserName
  37901. data["fixmedins_code"] = miConfig.Code
  37902. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37903. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37904. client := &http.Client{}
  37905. bytesData, _ := json.Marshal(data)
  37906. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  37907. resp, _ := client.Do(req)
  37908. defer resp.Body.Close()
  37909. body, ioErr := ioutil.ReadAll(resp.Body)
  37910. if ioErr != nil {
  37911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37913. return
  37914. }
  37915. var respJSON map[string]interface{}
  37916. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37919. return
  37920. }
  37921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37922. userJSONBytes, _ := json.Marshal(respJSON)
  37923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37924. utils.ErrorLog("解析失败:%v", err)
  37925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37926. return
  37927. }
  37928. if res.Infcode == 0 {
  37929. c.ServeSuccessJSON(map[string]interface{}{
  37930. "msg": "查询成功",
  37931. })
  37932. } else {
  37933. c.ServeSuccessJSON(map[string]interface{}{
  37934. "failed_code": -10,
  37935. "msg": res.ErrMsg,
  37936. })
  37937. }
  37938. }
  37939. }
  37940. func (c *HisApiController) Post3202b() {
  37941. start_time := c.GetString("start_time")
  37942. end_time := c.GetString("end_time")
  37943. //insutype := c.GetString("insutype")
  37944. clr_type := c.GetString("clr_type")
  37945. clr_org := c.GetString("clr_optins")
  37946. admin_user_id, _ := c.GetInt64("admin_user_id")
  37947. adminUser := c.GetAdminUserInfo()
  37948. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37949. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37950. if len(clr_org) == 0 {
  37951. clr_org = miConfig.MdtrtareaAdmvs
  37952. }
  37953. timeLayout := "2006-01-02"
  37954. loc, _ := time.LoadLocation("Local")
  37955. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37956. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37957. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37958. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37959. //fixmedins_setl_cnt := int64(len(orders))
  37960. var medfee_sumamt float64
  37961. var acct_pay float64
  37962. var fund_pay_sumamt float64
  37963. for _, item := range orders {
  37964. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37965. acct_pay = acct_pay + item.AcctPay
  37966. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37967. }
  37968. //var medfee_sumamt_two float64
  37969. //var acct_pay_two float64
  37970. //var fund_pay_sumamt_two float64
  37971. //for _, item := range orders_two {
  37972. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37973. // acct_pay_two = acct_pay_two + item.AcctPay
  37974. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37975. //}
  37976. //var user_name string
  37977. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37978. //if role.ID == 0 {
  37979. // user_name = "xxx"
  37980. //} else {
  37981. // user_name = role.UserName
  37982. //}
  37983. var res ResultSix
  37984. if config.IsOpen == 1 {
  37985. var bps []*models.BusinessParamsTwo
  37986. var bp models.BusinessParamsTwo
  37987. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37988. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37989. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37990. bp.MedfeeSumamt = medfee_sumamt_str
  37991. bp.AcctPay = acct_pay_str
  37992. bp.FundPaySumamt = fund_pay_sumamt_str
  37993. bp.Insutype = "390"
  37994. bp.StmtBegndate = start_time
  37995. bp.ClrType = clr_type
  37996. bp.SetlOptins = clr_org
  37997. bp.StmtEnddate = end_time
  37998. bps = append(bps, &bp)
  37999. data := make(map[string]interface{})
  38000. data["bps"] = bps
  38001. data["org_name"] = miConfig.OrgName
  38002. data["doctor"] = role.UserName
  38003. data["fixmedins_code"] = miConfig.Code
  38004. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38005. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38006. if miConfig.MdtrtareaAdmvs == "421300" {
  38007. client := &http.Client{}
  38008. bytesData, _ := json.Marshal(data)
  38009. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38010. resp, _ := client.Do(req)
  38011. defer resp.Body.Close()
  38012. body, ioErr := ioutil.ReadAll(resp.Body)
  38013. if ioErr != nil {
  38014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38016. return
  38017. }
  38018. var respJSON map[string]interface{}
  38019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38022. return
  38023. }
  38024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38025. userJSONBytes, _ := json.Marshal(respJSON)
  38026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38027. utils.ErrorLog("解析失败:%v", err)
  38028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38029. return
  38030. }
  38031. }
  38032. if miConfig.MdtrtareaAdmvs == "420200" {
  38033. client := &http.Client{}
  38034. bytesData, _ := json.Marshal(data)
  38035. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38036. resp, _ := client.Do(req)
  38037. defer resp.Body.Close()
  38038. body, ioErr := ioutil.ReadAll(resp.Body)
  38039. if ioErr != nil {
  38040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38042. return
  38043. }
  38044. var respJSON map[string]interface{}
  38045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38048. return
  38049. }
  38050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38051. userJSONBytes, _ := json.Marshal(respJSON)
  38052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38053. utils.ErrorLog("解析失败:%v", err)
  38054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38055. return
  38056. }
  38057. }
  38058. if miConfig.MdtrtareaAdmvs == "421182" {
  38059. client := &http.Client{}
  38060. bytesData, _ := json.Marshal(data)
  38061. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38062. resp, _ := client.Do(req)
  38063. defer resp.Body.Close()
  38064. body, ioErr := ioutil.ReadAll(resp.Body)
  38065. if ioErr != nil {
  38066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38068. return
  38069. }
  38070. var respJSON map[string]interface{}
  38071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38074. return
  38075. }
  38076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38077. userJSONBytes, _ := json.Marshal(respJSON)
  38078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38079. utils.ErrorLog("解析失败:%v", err)
  38080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38081. return
  38082. }
  38083. }
  38084. if res.Infcode == 0 {
  38085. c.ServeSuccessJSON(map[string]interface{}{
  38086. "msg": "发起成功",
  38087. })
  38088. } else {
  38089. c.ServeSuccessJSON(map[string]interface{}{
  38090. "failed_code": -10,
  38091. "msg": res.ErrMsg,
  38092. })
  38093. }
  38094. }
  38095. }
  38096. func (c *HisApiController) Post1608() {
  38097. start_time := c.GetString("start_time")
  38098. end_time := c.GetString("end_time")
  38099. admin_user_id, _ := c.GetInt64("admin_user_id")
  38100. adminUser := c.GetAdminUserInfo()
  38101. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38102. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38103. timeLayout := "2006-01-02"
  38104. loc, _ := time.LoadLocation("Local")
  38105. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38106. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38107. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38108. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38109. fixmedins_setl_cnt := int64(len(orders))
  38110. var medfee_sumamt float64
  38111. var func_smamt float64
  38112. for _, item := range orders {
  38113. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38114. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38115. }
  38116. times := strings.Split(start_time, "-")
  38117. time_tows := strings.Split(end_time, "-")
  38118. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38119. var res ResultSix
  38120. if config.IsOpen == 1 {
  38121. //var bps []*models.BusinessParamsTwo
  38122. //var bp models.BusinessParamsTwo
  38123. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38124. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38125. data := make(map[string]interface{})
  38126. data["org_name"] = miConfig.OrgName
  38127. data["doctor"] = role.UserName
  38128. data["func_smamt"] = func_smamt_str
  38129. data["fixmedins_code"] = miConfig.Code
  38130. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38131. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38132. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38133. data["medfee_sumamt"] = medfee_sumamt_str
  38134. data["start_time"] = times[0] + times[1] + times[2]
  38135. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38136. if miConfig.MdtrtareaAdmvs == "421300" {
  38137. client := &http.Client{}
  38138. bytesData, _ := json.Marshal(data)
  38139. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38140. resp, _ := client.Do(req)
  38141. defer resp.Body.Close()
  38142. body, ioErr := ioutil.ReadAll(resp.Body)
  38143. if ioErr != nil {
  38144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38146. return
  38147. }
  38148. var respJSON map[string]interface{}
  38149. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38152. return
  38153. }
  38154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38155. userJSONBytes, _ := json.Marshal(respJSON)
  38156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38157. utils.ErrorLog("解析失败:%v", err)
  38158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38159. return
  38160. }
  38161. }
  38162. if miConfig.MdtrtareaAdmvs == "420200" {
  38163. client := &http.Client{}
  38164. bytesData, _ := json.Marshal(data)
  38165. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38166. resp, _ := client.Do(req)
  38167. defer resp.Body.Close()
  38168. body, ioErr := ioutil.ReadAll(resp.Body)
  38169. if ioErr != nil {
  38170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38172. return
  38173. }
  38174. var respJSON map[string]interface{}
  38175. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38178. return
  38179. }
  38180. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38181. userJSONBytes, _ := json.Marshal(respJSON)
  38182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38183. utils.ErrorLog("解析失败:%v", err)
  38184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38185. return
  38186. }
  38187. }
  38188. if miConfig.MdtrtareaAdmvs == "421182" {
  38189. client := &http.Client{}
  38190. bytesData, _ := json.Marshal(data)
  38191. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38192. resp, _ := client.Do(req)
  38193. defer resp.Body.Close()
  38194. body, ioErr := ioutil.ReadAll(resp.Body)
  38195. if ioErr != nil {
  38196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38198. return
  38199. }
  38200. var respJSON map[string]interface{}
  38201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38204. return
  38205. }
  38206. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38207. userJSONBytes, _ := json.Marshal(respJSON)
  38208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38209. utils.ErrorLog("解析失败:%v", err)
  38210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38211. return
  38212. }
  38213. }
  38214. if res.Infcode == 0 {
  38215. c.ServeSuccessJSON(map[string]interface{}{
  38216. "msg": "发起成功",
  38217. })
  38218. } else {
  38219. c.ServeSuccessJSON(map[string]interface{}{
  38220. "failed_code": -10,
  38221. "msg": res.ErrMsg,
  38222. })
  38223. }
  38224. }
  38225. }
  38226. // 5.11.1.1【5262】结算信息按时间段查询
  38227. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38228. admin_user_id, _ := c.GetInt64("admin_user_id")
  38229. adminUser := c.GetAdminUserInfo()
  38230. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38231. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38232. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38233. var res Result5262
  38234. if config.IsOpen == 1 {
  38235. if miConfig.MdtrtareaAdmvs == "421300" {
  38236. data := make(map[string]interface{})
  38237. data["bps"] = bp
  38238. data["org_name"] = miConfig.OrgName
  38239. data["doctor"] = role.UserName
  38240. data["fixmedins_code"] = miConfig.Code
  38241. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38242. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38243. data["page"] = strconv.FormatInt(page, 10)
  38244. data["limit"] = strconv.FormatInt(limit, 10)
  38245. fmt.Println(data)
  38246. client := &http.Client{}
  38247. bytesData, _ := json.Marshal(data)
  38248. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38249. resp, _ := client.Do(req)
  38250. defer resp.Body.Close()
  38251. body, ioErr := ioutil.ReadAll(resp.Body)
  38252. if ioErr != nil {
  38253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38255. return
  38256. }
  38257. var respJSON map[string]interface{}
  38258. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38261. return
  38262. }
  38263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38264. userJSONBytes, _ := json.Marshal(respJSON)
  38265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38266. utils.ErrorLog("解析失败:%v", err)
  38267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38268. return
  38269. }
  38270. }
  38271. if miConfig.MdtrtareaAdmvs == "420200" {
  38272. data := make(map[string]interface{})
  38273. data["bps"] = bp
  38274. data["org_name"] = miConfig.OrgName
  38275. data["doctor"] = role.UserName
  38276. data["fixmedins_code"] = miConfig.Code
  38277. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38278. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38279. data["page"] = strconv.FormatInt(page, 10)
  38280. data["limit"] = strconv.FormatInt(limit, 10)
  38281. fmt.Println(data)
  38282. client := &http.Client{}
  38283. bytesData, _ := json.Marshal(data)
  38284. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38285. resp, _ := client.Do(req)
  38286. defer resp.Body.Close()
  38287. body, ioErr := ioutil.ReadAll(resp.Body)
  38288. if ioErr != nil {
  38289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38291. return
  38292. }
  38293. var respJSON map[string]interface{}
  38294. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38297. return
  38298. }
  38299. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38300. userJSONBytes, _ := json.Marshal(respJSON)
  38301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38302. utils.ErrorLog("解析失败:%v", err)
  38303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38304. return
  38305. }
  38306. }
  38307. if miConfig.MdtrtareaAdmvs == "421182" {
  38308. data := make(map[string]interface{})
  38309. data["bps"] = bp
  38310. data["org_name"] = miConfig.OrgName
  38311. data["doctor"] = role.UserName
  38312. data["fixmedins_code"] = miConfig.Code
  38313. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38314. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38315. data["page"] = strconv.FormatInt(page, 10)
  38316. data["limit"] = strconv.FormatInt(limit, 10)
  38317. fmt.Println(data)
  38318. client := &http.Client{}
  38319. bytesData, _ := json.Marshal(data)
  38320. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38321. resp, _ := client.Do(req)
  38322. defer resp.Body.Close()
  38323. body, ioErr := ioutil.ReadAll(resp.Body)
  38324. if ioErr != nil {
  38325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38327. return
  38328. }
  38329. var respJSON map[string]interface{}
  38330. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38333. return
  38334. }
  38335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38336. userJSONBytes, _ := json.Marshal(respJSON)
  38337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38338. utils.ErrorLog("解析失败:%v", err)
  38339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38340. return
  38341. }
  38342. }
  38343. if miConfig.MdtrtareaAdmvs == "420902" {
  38344. data := make(map[string]interface{})
  38345. data["bps"] = bp
  38346. data["org_name"] = miConfig.OrgName
  38347. data["doctor"] = role.UserName
  38348. data["fixmedins_code"] = miConfig.Code
  38349. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38350. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38351. data["page"] = strconv.FormatInt(page, 10)
  38352. data["limit"] = strconv.FormatInt(limit, 10)
  38353. fmt.Println(data)
  38354. client := &http.Client{}
  38355. bytesData, _ := json.Marshal(data)
  38356. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38357. resp, _ := client.Do(req)
  38358. defer resp.Body.Close()
  38359. body, ioErr := ioutil.ReadAll(resp.Body)
  38360. if ioErr != nil {
  38361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38363. return
  38364. }
  38365. var respJSON map[string]interface{}
  38366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38369. return
  38370. }
  38371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38372. userJSONBytes, _ := json.Marshal(respJSON)
  38373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38374. utils.ErrorLog("解析失败:%v", err)
  38375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38376. return
  38377. }
  38378. }
  38379. if res.Infcode == 0 {
  38380. c.ServeSuccessJSON(map[string]interface{}{
  38381. "order": res.Output.Result,
  38382. "total": res.Output.PageInfo.RecordCounts,
  38383. })
  38384. } else {
  38385. c.ServeSuccessJSON(map[string]interface{}{
  38386. "failed_code": -10,
  38387. "msg": res.ErrMsg,
  38388. })
  38389. }
  38390. }
  38391. }
  38392. // 5.11.1.2【5267】异地结算信息时间段查询
  38393. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38394. admin_user_id, _ := c.GetInt64("admin_user_id")
  38395. adminUser := c.GetAdminUserInfo()
  38396. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38397. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38398. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38399. var res Result5267
  38400. if config.IsOpen == 1 {
  38401. if miConfig.MdtrtareaAdmvs == "421300" {
  38402. data := make(map[string]interface{})
  38403. data["bps"] = bp
  38404. data["org_name"] = miConfig.OrgName
  38405. data["doctor"] = role.UserName
  38406. data["fixmedins_code"] = miConfig.Code
  38407. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38408. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38409. data["page"] = page
  38410. data["limit"] = limit
  38411. fmt.Println(data)
  38412. client := &http.Client{}
  38413. bytesData, _ := json.Marshal(data)
  38414. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38415. resp, _ := client.Do(req)
  38416. defer resp.Body.Close()
  38417. body, ioErr := ioutil.ReadAll(resp.Body)
  38418. if ioErr != nil {
  38419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38421. return
  38422. }
  38423. var respJSON map[string]interface{}
  38424. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38427. return
  38428. }
  38429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38430. userJSONBytes, _ := json.Marshal(respJSON)
  38431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38432. utils.ErrorLog("解析失败:%v", err)
  38433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38434. return
  38435. }
  38436. }
  38437. if miConfig.MdtrtareaAdmvs == "420200" {
  38438. data := make(map[string]interface{})
  38439. data["bps"] = bp
  38440. data["org_name"] = miConfig.OrgName
  38441. data["doctor"] = role.UserName
  38442. data["fixmedins_code"] = miConfig.Code
  38443. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38444. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38445. data["page"] = page
  38446. data["limit"] = limit
  38447. fmt.Println(data)
  38448. client := &http.Client{}
  38449. bytesData, _ := json.Marshal(data)
  38450. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38451. resp, _ := client.Do(req)
  38452. defer resp.Body.Close()
  38453. body, ioErr := ioutil.ReadAll(resp.Body)
  38454. if ioErr != nil {
  38455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38457. return
  38458. }
  38459. var respJSON map[string]interface{}
  38460. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38463. return
  38464. }
  38465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38466. userJSONBytes, _ := json.Marshal(respJSON)
  38467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38468. utils.ErrorLog("解析失败:%v", err)
  38469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38470. return
  38471. }
  38472. }
  38473. if miConfig.MdtrtareaAdmvs == "421182" {
  38474. data := make(map[string]interface{})
  38475. data["bps"] = bp
  38476. data["org_name"] = miConfig.OrgName
  38477. data["doctor"] = role.UserName
  38478. data["fixmedins_code"] = miConfig.Code
  38479. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38480. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38481. data["page"] = page
  38482. data["limit"] = limit
  38483. fmt.Println(data)
  38484. client := &http.Client{}
  38485. bytesData, _ := json.Marshal(data)
  38486. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38487. resp, _ := client.Do(req)
  38488. defer resp.Body.Close()
  38489. body, ioErr := ioutil.ReadAll(resp.Body)
  38490. if ioErr != nil {
  38491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38493. return
  38494. }
  38495. var respJSON map[string]interface{}
  38496. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38499. return
  38500. }
  38501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38502. userJSONBytes, _ := json.Marshal(respJSON)
  38503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38504. utils.ErrorLog("解析失败:%v", err)
  38505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38506. return
  38507. }
  38508. }
  38509. if res.Infcode == 0 {
  38510. c.ServeSuccessJSON(map[string]interface{}{
  38511. "order": res.Output.Result,
  38512. "total": res.Output.PageInfo.RecordCounts,
  38513. })
  38514. } else {
  38515. c.ServeSuccessJSON(map[string]interface{}{
  38516. "failed_code": -10,
  38517. "msg": res.ErrMsg,
  38518. })
  38519. }
  38520. }
  38521. }
  38522. func (c *HisApiController) Post3501() {
  38523. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38524. data := make(map[string]interface{})
  38525. var struct3501s []models.Struct3501
  38526. var struct3501 models.Struct3501
  38527. struct3501.OrgName = miConfig.OrgName
  38528. struct3501.AccessKey = miConfig.AccessKey
  38529. struct3501.RequestUrl = miConfig.Url
  38530. struct3501.SecretKey = miConfig.SecretKey
  38531. struct3501.ManuDate = "2022-08-17"
  38532. struct3501.FixmedinsBchno = ""
  38533. struct3501.ManuLotnum = ""
  38534. struct3501.RxFlag = "0"
  38535. struct3501.ExpyEnd = "2022-08-17"
  38536. struct3501.Invdate = "2022-08-17"
  38537. struct3501.InvCnt = "20.25"
  38538. struct3501.Memo = ""
  38539. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38540. struct3501.FixmedinsHilistId = miConfig.Code
  38541. struct3501.FixmedinsHilistName = miConfig.OrgName
  38542. struct3501s = append(struct3501s, struct3501)
  38543. data["struct_3501s"] = struct3501s
  38544. client := &http.Client{}
  38545. bytesData, _ := json.Marshal(data)
  38546. var req *http.Request
  38547. if miConfig.MdtrtareaAdmvs == "320921" {
  38548. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38549. } else {
  38550. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38551. }
  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. var res ResultSix
  38567. var resSix10265 ResultSix10265 //1101结果
  38568. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38569. result, _ := json.Marshal(respJSON)
  38570. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38571. utils.ErrorLog("解析失败:%v", err)
  38572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38573. return
  38574. }
  38575. res.InfRefmsgid = resSix10265.InfRefmsgid
  38576. res.Output = resSix10265.Output
  38577. res.ErrMsg = resSix10265.ErrMsg
  38578. res.Cainfo = resSix10265.Cainfo
  38579. res.WarnMsg = resSix10265.WarnMsg
  38580. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38581. res.Infcode = infocode
  38582. if infocode == 0 {
  38583. c.ServeSuccessJSON(map[string]interface{}{
  38584. "msg": "上传成功",
  38585. })
  38586. return
  38587. } else {
  38588. c.ServeSuccessJSON(map[string]interface{}{
  38589. "failed_code": -10,
  38590. "msg": res.ErrMsg,
  38591. })
  38592. return
  38593. }
  38594. }
  38595. func (c *HisApiController) Post3502() {
  38596. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38597. data := make(map[string]interface{})
  38598. var struct3502s []models.Struct3502
  38599. var struct3502 models.Struct3502
  38600. struct3502.OrgName = miConfig.OrgName
  38601. struct3502.AccessKey = miConfig.AccessKey
  38602. struct3502.RequestUrl = miConfig.Url
  38603. struct3502.SecretKey = miConfig.SecretKey
  38604. struct3502.ManuDate = "2022-08-15"
  38605. struct3502.FixmedinsBchno = ""
  38606. struct3502.ManuLotnum = ""
  38607. struct3502.RxFlag = "0"
  38608. struct3502.ExpyEnd = "2022-08-15"
  38609. struct3502.Invdate = "2022-08-15"
  38610. struct3502.InvCnt = "20.25"
  38611. struct3502.Memo = ""
  38612. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38613. struct3502.FixmedinsHilistId = miConfig.Code
  38614. struct3502.FixmedinsHilistName = miConfig.OrgName
  38615. struct3502s = append(struct3502s, struct3502)
  38616. data["struct_3502s"] = struct3502s
  38617. client := &http.Client{}
  38618. bytesData, _ := json.Marshal(data)
  38619. var req *http.Request
  38620. if miConfig.MdtrtareaAdmvs == "320921" {
  38621. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38622. } else {
  38623. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38624. }
  38625. resp, _ := client.Do(req)
  38626. defer resp.Body.Close()
  38627. body, ioErr := ioutil.ReadAll(resp.Body)
  38628. if ioErr != nil {
  38629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38631. return
  38632. }
  38633. var respJSON map[string]interface{}
  38634. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38637. return
  38638. }
  38639. var res ResultSix
  38640. var resSix10265 ResultSix10265 //1101结果
  38641. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38642. result, _ := json.Marshal(respJSON)
  38643. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38644. utils.ErrorLog("解析失败:%v", err)
  38645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38646. return
  38647. }
  38648. res.InfRefmsgid = resSix10265.InfRefmsgid
  38649. res.Output = resSix10265.Output
  38650. res.ErrMsg = resSix10265.ErrMsg
  38651. res.Cainfo = resSix10265.Cainfo
  38652. res.WarnMsg = resSix10265.WarnMsg
  38653. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38654. res.Infcode = infocode
  38655. if infocode == 0 {
  38656. c.ServeSuccessJSON(map[string]interface{}{
  38657. "msg": "上传成功",
  38658. })
  38659. return
  38660. } else {
  38661. c.ServeSuccessJSON(map[string]interface{}{
  38662. "failed_code": -10,
  38663. "msg": res.ErrMsg,
  38664. })
  38665. return
  38666. }
  38667. }
  38668. func (c *HisApiController) Post3503() {
  38669. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38670. data := make(map[string]interface{})
  38671. var struct3501s []models.Struct3501
  38672. var struct3501 models.Struct3501
  38673. struct3501.OrgName = miConfig.OrgName
  38674. struct3501.AccessKey = miConfig.AccessKey
  38675. struct3501.RequestUrl = miConfig.Url
  38676. struct3501.SecretKey = miConfig.SecretKey
  38677. struct3501.ManuDate = "2022-08-15"
  38678. struct3501.FixmedinsBchno = ""
  38679. struct3501.ManuLotnum = ""
  38680. struct3501.RxFlag = "0"
  38681. struct3501.ExpyEnd = "2022-08-15"
  38682. struct3501.Invdate = "2022-08-15"
  38683. struct3501.InvCnt = "20.25"
  38684. struct3501.Memo = ""
  38685. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38686. struct3501.FixmedinsHilistId = miConfig.Code
  38687. struct3501.FixmedinsHilistName = miConfig.OrgName
  38688. struct3501s = append(struct3501s, struct3501)
  38689. data["struct_3501s"] = struct3501s
  38690. client := &http.Client{}
  38691. bytesData, _ := json.Marshal(data)
  38692. var req *http.Request
  38693. if miConfig.MdtrtareaAdmvs == "320921" {
  38694. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38695. } else {
  38696. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38697. }
  38698. resp, _ := client.Do(req)
  38699. defer resp.Body.Close()
  38700. body, ioErr := ioutil.ReadAll(resp.Body)
  38701. if ioErr != nil {
  38702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38704. return
  38705. }
  38706. var respJSON map[string]interface{}
  38707. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38710. return
  38711. }
  38712. var res ResultSix
  38713. var resSix10265 ResultSix10265 //1101结果
  38714. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38715. result, _ := json.Marshal(respJSON)
  38716. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38717. utils.ErrorLog("解析失败:%v", err)
  38718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38719. return
  38720. }
  38721. res.InfRefmsgid = resSix10265.InfRefmsgid
  38722. res.Output = resSix10265.Output
  38723. res.ErrMsg = resSix10265.ErrMsg
  38724. res.Cainfo = resSix10265.Cainfo
  38725. res.WarnMsg = resSix10265.WarnMsg
  38726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38727. res.Infcode = infocode
  38728. if infocode == 0 {
  38729. c.ServeSuccessJSON(map[string]interface{}{
  38730. "msg": "上传成功",
  38731. })
  38732. return
  38733. } else {
  38734. c.ServeSuccessJSON(map[string]interface{}{
  38735. "failed_code": -10,
  38736. "msg": res.ErrMsg,
  38737. })
  38738. return
  38739. }
  38740. }
  38741. func (c *HisApiController) Post3504() {
  38742. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38743. data := make(map[string]interface{})
  38744. var struct3501s []models.Struct3501
  38745. var struct3501 models.Struct3501
  38746. struct3501.OrgName = miConfig.OrgName
  38747. struct3501.AccessKey = miConfig.AccessKey
  38748. struct3501.RequestUrl = miConfig.Url
  38749. struct3501.SecretKey = miConfig.SecretKey
  38750. struct3501.ManuDate = "2022-08-15"
  38751. struct3501.FixmedinsBchno = ""
  38752. struct3501.ManuLotnum = ""
  38753. struct3501.RxFlag = "0"
  38754. struct3501.ExpyEnd = "2022-08-15"
  38755. struct3501.Invdate = "2022-08-15"
  38756. struct3501.InvCnt = "20.25"
  38757. struct3501.Memo = ""
  38758. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38759. struct3501.FixmedinsHilistId = miConfig.Code
  38760. struct3501.FixmedinsHilistName = miConfig.OrgName
  38761. struct3501s = append(struct3501s, struct3501)
  38762. data["struct_3501s"] = struct3501s
  38763. client := &http.Client{}
  38764. bytesData, _ := json.Marshal(data)
  38765. var req *http.Request
  38766. if miConfig.MdtrtareaAdmvs == "320921" {
  38767. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38768. } else {
  38769. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38770. }
  38771. resp, _ := client.Do(req)
  38772. defer resp.Body.Close()
  38773. body, ioErr := ioutil.ReadAll(resp.Body)
  38774. if ioErr != nil {
  38775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38777. return
  38778. }
  38779. var respJSON map[string]interface{}
  38780. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38783. return
  38784. }
  38785. var res ResultSix
  38786. var resSix10265 ResultSix10265 //1101结果
  38787. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38788. result, _ := json.Marshal(respJSON)
  38789. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38790. utils.ErrorLog("解析失败:%v", err)
  38791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38792. return
  38793. }
  38794. res.InfRefmsgid = resSix10265.InfRefmsgid
  38795. res.Output = resSix10265.Output
  38796. res.ErrMsg = resSix10265.ErrMsg
  38797. res.Cainfo = resSix10265.Cainfo
  38798. res.WarnMsg = resSix10265.WarnMsg
  38799. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38800. res.Infcode = infocode
  38801. if infocode == 0 {
  38802. c.ServeSuccessJSON(map[string]interface{}{
  38803. "msg": "上传成功",
  38804. })
  38805. return
  38806. } else {
  38807. c.ServeSuccessJSON(map[string]interface{}{
  38808. "failed_code": -10,
  38809. "msg": res.ErrMsg,
  38810. })
  38811. return
  38812. }
  38813. }
  38814. func (c *HisApiController) Post3505() {
  38815. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38816. data := make(map[string]interface{})
  38817. var struct3501s []models.Struct3501
  38818. var struct3501 models.Struct3501
  38819. struct3501.OrgName = miConfig.OrgName
  38820. struct3501.AccessKey = miConfig.AccessKey
  38821. struct3501.RequestUrl = miConfig.Url
  38822. struct3501.SecretKey = miConfig.SecretKey
  38823. struct3501.ManuDate = "2022-08-15"
  38824. struct3501.FixmedinsBchno = ""
  38825. struct3501.ManuLotnum = ""
  38826. struct3501.RxFlag = "0"
  38827. struct3501.ExpyEnd = "2022-08-15"
  38828. struct3501.Invdate = "2022-08-15"
  38829. struct3501.InvCnt = "20.25"
  38830. struct3501.Memo = ""
  38831. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38832. struct3501.FixmedinsHilistId = miConfig.Code
  38833. struct3501.FixmedinsHilistName = miConfig.OrgName
  38834. struct3501s = append(struct3501s, struct3501)
  38835. data["struct_3501s"] = struct3501s
  38836. client := &http.Client{}
  38837. bytesData, _ := json.Marshal(data)
  38838. var req *http.Request
  38839. if miConfig.MdtrtareaAdmvs == "320921" {
  38840. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38841. } else {
  38842. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38843. }
  38844. resp, _ := client.Do(req)
  38845. defer resp.Body.Close()
  38846. body, ioErr := ioutil.ReadAll(resp.Body)
  38847. if ioErr != nil {
  38848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38850. return
  38851. }
  38852. var respJSON map[string]interface{}
  38853. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38856. return
  38857. }
  38858. var res ResultSix
  38859. var resSix10265 ResultSix10265 //1101结果
  38860. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38861. result, _ := json.Marshal(respJSON)
  38862. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38863. utils.ErrorLog("解析失败:%v", err)
  38864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38865. return
  38866. }
  38867. res.InfRefmsgid = resSix10265.InfRefmsgid
  38868. res.Output = resSix10265.Output
  38869. res.ErrMsg = resSix10265.ErrMsg
  38870. res.Cainfo = resSix10265.Cainfo
  38871. res.WarnMsg = resSix10265.WarnMsg
  38872. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38873. res.Infcode = infocode
  38874. if infocode == 0 {
  38875. c.ServeSuccessJSON(map[string]interface{}{
  38876. "msg": "上传成功",
  38877. })
  38878. return
  38879. } else {
  38880. c.ServeSuccessJSON(map[string]interface{}{
  38881. "failed_code": -10,
  38882. "msg": res.ErrMsg,
  38883. })
  38884. return
  38885. }
  38886. }
  38887. func (c *HisApiController) Post3506() {
  38888. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38889. data := make(map[string]interface{})
  38890. var struct3501s []models.Struct3501
  38891. var struct3501 models.Struct3501
  38892. struct3501.OrgName = miConfig.OrgName
  38893. struct3501.AccessKey = miConfig.AccessKey
  38894. struct3501.RequestUrl = miConfig.Url
  38895. struct3501.SecretKey = miConfig.SecretKey
  38896. struct3501.ManuDate = "2022-08-15"
  38897. struct3501.FixmedinsBchno = ""
  38898. struct3501.ManuLotnum = ""
  38899. struct3501.RxFlag = "0"
  38900. struct3501.ExpyEnd = "2022-08-15"
  38901. struct3501.Invdate = "2022-08-15"
  38902. struct3501.InvCnt = "20.25"
  38903. struct3501.Memo = ""
  38904. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38905. struct3501.FixmedinsHilistId = miConfig.Code
  38906. struct3501.FixmedinsHilistName = miConfig.OrgName
  38907. struct3501s = append(struct3501s, struct3501)
  38908. data["struct_3501s"] = struct3501s
  38909. client := &http.Client{}
  38910. bytesData, _ := json.Marshal(data)
  38911. var req *http.Request
  38912. if miConfig.MdtrtareaAdmvs == "320921" {
  38913. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38914. } else {
  38915. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38916. }
  38917. resp, _ := client.Do(req)
  38918. defer resp.Body.Close()
  38919. body, ioErr := ioutil.ReadAll(resp.Body)
  38920. if ioErr != nil {
  38921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38923. return
  38924. }
  38925. var respJSON map[string]interface{}
  38926. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38929. return
  38930. }
  38931. var res ResultSix
  38932. var resSix10265 ResultSix10265 //1101结果
  38933. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38934. result, _ := json.Marshal(respJSON)
  38935. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38936. utils.ErrorLog("解析失败:%v", err)
  38937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38938. return
  38939. }
  38940. res.InfRefmsgid = resSix10265.InfRefmsgid
  38941. res.Output = resSix10265.Output
  38942. res.ErrMsg = resSix10265.ErrMsg
  38943. res.Cainfo = resSix10265.Cainfo
  38944. res.WarnMsg = resSix10265.WarnMsg
  38945. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38946. res.Infcode = infocode
  38947. if infocode == 0 {
  38948. c.ServeSuccessJSON(map[string]interface{}{
  38949. "msg": "上传成功",
  38950. })
  38951. return
  38952. } else {
  38953. c.ServeSuccessJSON(map[string]interface{}{
  38954. "failed_code": -10,
  38955. "msg": res.ErrMsg,
  38956. })
  38957. return
  38958. }
  38959. }
  38960. func (c *HisApiController) Post3507() {
  38961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38962. data := make(map[string]interface{})
  38963. var struct3501s []models.Struct3501
  38964. var struct3501 models.Struct3501
  38965. struct3501.OrgName = miConfig.OrgName
  38966. struct3501.AccessKey = miConfig.AccessKey
  38967. struct3501.RequestUrl = miConfig.Url
  38968. struct3501.SecretKey = miConfig.SecretKey
  38969. struct3501.ManuDate = "2022-08-15"
  38970. struct3501.FixmedinsBchno = ""
  38971. struct3501.ManuLotnum = ""
  38972. struct3501.RxFlag = "0"
  38973. struct3501.ExpyEnd = "2022-08-15"
  38974. struct3501.Invdate = "2022-08-15"
  38975. struct3501.InvCnt = "20.25"
  38976. struct3501.Memo = ""
  38977. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38978. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  38979. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  38980. struct3501s = append(struct3501s, struct3501)
  38981. data["struct_3501s"] = struct3501s
  38982. client := &http.Client{}
  38983. bytesData, _ := json.Marshal(data)
  38984. var req *http.Request
  38985. if miConfig.MdtrtareaAdmvs == "320921" {
  38986. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38987. } else {
  38988. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38989. }
  38990. resp, _ := client.Do(req)
  38991. defer resp.Body.Close()
  38992. body, ioErr := ioutil.ReadAll(resp.Body)
  38993. if ioErr != nil {
  38994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38996. return
  38997. }
  38998. var respJSON map[string]interface{}
  38999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39002. return
  39003. }
  39004. var res ResultSix
  39005. var resSix10265 ResultSix10265 //1101结果
  39006. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39007. result, _ := json.Marshal(respJSON)
  39008. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39009. utils.ErrorLog("解析失败:%v", err)
  39010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39011. return
  39012. }
  39013. res.InfRefmsgid = resSix10265.InfRefmsgid
  39014. res.Output = resSix10265.Output
  39015. res.ErrMsg = resSix10265.ErrMsg
  39016. res.Cainfo = resSix10265.Cainfo
  39017. res.WarnMsg = resSix10265.WarnMsg
  39018. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39019. res.Infcode = infocode
  39020. if infocode == 0 {
  39021. c.ServeSuccessJSON(map[string]interface{}{
  39022. "msg": "上传成功",
  39023. })
  39024. return
  39025. } else {
  39026. c.ServeSuccessJSON(map[string]interface{}{
  39027. "failed_code": -10,
  39028. "msg": res.ErrMsg,
  39029. })
  39030. return
  39031. }
  39032. }
  39033. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39034. // WebSocket服务器地址
  39035. serverURL := "ws://127.0.0.1:8899"
  39036. // 解析WebSocket服务器地址
  39037. u, err := url.Parse(serverURL)
  39038. if err != nil {
  39039. }
  39040. // 建立WebSocket连接
  39041. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39042. if err != nil {
  39043. }
  39044. defer conn.Close()
  39045. input2 := make(map[string]interface{})
  39046. input := make(map[string]interface{})
  39047. inputData := make(map[string]interface{})
  39048. inputData["orgId"] = code
  39049. inputData["businessType"] = "01101"
  39050. inputData["operatorId"] = operator_id
  39051. inputData["operatorName"] = operator_name
  39052. inputData["officeId"] = "001"
  39053. inputData["officeName"] = "血透室"
  39054. inputData["deviceType"] = ""
  39055. input["data"] = inputData
  39056. input["orgId"] = code
  39057. input["transType"] = "ec.query"
  39058. //if md == ""
  39059. if md[:4] == "4403" {
  39060. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39061. } else if md[:4] == "4401" {
  39062. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39063. } else {
  39064. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39065. }
  39066. input2["indata"] = input
  39067. fmt.Println(input2)
  39068. bytesData, _ := json.Marshal(input2)
  39069. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39070. if err != nil {
  39071. fmt.Println(err)
  39072. }
  39073. // 接收消息
  39074. _, receivedMessage, err := conn.ReadMessage()
  39075. if err != nil {
  39076. fmt.Println(err)
  39077. }
  39078. return "", string(receivedMessage)
  39079. }
  39080. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39081. // WebSocket服务器地址
  39082. serverURL := "ws://127.0.0.1:8899"
  39083. // 解析WebSocket服务器地址
  39084. u, err := url.Parse(serverURL)
  39085. if err != nil {
  39086. }
  39087. // 建立WebSocket连接
  39088. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39089. if err != nil {
  39090. }
  39091. defer conn.Close()
  39092. input2 := make(map[string]interface{})
  39093. input := make(map[string]interface{})
  39094. inputData := make(map[string]interface{})
  39095. inputData["orgId"] = code
  39096. inputData["businessType"] = "01101"
  39097. inputData["operatorId"] = operator_id
  39098. inputData["operatorName"] = operator_name
  39099. inputData["officeId"] = "001"
  39100. inputData["officeName"] = "血透室"
  39101. inputData["deviceType"] = ""
  39102. input["data"] = inputData
  39103. input["orgId"] = code
  39104. input["transType"] = "ec.query"
  39105. //if md == ""
  39106. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39107. input2["indata"] = input
  39108. fmt.Println(input2)
  39109. bytesData, _ := json.Marshal(input2)
  39110. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39111. if err != nil {
  39112. fmt.Println(err)
  39113. }
  39114. // 接收消息
  39115. _, receivedMessage, err := conn.ReadMessage()
  39116. if err != nil {
  39117. fmt.Println(err)
  39118. }
  39119. return "", string(receivedMessage)
  39120. }
  39121. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39122. // WebSocket服务器地址
  39123. serverURL := "ws://127.0.0.1:8899"
  39124. // 解析WebSocket服务器地址
  39125. u, err := url.Parse(serverURL)
  39126. if err != nil {
  39127. }
  39128. // 建立WebSocket连接
  39129. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39130. if err != nil {
  39131. }
  39132. defer conn.Close()
  39133. input2 := make(map[string]interface{})
  39134. input := make(map[string]interface{})
  39135. inputData := make(map[string]interface{})
  39136. inputData["orgId"] = code
  39137. inputData["businessType"] = "01301"
  39138. inputData["operatorId"] = operator_id
  39139. inputData["operatorName"] = operator_name
  39140. inputData["officeId"] = "001"
  39141. inputData["officeName"] = "血透室"
  39142. inputData["deviceType"] = ""
  39143. input["data"] = inputData
  39144. input["orgId"] = code
  39145. input["transType"] = "ec.query"
  39146. //if md == ""
  39147. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39148. input2["indata"] = input
  39149. fmt.Println(input2)
  39150. bytesData, _ := json.Marshal(input2)
  39151. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39152. if err != nil {
  39153. fmt.Println(err)
  39154. }
  39155. // 接收消息
  39156. _, receivedMessage, err := conn.ReadMessage()
  39157. if err != nil {
  39158. fmt.Println(err)
  39159. }
  39160. return "", string(receivedMessage)
  39161. }
  39162. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39163. // WebSocket服务器地址
  39164. serverURL := "ws://127.0.0.1:8899"
  39165. // 解析WebSocket服务器地址
  39166. u, err := url.Parse(serverURL)
  39167. if err != nil {
  39168. }
  39169. // 建立WebSocket连接
  39170. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39171. if err != nil {
  39172. }
  39173. defer conn.Close()
  39174. input2 := make(map[string]interface{})
  39175. input := make(map[string]interface{})
  39176. inputData := make(map[string]interface{})
  39177. inputData["orgId"] = code
  39178. inputData["businessType"] = "01103"
  39179. inputData["operatorId"] = operator_id
  39180. inputData["operatorName"] = operator_name
  39181. inputData["officeId"] = "001"
  39182. inputData["officeName"] = "血透室"
  39183. inputData["deviceType"] = ""
  39184. input["data"] = inputData
  39185. input["orgId"] = code
  39186. input["transType"] = "ec.query"
  39187. //if md ==
  39188. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39189. input2["indata"] = input
  39190. fmt.Println(input2)
  39191. bytesData, _ := json.Marshal(input2)
  39192. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39193. if err != nil {
  39194. fmt.Println(err)
  39195. }
  39196. // 接收消息
  39197. _, receivedMessage, err := conn.ReadMessage()
  39198. if err != nil {
  39199. fmt.Println(err)
  39200. }
  39201. return "", string(receivedMessage)
  39202. }
  39203. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39204. // WebSocket服务器地址
  39205. serverURL := "ws://127.0.0.1:8899"
  39206. // 解析WebSocket服务器地址
  39207. u, err := url.Parse(serverURL)
  39208. if err != nil {
  39209. }
  39210. // 建立WebSocket连接
  39211. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39212. if err != nil {
  39213. }
  39214. defer conn.Close()
  39215. input2 := make(map[string]interface{})
  39216. input := make(map[string]interface{})
  39217. inputData := make(map[string]interface{})
  39218. inputData["orgId"] = code
  39219. inputData["businessType"] = "01101"
  39220. inputData["operatorId"] = operator_id
  39221. inputData["operatorName"] = operator_name
  39222. inputData["officeId"] = "001"
  39223. inputData["officeName"] = "血透室"
  39224. inputData["deviceType"] = ""
  39225. input["data"] = inputData
  39226. input["orgId"] = code
  39227. input["transType"] = "ec.query"
  39228. //if md == ""
  39229. if md[:4] == "4403" {
  39230. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39231. } else if md[:4] == "4401" {
  39232. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39233. } else {
  39234. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39235. }
  39236. input2["indata"] = input
  39237. fmt.Println(input2)
  39238. bytesData, _ := json.Marshal(input2)
  39239. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39240. if err != nil {
  39241. fmt.Println(err)
  39242. }
  39243. // 接收消息
  39244. _, receivedMessage, err := conn.ReadMessage()
  39245. if err != nil {
  39246. fmt.Println(err)
  39247. }
  39248. return "", string(receivedMessage)
  39249. }
  39250. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39251. // WebSocket服务器地址
  39252. serverURL := "ws://127.0.0.1:8899"
  39253. // 解析WebSocket服务器地址
  39254. u, err := url.Parse(serverURL)
  39255. if err != nil {
  39256. }
  39257. // 建立WebSocket连接
  39258. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39259. if err != nil {
  39260. }
  39261. defer conn.Close()
  39262. input2 := make(map[string]interface{})
  39263. input := make(map[string]interface{})
  39264. inputData := make(map[string]interface{})
  39265. inputData["orgId"] = code
  39266. inputData["businessType"] = "01301"
  39267. inputData["operatorId"] = operator_id
  39268. inputData["operatorName"] = operator_name
  39269. inputData["officeId"] = "001"
  39270. inputData["officeName"] = "血透室"
  39271. inputData["deviceType"] = ""
  39272. input["data"] = inputData
  39273. input["orgId"] = code
  39274. input["transType"] = "ec.query"
  39275. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39276. input2["indata"] = input
  39277. bytesData, _ := json.Marshal(input2)
  39278. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39279. if err != nil {
  39280. fmt.Println(err)
  39281. }
  39282. // 接收消息
  39283. _, receivedMessage, err := conn.ReadMessage()
  39284. if err != nil {
  39285. fmt.Println(err)
  39286. }
  39287. return "", string(receivedMessage)
  39288. }
  39289. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39290. newArr = make([]string, 0)
  39291. for i := 0; i < len(arr); i++ {
  39292. repeat := false
  39293. for j := i + 1; j < len(arr); j++ {
  39294. if arr[i] == arr[j] {
  39295. repeat = true
  39296. break
  39297. }
  39298. }
  39299. if !repeat {
  39300. newArr = append(newArr, arr[i])
  39301. }
  39302. }
  39303. return
  39304. }
  39305. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39306. if len(idNumber) != 18 {
  39307. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39308. }
  39309. // 提取出生日期
  39310. year, err := strconv.Atoi(idNumber[6:10])
  39311. if err != nil {
  39312. return "", 0, err
  39313. }
  39314. month, err := strconv.Atoi(idNumber[10:12])
  39315. if err != nil {
  39316. return "", 0, err
  39317. }
  39318. day, err := strconv.Atoi(idNumber[12:14])
  39319. if err != nil {
  39320. return "", 0, err
  39321. }
  39322. // 格式化生日字符串
  39323. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39324. birthdateFormatted := birthdate.Format("2006-01-02")
  39325. // 计算年龄
  39326. today := time.Now()
  39327. age := today.Year() - birthdate.Year()
  39328. if today.YearDay() < birthdate.YearDay() {
  39329. age--
  39330. }
  39331. return birthdateFormatted, age, nil
  39332. }
  39333. // 从身份证号码中提取出生年月日
  39334. func getBirthDateFromIDCard(idCard string) (string, error) {
  39335. // 身份证号码长度应为18位
  39336. if len(idCard) != 18 {
  39337. return "", fmt.Errorf("身份证号码长度应为18位")
  39338. }
  39339. // 提取出生日期部分 (YYYYMMDD)
  39340. birthDateStr := idCard[6:14]
  39341. // 解析出生日期
  39342. birthDate, err := time.Parse("20060102", birthDateStr)
  39343. if err != nil {
  39344. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39345. }
  39346. // 格式化出生日期为 YYYY-MM-DD
  39347. formattedDate := birthDate.Format("2006-01-02")
  39348. return formattedDate, nil
  39349. }