his_api_controller.go 1.7MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522
  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/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  117. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. //beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. //beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. //beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. //beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  172. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  173. //beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  174. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  175. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  176. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  177. }
  178. func (c *HisApiController) Get5101() {
  179. adminUser := c.GetAdminUserInfo()
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. if miConfig.MdtrtareaAdmvs == "341203" {
  184. fmt.Println(miConfig.SecretKey)
  185. var res models.Result9001Two
  186. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  187. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  188. resp, requestErr := http.Get(api)
  189. if requestErr != nil {
  190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. return
  192. }
  193. body, ioErr := ioutil.ReadAll(resp.Body)
  194. if ioErr != nil {
  195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  197. return
  198. }
  199. var respJSON map[string]interface{}
  200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. status := respJSON["data"].(map[string]interface{})["status"].(string)
  206. if status == "0" {
  207. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "failed_code": -10,
  210. "msg": err_msg,
  211. })
  212. return
  213. }
  214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  215. result, _ := json.Marshal(respJSON)
  216. fmt.Println("log")
  217. fmt.Println(string(result))
  218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. if res.Infcode == 0 {
  224. sign := models.HisSignIn{
  225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  226. SignNo: res.Output.Signinoutb.SignNo,
  227. SignTime: "",
  228. Ctime: time.Now().Unix(),
  229. Mtime: time.Now().Unix(),
  230. Status: 1,
  231. InputLog: "",
  232. OutputLog: "",
  233. FixmedinsCode: miConfig.Code,
  234. }
  235. err := service.CreateSignIn(&sign)
  236. if err == nil {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "签到成功",
  239. })
  240. }
  241. } else {
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "failed_code": -10,
  244. "msg": res.ErrMsg,
  245. })
  246. return
  247. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  248. //return
  249. }
  250. } else if miConfig.MdtrtareaAdmvs == "340699" {
  251. fmt.Println(miConfig.SecretKey)
  252. var res models.Result9001Two
  253. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  255. resp, requestErr := http.Get(api)
  256. if requestErr != nil {
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. return
  259. }
  260. body, ioErr := ioutil.ReadAll(resp.Body)
  261. if ioErr != nil {
  262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  264. return
  265. }
  266. var respJSON map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. status := respJSON["data"].(map[string]interface{})["status"].(string)
  273. if status == "0" {
  274. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  275. c.ServeSuccessJSON(map[string]interface{}{
  276. "failed_code": -10,
  277. "msg": err_msg,
  278. })
  279. return
  280. }
  281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  282. result, _ := json.Marshal(respJSON)
  283. fmt.Println("log")
  284. fmt.Println(string(result))
  285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  286. utils.ErrorLog("解析失败:%v", err)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. if res.Infcode == 0 {
  291. sign := models.HisSignIn{
  292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  293. SignNo: res.Output.Signinoutb.SignNo,
  294. SignTime: "",
  295. Ctime: time.Now().Unix(),
  296. Mtime: time.Now().Unix(),
  297. Status: 1,
  298. InputLog: "",
  299. OutputLog: "",
  300. FixmedinsCode: miConfig.Code,
  301. }
  302. err := service.CreateSignIn(&sign)
  303. if err == nil {
  304. c.ServeSuccessJSON(map[string]interface{}{
  305. "msg": "查询成功",
  306. })
  307. }
  308. } else {
  309. c.ServeSuccessJSON(map[string]interface{}{
  310. "failed_code": -10,
  311. "msg": res.ErrMsg,
  312. })
  313. return
  314. }
  315. }
  316. }
  317. func (c *HisApiController) Get5102() {
  318. adminUser := c.GetAdminUserInfo()
  319. admin_user_id, _ := c.GetInt64("admin_user_id")
  320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  322. if miConfig.MdtrtareaAdmvs == "341203" {
  323. fmt.Println(miConfig.SecretKey)
  324. var res models.Result9001Two
  325. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  326. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  327. resp, requestErr := http.Get(api)
  328. if requestErr != nil {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. body, ioErr := ioutil.ReadAll(resp.Body)
  333. if ioErr != nil {
  334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. return
  337. }
  338. var respJSON map[string]interface{}
  339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  342. return
  343. }
  344. status := respJSON["data"].(map[string]interface{})["status"].(string)
  345. if status == "0" {
  346. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "failed_code": -10,
  349. "msg": err_msg,
  350. })
  351. return
  352. }
  353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  354. result, _ := json.Marshal(respJSON)
  355. fmt.Println("log")
  356. fmt.Println(string(result))
  357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  358. utils.ErrorLog("解析失败:%v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. if res.Infcode == 0 {
  363. sign := models.HisSignIn{
  364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  365. SignNo: res.Output.Signinoutb.SignNo,
  366. SignTime: "",
  367. Ctime: time.Now().Unix(),
  368. Mtime: time.Now().Unix(),
  369. Status: 1,
  370. InputLog: "",
  371. OutputLog: "",
  372. FixmedinsCode: miConfig.Code,
  373. }
  374. err := service.CreateSignIn(&sign)
  375. if err == nil {
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "msg": "签到成功",
  378. })
  379. }
  380. } else {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. return
  386. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  387. //return
  388. }
  389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  390. fmt.Println(miConfig.SecretKey)
  391. var res models.Result9001Two
  392. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  394. resp, requestErr := http.Get(api)
  395. if requestErr != nil {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. body, ioErr := ioutil.ReadAll(resp.Body)
  400. if ioErr != nil {
  401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. var respJSON map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  412. if status == "0" {
  413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  414. c.ServeSuccessJSON(map[string]interface{}{
  415. "failed_code": -10,
  416. "msg": err_msg,
  417. })
  418. return
  419. }
  420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  421. result, _ := json.Marshal(respJSON)
  422. fmt.Println("log")
  423. fmt.Println(string(result))
  424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == 0 {
  430. sign := models.HisSignIn{
  431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  432. SignNo: res.Output.Signinoutb.SignNo,
  433. SignTime: "",
  434. Ctime: time.Now().Unix(),
  435. Mtime: time.Now().Unix(),
  436. Status: 1,
  437. InputLog: "",
  438. OutputLog: "",
  439. FixmedinsCode: miConfig.Code,
  440. }
  441. err := service.CreateSignIn(&sign)
  442. if err == nil {
  443. c.ServeSuccessJSON(map[string]interface{}{
  444. "msg": "查询成功",
  445. })
  446. }
  447. } else {
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "failed_code": -10,
  450. "msg": res.ErrMsg,
  451. })
  452. return
  453. }
  454. }
  455. }
  456. func (c *HisApiController) Get3201() {
  457. adminUser := c.GetAdminUserInfo()
  458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  459. 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)
  460. var response Response
  461. if err := json.Unmarshal([]byte(result), &response); err != nil {
  462. fmt.Println("Error decoding JSON:", err)
  463. return
  464. }
  465. }
  466. func (c *HisApiController) TestNet() {
  467. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. //return
  469. c.ServeSuccessJSON(map[string]interface{}{
  470. "msg": "成功",
  471. })
  472. }
  473. func (c *HisApiController) Get3508() {
  474. admin_user_id, _ := c.GetInt64("admin_user_id")
  475. drug_id, _ := c.GetInt64("id")
  476. start_time := c.GetString("start_time")
  477. end_time := c.GetString("end_time")
  478. adminUser := c.GetAdminUserInfo()
  479. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  481. drug, _ := service.GetDrugByID(drug_id)
  482. var struct3508 models.Struct3508
  483. struct3508.OrgName = miConfig.OrgName
  484. struct3508.FixmedinsCode = miConfig.Code
  485. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  486. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  487. struct3508.AccessKey = miConfig.AccessKey
  488. struct3508.Opter = curRoles.UserName
  489. struct3508.RequestUrl = miConfig.Url
  490. struct3508.Url = miConfig.Url
  491. struct3508.AppId = miConfig.Cainfo
  492. struct3508.AppSecret = miConfig.AppSecret
  493. struct3508.Enckey = miConfig.EncKey
  494. struct3508.SignKey = miConfig.SignKey
  495. struct3508.SecretKey = miConfig.SecretKey
  496. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  497. struct3508.Begndate = start_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. struct3508.Enddate = end_time
  501. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  502. result1, result2 := service.Gdyb3508(struct3508, struct3508.SecretKey)
  503. saveLog(result1, result2, "3508", "3508")
  504. var res models.Result3508
  505. var respJSON2 map[string]interface{}
  506. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  509. return
  510. }
  511. userJSONBytes2, _ := json.Marshal(respJSON2)
  512. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  513. utils.ErrorLog("解析失败:%v", err)
  514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  515. return
  516. }
  517. if res.Infcode == -1 {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "failed_code": -10,
  520. "msg": res.ErrMsg,
  521. })
  522. } else {
  523. c.ServeSuccessJSON(map[string]interface{}{
  524. "info": res.Output,
  525. })
  526. }
  527. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  528. result1, result2, _ := service.FJyb3508(struct3508)
  529. saveLog(result1, result2, "3508", "3508")
  530. var res models.Result3508
  531. var respJSON2 map[string]interface{}
  532. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  535. return
  536. }
  537. userJSONBytes2, _ := json.Marshal(respJSON2)
  538. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  539. utils.ErrorLog("解析失败:%v", err)
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  541. return
  542. }
  543. if res.Infcode == -1 {
  544. c.ServeSuccessJSON(map[string]interface{}{
  545. "failed_code": -10,
  546. "msg": res.ErrMsg,
  547. })
  548. } else {
  549. c.ServeSuccessJSON(map[string]interface{}{
  550. "info": res.Output,
  551. })
  552. }
  553. }
  554. }
  555. func (c *HisApiController) Get3509() {
  556. admin_user_id, _ := c.GetInt64("admin_user_id")
  557. drug_id, _ := c.GetInt64("id")
  558. start_time := c.GetString("start_time")
  559. end_time := c.GetString("end_time")
  560. adminUser := c.GetAdminUserInfo()
  561. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  562. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  563. drug, _ := service.GetDrugByID(drug_id)
  564. var struct3508 models.Struct3509
  565. struct3508.OrgName = miConfig.OrgName
  566. struct3508.FixmedinsCode = miConfig.Code
  567. struct3508.AccessKey = miConfig.AccessKey
  568. struct3508.Opter = curRoles.UserName
  569. struct3508.RequestUrl = miConfig.Url
  570. struct3508.Url = miConfig.Url
  571. struct3508.AppId = miConfig.Cainfo
  572. struct3508.AppSecret = miConfig.AppSecret
  573. struct3508.Enckey = miConfig.EncKey
  574. struct3508.SignKey = miConfig.SignKey
  575. struct3508.SecretKey = miConfig.SecretKey
  576. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  577. struct3508.Begndate = start_time
  578. struct3508.Enddate = end_time
  579. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  580. result1, result2 := service.Gdyb3509(struct3508, struct3508.SecretKey)
  581. saveLog(result1, result2, "3509", "3509")
  582. var res models.Result3508
  583. var respJSON2 map[string]interface{}
  584. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  587. return
  588. }
  589. userJSONBytes2, _ := json.Marshal(respJSON2)
  590. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  591. utils.ErrorLog("解析失败:%v", err)
  592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  593. return
  594. }
  595. if res.Infcode == -1 {
  596. c.ServeSuccessJSON(map[string]interface{}{
  597. "failed_code": -10,
  598. "msg": res.ErrMsg,
  599. })
  600. } else {
  601. c.ServeSuccessJSON(map[string]interface{}{
  602. "info": res.Output,
  603. })
  604. }
  605. } else {
  606. result1, result2, _ := service.FJyb3509(struct3508)
  607. saveLog(result1, result2, "3509", "3509")
  608. var res models.Result3509
  609. var respJSON2 map[string]interface{}
  610. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  613. return
  614. }
  615. userJSONBytes2, _ := json.Marshal(respJSON2)
  616. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  617. utils.ErrorLog("解析失败:%v", err)
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. return
  620. }
  621. if res.Infcode == -1 {
  622. c.ServeSuccessJSON(map[string]interface{}{
  623. "failed_code": -10,
  624. "msg": res.ErrMsg,
  625. })
  626. } else {
  627. c.ServeSuccessJSON(map[string]interface{}{
  628. "info": res.Output,
  629. })
  630. }
  631. }
  632. }
  633. func (c *HisApiController) Get3510() {
  634. admin_user_id, _ := c.GetInt64("admin_user_id")
  635. drug_id, _ := c.GetInt64("id")
  636. start_time := c.GetString("start_time")
  637. end_time := c.GetString("end_time")
  638. adminUser := c.GetAdminUserInfo()
  639. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  640. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  641. drug, _ := service.GetDrugByID(drug_id)
  642. var struct3508 models.Struct3510
  643. struct3508.FixmedinsCode = miConfig.Code
  644. struct3508.OrgName = miConfig.OrgName
  645. struct3508.AccessKey = miConfig.AccessKey
  646. struct3508.Opter = curRoles.UserName
  647. struct3508.RequestUrl = miConfig.Url
  648. struct3508.Url = miConfig.Url
  649. struct3508.AppId = miConfig.Cainfo
  650. struct3508.AppSecret = miConfig.AppSecret
  651. struct3508.Enckey = miConfig.EncKey
  652. struct3508.SignKey = miConfig.SignKey
  653. struct3508.SecretKey = miConfig.SecretKey
  654. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  655. struct3508.Begndate = start_time
  656. struct3508.Enddate = end_time
  657. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  658. result1, result2 := service.Gdyb3510(struct3508, struct3508.SecretKey)
  659. saveLog(result1, result2, "3510", "3510")
  660. var res models.Result3510
  661. var respJSON2 map[string]interface{}
  662. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  665. return
  666. }
  667. userJSONBytes2, _ := json.Marshal(respJSON2)
  668. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  669. utils.ErrorLog("解析失败:%v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. if res.Infcode == -1 {
  674. c.ServeSuccessJSON(map[string]interface{}{
  675. "failed_code": -10,
  676. "msg": res.ErrMsg,
  677. })
  678. } else {
  679. c.ServeSuccessJSON(map[string]interface{}{
  680. "info": res.Output,
  681. })
  682. }
  683. } else {
  684. result1, result2, _ := service.FJyb3510(struct3508)
  685. saveLog(result1, result2, "3510", "3510")
  686. var res models.Result3510
  687. var respJSON2 map[string]interface{}
  688. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  691. return
  692. }
  693. userJSONBytes2, _ := json.Marshal(respJSON2)
  694. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  695. utils.ErrorLog("解析失败:%v", err)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. if res.Infcode == -1 {
  700. c.ServeSuccessJSON(map[string]interface{}{
  701. "failed_code": -10,
  702. "msg": res.ErrMsg,
  703. })
  704. } else {
  705. c.ServeSuccessJSON(map[string]interface{}{
  706. "info": res.Output,
  707. })
  708. }
  709. }
  710. }
  711. func (c *HisApiController) Get3511() {
  712. admin_user_id, _ := c.GetInt64("admin_user_id")
  713. drug_id, _ := c.GetInt64("id")
  714. start_time := c.GetString("start_time")
  715. end_time := c.GetString("end_time")
  716. adminUser := c.GetAdminUserInfo()
  717. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  719. drug, _ := service.GetDrugByID(drug_id)
  720. var struct3508 models.Struct3511
  721. struct3508.FixmedinsCode = miConfig.Code
  722. struct3508.OrgName = miConfig.OrgName
  723. struct3508.AccessKey = miConfig.AccessKey
  724. struct3508.Opter = curRoles.UserName
  725. struct3508.RequestUrl = miConfig.Url
  726. struct3508.Url = miConfig.Url
  727. struct3508.AppId = miConfig.Cainfo
  728. struct3508.AppSecret = miConfig.AppSecret
  729. struct3508.Enckey = miConfig.EncKey
  730. struct3508.SignKey = miConfig.SignKey
  731. struct3508.SecretKey = miConfig.SecretKey
  732. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  733. struct3508.Begndate = start_time
  734. struct3508.Enddate = end_time
  735. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  736. result1, result2 := service.Gdyb3511(struct3508, struct3508.SecretKey)
  737. saveLog(result1, result2, "3511", "3511")
  738. var res models.Result3511
  739. var respJSON2 map[string]interface{}
  740. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  743. return
  744. }
  745. userJSONBytes2, _ := json.Marshal(respJSON2)
  746. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  747. utils.ErrorLog("解析失败:%v", err)
  748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  749. return
  750. }
  751. if res.Infcode == -1 {
  752. c.ServeSuccessJSON(map[string]interface{}{
  753. "failed_code": -10,
  754. "msg": res.ErrMsg,
  755. })
  756. } else {
  757. c.ServeSuccessJSON(map[string]interface{}{
  758. "info": res.Output,
  759. })
  760. }
  761. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  762. var res models.Result3511
  763. //安徽
  764. data := make(map[string]interface{})
  765. data["struct_3511s"] = struct3508
  766. client := &http.Client{}
  767. bytesData, _ := json.Marshal(data)
  768. var req *http.Request
  769. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3511", bytes.NewReader(bytesData))
  770. resp, _ := client.Do(req)
  771. defer resp.Body.Close()
  772. body, ioErr := ioutil.ReadAll(resp.Body)
  773. if ioErr != nil {
  774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  775. }
  776. var respJSON map[string]interface{}
  777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  780. return
  781. }
  782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  783. result, _ := json.Marshal(respJSON)
  784. if err := json.Unmarshal([]byte(result), &res); err != nil {
  785. //utils.ErrorLog("解析失败:%v", err)
  786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  787. return
  788. }
  789. if res.Infcode == -1 {
  790. c.ServeSuccessJSON(map[string]interface{}{
  791. "failed_code": -10,
  792. "msg": res.ErrMsg,
  793. })
  794. } else {
  795. c.ServeSuccessJSON(map[string]interface{}{
  796. "info": res.Output,
  797. })
  798. }
  799. } else {
  800. result1, result2, _ := service.FJyb3511(struct3508)
  801. saveLog(result1, result2, "3511", "3511")
  802. var res models.Result3511
  803. var respJSON2 map[string]interface{}
  804. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. userJSONBytes2, _ := json.Marshal(respJSON2)
  810. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  811. utils.ErrorLog("解析失败:%v", err)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. if res.Infcode == -1 {
  816. c.ServeSuccessJSON(map[string]interface{}{
  817. "failed_code": -10,
  818. "msg": res.ErrMsg,
  819. })
  820. } else {
  821. c.ServeSuccessJSON(map[string]interface{}{
  822. "info": res.Output,
  823. })
  824. }
  825. }
  826. }
  827. func (c *HisApiController) Get3512() {
  828. admin_user_id, _ := c.GetInt64("admin_user_id")
  829. drug_id, _ := c.GetInt64("id")
  830. start_time := c.GetString("start_time")
  831. end_time := c.GetString("end_time")
  832. adminUser := c.GetAdminUserInfo()
  833. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  835. drug, _ := service.GetDrugByIDTwo(drug_id, adminUser.CurrentOrgId)
  836. var infos models.Output2
  837. for _, item := range drug {
  838. var struct3508 models.Struct3512
  839. struct3508.FixmedinsCode = miConfig.Code
  840. struct3508.OrgName = miConfig.OrgName
  841. struct3508.AccessKey = miConfig.AccessKey
  842. struct3508.Opter = curRoles.UserName
  843. struct3508.RequestUrl = miConfig.Url
  844. struct3508.Url = miConfig.Url
  845. struct3508.AppId = miConfig.Cainfo
  846. struct3508.AppSecret = miConfig.AppSecret
  847. struct3508.Enckey = miConfig.EncKey
  848. struct3508.SignKey = miConfig.SignKey
  849. struct3508.SecretKey = miConfig.SecretKey
  850. struct3508.MedListCodg = item.MedicalInsuranceNumber
  851. struct3508.Begndate = start_time
  852. struct3508.Enddate = end_time
  853. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  854. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  855. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  856. result1, result2 := service.Gdyb3512(struct3508, struct3508.SecretKey)
  857. saveLog(result1, result2, "3512", "3512")
  858. var res models.Result3512
  859. var respJSON2 map[string]interface{}
  860. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  863. return
  864. }
  865. userJSONBytes2, _ := json.Marshal(respJSON2)
  866. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  867. utils.ErrorLog("解析失败:%v", err)
  868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  869. return
  870. }
  871. for _, item := range res.Output {
  872. if item.ValiFlag == "1" {
  873. infos = append(infos, item)
  874. }
  875. }
  876. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  877. result1, result2, _ := service.FJyb3512(struct3508)
  878. saveLog(result1, result2, "3512", "3512")
  879. var res models.Result3512
  880. var respJSON2 map[string]interface{}
  881. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return
  885. }
  886. userJSONBytes2, _ := json.Marshal(respJSON2)
  887. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  888. utils.ErrorLog("解析失败:%v", err)
  889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  890. return
  891. }
  892. for _, item := range res.Output {
  893. if item.ValiFlag == "1" {
  894. infos = append(infos, item)
  895. }
  896. }
  897. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  898. var res models.Result3512
  899. //安徽
  900. data := make(map[string]interface{})
  901. data["struct_3512s"] = struct3508
  902. client := &http.Client{}
  903. bytesData, _ := json.Marshal(data)
  904. var req *http.Request
  905. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3512", bytes.NewReader(bytesData))
  906. resp, _ := client.Do(req)
  907. defer resp.Body.Close()
  908. body, ioErr := ioutil.ReadAll(resp.Body)
  909. if ioErr != nil {
  910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  911. }
  912. var respJSON map[string]interface{}
  913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  916. return
  917. }
  918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  919. result, _ := json.Marshal(respJSON)
  920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  921. //utils.ErrorLog("解析失败:%v", err)
  922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  923. return
  924. }
  925. for _, item := range res.Output {
  926. if item.ValiFlag == "1" {
  927. infos = append(infos, item)
  928. }
  929. }
  930. }
  931. }
  932. c.ServeSuccessJSON(map[string]interface{}{
  933. "info": infos,
  934. })
  935. }
  936. func (c *HisApiController) Get3513() {
  937. admin_user_id, _ := c.GetInt64("admin_user_id")
  938. drug_id, _ := c.GetInt64("id")
  939. start_time := c.GetString("start_time")
  940. end_time := c.GetString("end_time")
  941. adminUser := c.GetAdminUserInfo()
  942. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  943. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  944. //drug, _ := service.GetDrugByID(drug_id)
  945. drug, _ := service.GetDrugByIDTwo(drug_id, adminUser.CurrentOrgId)
  946. var infos models.Output3
  947. for _, item := range drug {
  948. var struct3508 models.Struct3513
  949. struct3508.FixmedinsCode = miConfig.Code
  950. struct3508.OrgName = miConfig.OrgName
  951. struct3508.AccessKey = miConfig.AccessKey
  952. struct3508.Opter = curRoles.UserName
  953. struct3508.RequestUrl = miConfig.Url
  954. struct3508.Url = miConfig.Url
  955. struct3508.AppId = miConfig.Cainfo
  956. struct3508.AppSecret = miConfig.AppSecret
  957. struct3508.Enckey = miConfig.EncKey
  958. struct3508.SignKey = miConfig.SignKey
  959. struct3508.SecretKey = miConfig.SecretKey
  960. struct3508.MedListCodg = item.MedicalInsuranceNumber
  961. struct3508.Begndate = start_time
  962. struct3508.Enddate = end_time
  963. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  964. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  965. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  966. result1, result2 := service.Gdyb3513(struct3508, struct3508.SecretKey)
  967. saveLog(result1, result2, "3513", "3513")
  968. var res models.Result3513
  969. var respJSON2 map[string]interface{}
  970. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  973. return
  974. }
  975. userJSONBytes2, _ := json.Marshal(respJSON2)
  976. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  977. utils.ErrorLog("解析失败:%v", err)
  978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  979. return
  980. }
  981. infos = append(infos, res.Output...)
  982. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  983. result1, result2, _ := service.FJyb3513(struct3508)
  984. saveLog(result1, result2, "3513", "3513")
  985. var res models.Result3513
  986. var respJSON2 map[string]interface{}
  987. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  990. return
  991. }
  992. userJSONBytes2, _ := json.Marshal(respJSON2)
  993. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  994. utils.ErrorLog("解析失败:%v", err)
  995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  996. return
  997. }
  998. infos = append(infos, res.Output...)
  999. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1000. var res models.Result3513
  1001. //安徽
  1002. data := make(map[string]interface{})
  1003. data["struct_3513s"] = struct3508
  1004. client := &http.Client{}
  1005. bytesData, _ := json.Marshal(data)
  1006. var req *http.Request
  1007. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3513", bytes.NewReader(bytesData))
  1008. resp, _ := client.Do(req)
  1009. defer resp.Body.Close()
  1010. body, ioErr := ioutil.ReadAll(resp.Body)
  1011. if ioErr != nil {
  1012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1013. }
  1014. var respJSON map[string]interface{}
  1015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1021. result, _ := json.Marshal(respJSON)
  1022. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1023. //utils.ErrorLog("解析失败:%v", err)
  1024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1025. return
  1026. }
  1027. infos = append(infos, res.Output...)
  1028. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") { //
  1029. result1, result2 := service.JXyb3513(struct3508, struct3508.SecretKey, struct3508.AccessKey, struct3508.RequestUrl)
  1030. saveLog(result1, result2, "3513", "3513")
  1031. var res models.Result3513
  1032. var respJSON2 map[string]interface{}
  1033. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1036. return
  1037. }
  1038. userJSONBytes2, _ := json.Marshal(respJSON2)
  1039. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1040. utils.ErrorLog("解析失败:%v", err)
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1042. return
  1043. }
  1044. infos = append(infos, res.Output...)
  1045. }
  1046. }
  1047. type Newinfo struct {
  1048. FixmedinsCode string
  1049. MedListCodg string
  1050. MedinsListCodg string
  1051. MedinsListName string
  1052. FixmedinsBchno string
  1053. MdtrtId string
  1054. MdtrtSetlType string
  1055. BkkpSn string
  1056. DrugTracCodg string
  1057. PsnNo string
  1058. PsnCertType string
  1059. Certno string
  1060. PsnName string
  1061. Memo string
  1062. TrdnFlag string
  1063. UpdtTime string
  1064. OpterName string
  1065. Rid string
  1066. CrteTime string
  1067. OptTime string
  1068. OpterId string
  1069. CrterName string
  1070. CrterId string
  1071. OptinsNo string
  1072. }
  1073. var Newinfos []Newinfo
  1074. for _, item := range infos {
  1075. var ni Newinfo
  1076. patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1077. //patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1078. numbers := strings.Split(item.FixmedinsBchno, "-")
  1079. flow := service.GetSaleDate(numbers[1])
  1080. ni.MdtrtId = item.MdtrtId
  1081. ni.UpdtTime = flow.SaleDate
  1082. ni.PsnName = patient.Name
  1083. ni.Certno = item.Certno
  1084. ni.MedinsListName = item.MedinsListName
  1085. ni.FixmedinsBchno = item.FixmedinsBchno
  1086. ni.DrugTracCodg = item.DrugTracCodg
  1087. ni.MedListCodg = patient.Name
  1088. Newinfos = append(Newinfos, ni)
  1089. }
  1090. c.ServeSuccessJSON(map[string]interface{}{
  1091. "info": Newinfos,
  1092. })
  1093. }
  1094. func (c *HisApiController) Get35081() {
  1095. admin_user_id, _ := c.GetInt64("admin_user_id")
  1096. drug_id, _ := c.GetInt64("id")
  1097. //start_time := c.GetString("start_time")
  1098. //end_time := c.GetString("end_time")
  1099. page, _ := c.GetInt("page")
  1100. adminUser := c.GetAdminUserInfo()
  1101. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1102. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1103. drug, _ := service.GetDrugByID(drug_id)
  1104. var struct3508 models.Struct35081
  1105. struct3508.FixmedinsCode = miConfig.Code
  1106. struct3508.OrgName = miConfig.OrgName
  1107. struct3508.AccessKey = miConfig.AccessKey
  1108. struct3508.Opter = curRoles.UserName
  1109. struct3508.RequestUrl = miConfig.Url
  1110. struct3508.Url = miConfig.Url
  1111. struct3508.AppId = miConfig.Cainfo
  1112. struct3508.AppSecret = miConfig.AppSecret
  1113. struct3508.Enckey = miConfig.EncKey
  1114. struct3508.SignKey = miConfig.SignKey
  1115. struct3508.SecretKey = miConfig.SecretKey
  1116. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1117. struct3508.PageNum = page
  1118. struct3508.PageSize = 10
  1119. result1, result2, _ := service.FJyb35081(struct3508)
  1120. saveLog(result1, result2, "35081", "35081")
  1121. var res models.Result35081
  1122. var respJSON2 map[string]interface{}
  1123. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1126. return
  1127. }
  1128. userJSONBytes2, _ := json.Marshal(respJSON2)
  1129. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1130. utils.ErrorLog("解析失败:%v", err)
  1131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1132. return
  1133. }
  1134. if res.Infcode == -1 {
  1135. c.ServeSuccessJSON(map[string]interface{}{
  1136. "failed_code": -10,
  1137. "msg": res.ErrMsg,
  1138. })
  1139. } else {
  1140. c.ServeSuccessJSON(map[string]interface{}{
  1141. "info": res.Output,
  1142. })
  1143. }
  1144. }
  1145. func (c *HisApiController) Get35082() {
  1146. admin_user_id, _ := c.GetInt64("admin_user_id")
  1147. drug_id, _ := c.GetInt64("id")
  1148. //start_time := c.GetString("start_time")
  1149. //end_time := c.GetString("end_time")
  1150. page, _ := c.GetInt("page")
  1151. adminUser := c.GetAdminUserInfo()
  1152. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1153. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1154. drug, _ := service.GetDrugByID(drug_id)
  1155. var struct3508 models.Struct35082
  1156. struct3508.FixmedinsCode = miConfig.Code
  1157. struct3508.OrgName = miConfig.OrgName
  1158. struct3508.AccessKey = miConfig.AccessKey
  1159. struct3508.Opter = curRoles.UserName
  1160. struct3508.RequestUrl = miConfig.Url
  1161. struct3508.Url = miConfig.Url
  1162. struct3508.AppId = miConfig.Cainfo
  1163. struct3508.AppSecret = miConfig.AppSecret
  1164. struct3508.Enckey = miConfig.EncKey
  1165. struct3508.SignKey = miConfig.SignKey
  1166. struct3508.SecretKey = miConfig.SecretKey
  1167. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1168. struct3508.PageNum = page
  1169. struct3508.PageSize = 10
  1170. result1, result2, _ := service.FJyb35082(struct3508)
  1171. saveLog(result1, result2, "35082", "35082")
  1172. var res models.Result35082
  1173. var respJSON2 map[string]interface{}
  1174. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1177. return
  1178. }
  1179. userJSONBytes2, _ := json.Marshal(respJSON2)
  1180. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1181. utils.ErrorLog("解析失败:%v", err)
  1182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1183. return
  1184. }
  1185. if res.Infcode == -1 {
  1186. c.ServeSuccessJSON(map[string]interface{}{
  1187. "failed_code": -10,
  1188. "msg": res.ErrMsg,
  1189. })
  1190. } else {
  1191. c.ServeSuccessJSON(map[string]interface{}{
  1192. "info": res.Output,
  1193. })
  1194. }
  1195. }
  1196. func IsDigit(s string) bool {
  1197. re := regexp.MustCompile("^[0-9]+$")
  1198. return re.MatchString(s)
  1199. }
  1200. func (c *HisApiController) FJ3501AND3502() {
  1201. ids := c.GetString("ids")
  1202. admin_user_id, _ := c.GetInt64("admin_user_id")
  1203. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1204. id_arr := strings.Split(ids, ",")
  1205. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1206. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1207. //规则判断
  1208. var errs []string
  1209. for _, drug := range drugs {
  1210. if drug.IsPc == 0 {
  1211. if len(drug.DrugCode) > 0 {
  1212. codes := strings.Split(drug.DrugCode, ",")
  1213. for _, code := range codes {
  1214. if len(code) > 0 {
  1215. if len(code) != 20 {
  1216. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1217. }
  1218. if IsDigit(code) == false {
  1219. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1220. }
  1221. }
  1222. }
  1223. }
  1224. }
  1225. }
  1226. if len(errs) > 0 {
  1227. c.ServeSuccessJSON(map[string]interface{}{
  1228. "failed_code": -10,
  1229. "msg": errs,
  1230. })
  1231. return
  1232. }
  1233. //库盘
  1234. for _, drug := range drugs {
  1235. if drug.IsPc == 0 {
  1236. var res2 ResultSix
  1237. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1238. var struct3501 models.Struct3501
  1239. struct3501.Code = miConfig.Code
  1240. struct3501.OrgName = miConfig.OrgName
  1241. struct3501.AccessKey = miConfig.AccessKey
  1242. struct3501.Opter = roles.UserName
  1243. struct3501.RequestUrl = miConfig.Url
  1244. struct3501.Url = miConfig.Url
  1245. struct3501.AppId = miConfig.Cainfo
  1246. struct3501.AppSecret = miConfig.AppSecret
  1247. struct3501.Enckey = miConfig.EncKey
  1248. struct3501.SignKey = miConfig.SignKey
  1249. struct3501.SecretKey = miConfig.SecretKey
  1250. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1251. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1252. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1253. struct3501.RxFlag = "1"
  1254. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1255. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1256. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1257. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1258. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1259. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1260. struct3501.FixmedinsBchno = number
  1261. struct3501.DrugTracCodg = drug.DrugCode
  1262. memo := make(map[string]interface{})
  1263. memo["pric"] = drug.Price
  1264. bytesData, _ := json.Marshal(memo)
  1265. struct3501.Memo = string(bytesData)
  1266. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1267. result1, result2, _ := service.FJyb3501(struct3501)
  1268. saveLog(result1, result2, "3501", "3501")
  1269. //saveLog(result, requestLog, "2201", "挂号")
  1270. var respJSON2 map[string]interface{}
  1271. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1274. return
  1275. }
  1276. userJSONBytes2, _ := json.Marshal(respJSON2)
  1277. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1278. utils.ErrorLog("解析失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. return
  1281. }
  1282. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1283. data := make(map[string]interface{})
  1284. data["struct_3501s"] = struct3501
  1285. client := &http.Client{}
  1286. bytesData, _ := json.Marshal(data)
  1287. var req *http.Request
  1288. if miConfig.MdtrtareaAdmvs == "320830" {
  1289. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1290. } else {
  1291. if miConfig.MdtrtareaAdmvs == "320921" {
  1292. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1293. } else {
  1294. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1295. }
  1296. }
  1297. resp, _ := client.Do(req)
  1298. defer resp.Body.Close()
  1299. body, ioErr := ioutil.ReadAll(resp.Body)
  1300. if ioErr != nil {
  1301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1302. }
  1303. var respJSON map[string]interface{}
  1304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1307. return
  1308. }
  1309. var resSix10265 ResultSix10265 //1101结果
  1310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1311. result, _ := json.Marshal(respJSON)
  1312. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1313. utils.ErrorLog("解析失败:%v", err)
  1314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1315. return
  1316. }
  1317. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1318. res2.Output = resSix10265.Output
  1319. res2.ErrMsg = resSix10265.ErrMsg
  1320. res2.Cainfo = resSix10265.Cainfo
  1321. res2.WarnMsg = resSix10265.WarnMsg
  1322. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1323. res2.Infcode = infocode
  1324. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1325. data := make(map[string]interface{})
  1326. data["struct_3501s"] = struct3501
  1327. client := &http.Client{}
  1328. bytesData, _ := json.Marshal(data)
  1329. var req *http.Request
  1330. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1331. resp, _ := client.Do(req)
  1332. defer resp.Body.Close()
  1333. body, ioErr := ioutil.ReadAll(resp.Body)
  1334. if ioErr != nil {
  1335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1336. }
  1337. var respJSON map[string]interface{}
  1338. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. return
  1342. }
  1343. var resSix10265 ResultSix10265 //1101结果
  1344. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1345. result, _ := json.Marshal(respJSON)
  1346. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1347. utils.ErrorLog("解析失败:%v", err)
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1352. res2.Output = resSix10265.Output
  1353. res2.ErrMsg = resSix10265.ErrMsg
  1354. res2.Cainfo = resSix10265.Cainfo
  1355. res2.WarnMsg = resSix10265.WarnMsg
  1356. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1357. res2.Infcode = infocode
  1358. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1359. data := make(map[string]interface{})
  1360. data["struct_3501s"] = struct3501
  1361. client := &http.Client{}
  1362. bytesData, _ := json.Marshal(data)
  1363. var req *http.Request
  1364. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1365. resp, _ := client.Do(req)
  1366. defer resp.Body.Close()
  1367. body, ioErr := ioutil.ReadAll(resp.Body)
  1368. if ioErr != nil {
  1369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1370. }
  1371. var respJSON map[string]interface{}
  1372. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. return
  1376. }
  1377. var resSix10265 ResultSix10265 //1101结果
  1378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1379. result, _ := json.Marshal(respJSON)
  1380. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1381. utils.ErrorLog("解析失败:%v", err)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1383. return
  1384. }
  1385. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1386. res2.Output = resSix10265.Output
  1387. res2.ErrMsg = resSix10265.ErrMsg
  1388. res2.Cainfo = resSix10265.Cainfo
  1389. res2.WarnMsg = resSix10265.WarnMsg
  1390. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1391. res2.Infcode = infocode
  1392. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1393. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1394. saveLog(result1, result2, "3501", "3501")
  1395. //saveLog(result, requestLog, "2201", "挂号")
  1396. var respJSON2 map[string]interface{}
  1397. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1400. return
  1401. }
  1402. userJSONBytes2, _ := json.Marshal(respJSON2)
  1403. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1404. utils.ErrorLog("解析失败:%v", err)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. }
  1409. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1410. if res2.Infcode != -1 {
  1411. drug.IsPc = 1
  1412. drug.Bchno = number
  1413. drug.PcDate = time.Now().Unix()
  1414. service.SaveW(drug)
  1415. //if err == nil {
  1416. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1417. // var struct3502 models.Struct3502
  1418. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1419. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1420. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1421. // struct3502.FixmedinsCode = miConfig.Code
  1422. // struct3502.Code = miConfig.Code
  1423. //
  1424. // struct3502.RxFlag = "0"
  1425. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1426. // struct3502.OrgName = miConfig.OrgName
  1427. // struct3502.Opter = roles.UserName
  1428. // struct3502.AccessKey = miConfig.AccessKey
  1429. // struct3502.RequestUrl = miConfig.Url
  1430. // struct3502.SecretKey = miConfig.SecretKey
  1431. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1432. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1433. // struct3502.Url = miConfig.Url
  1434. // struct3502.AppId = miConfig.Cainfo
  1435. // struct3502.AppSecret = miConfig.AppSecret
  1436. // struct3502.Enckey = miConfig.EncKey
  1437. // struct3502.SignKey = miConfig.SignKey
  1438. // struct3502.SecretKey = miConfig.SecretKey
  1439. // struct3502.DrugTracCodg = drug.DrugCode
  1440. //
  1441. // struct3502.Memo = ""
  1442. // struct3502.InvChgType = "108"
  1443. // struct3502.FixmedinsBchno = bg_number
  1444. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1445. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1446. //
  1447. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1448. // result11, result22, _ := service.FJyb3502(struct3502)
  1449. // saveLog(result11, result22, "3502", "3502")
  1450. //
  1451. // var respJSON3 map[string]interface{}
  1452. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1453. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1455. // return
  1456. // }
  1457. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1458. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1459. // utils.ErrorLog("解析失败:%v", err)
  1460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1461. // return
  1462. // }
  1463. //
  1464. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1465. // data := make(map[string]interface{})
  1466. // data["struct_3502s"] = struct3502
  1467. // client := &http.Client{}
  1468. // bytesData, _ := json.Marshal(data)
  1469. // var req *http.Request
  1470. // if miConfig.MdtrtareaAdmvs == "320830" {
  1471. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1472. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1473. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1474. // } else {
  1475. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1476. // }
  1477. //
  1478. // resp, _ := client.Do(req)
  1479. // defer resp.Body.Close()
  1480. // body, ioErr := ioutil.ReadAll(resp.Body)
  1481. // if ioErr != nil {
  1482. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1483. // }
  1484. // var respJSON map[string]interface{}
  1485. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1486. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1488. // return
  1489. // }
  1490. // var resSix10265 ResultSix10265 //1101结果
  1491. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1492. // result, _ := json.Marshal(respJSON)
  1493. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1494. // utils.ErrorLog("解析失败:%v", err)
  1495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1496. // return
  1497. // }
  1498. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1499. // res3.Output = resSix10265.Output
  1500. // res3.ErrMsg = resSix10265.ErrMsg
  1501. // res3.Cainfo = resSix10265.Cainfo
  1502. // res3.WarnMsg = resSix10265.WarnMsg
  1503. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1504. // res3.Infcode = infocode
  1505. //
  1506. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1507. //
  1508. // data := make(map[string]interface{})
  1509. // data["struct_3502s"] = struct3502
  1510. // client := &http.Client{}
  1511. // bytesData, _ := json.Marshal(data)
  1512. // var req *http.Request
  1513. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1514. // resp, _ := client.Do(req)
  1515. // defer resp.Body.Close()
  1516. // body, ioErr := ioutil.ReadAll(resp.Body)
  1517. // if ioErr != nil {
  1518. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1519. // }
  1520. // var respJSON map[string]interface{}
  1521. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1522. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1524. // return
  1525. // }
  1526. // var resSix10265 ResultSix10265 //1101结果
  1527. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1528. // result, _ := json.Marshal(respJSON)
  1529. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1530. // utils.ErrorLog("解析失败:%v", err)
  1531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. // return
  1533. // }
  1534. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1535. // res3.Output = resSix10265.Output
  1536. // res3.ErrMsg = resSix10265.ErrMsg
  1537. // res3.Cainfo = resSix10265.Cainfo
  1538. // res3.WarnMsg = resSix10265.WarnMsg
  1539. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1540. // res3.Infcode = infocode
  1541. //
  1542. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1543. //
  1544. // data := make(map[string]interface{})
  1545. // data["struct_3501s"] = struct3501
  1546. // client := &http.Client{}
  1547. // bytesData, _ := json.Marshal(data)
  1548. // var req *http.Request
  1549. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1550. // resp, _ := client.Do(req)
  1551. // defer resp.Body.Close()
  1552. // body, ioErr := ioutil.ReadAll(resp.Body)
  1553. // if ioErr != nil {
  1554. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1555. // }
  1556. // var respJSON map[string]interface{}
  1557. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1558. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1560. // return
  1561. // }
  1562. // var resSix10265 ResultSix10265 //1101结果
  1563. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1564. // result, _ := json.Marshal(respJSON)
  1565. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1566. // utils.ErrorLog("解析失败:%v", err)
  1567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1568. // return
  1569. // }
  1570. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1571. // res2.Output = resSix10265.Output
  1572. // res2.ErrMsg = resSix10265.ErrMsg
  1573. // res2.Cainfo = resSix10265.Cainfo
  1574. // res2.WarnMsg = resSix10265.WarnMsg
  1575. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1576. // res2.Infcode = infocode
  1577. //
  1578. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1579. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1580. // saveLog(result11, result22, "3502", "3502")
  1581. //
  1582. // var respJSON3 map[string]interface{}
  1583. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1584. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. // return
  1587. // }
  1588. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1589. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1590. // utils.ErrorLog("解析失败:%v", err)
  1591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1592. // return
  1593. // }
  1594. // }
  1595. // if res3.Infcode == -1 {
  1596. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1597. // c.ServeSuccessJSON(map[string]interface{}{
  1598. // "failed_code": -10,
  1599. // "msg": res3.ErrMsg,
  1600. // })
  1601. // } else {
  1602. // drug.IsBg = 1
  1603. // drug.BgBchno = bg_number
  1604. // service.SaveW(drug)
  1605. // }
  1606. //}
  1607. //} else {
  1608. } else {
  1609. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1610. }
  1611. }
  1612. //变更
  1613. }
  1614. if len(errs) == 0 {
  1615. c.ServeSuccessJSON(map[string]interface{}{
  1616. "msg": "盘存变更成功",
  1617. })
  1618. } else {
  1619. c.ServeSuccessJSON(map[string]interface{}{
  1620. "failed_code": -10,
  1621. "msg": errs,
  1622. })
  1623. }
  1624. }
  1625. func (c *HisApiController) DeletePCandBG() {
  1626. ids := c.GetString("ids")
  1627. id_arr := strings.Split(ids, ",")
  1628. admin_user_id, _ := c.GetInt64("admin_user_id")
  1629. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1630. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1631. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1632. var err []string
  1633. for _, item := range drugs {
  1634. if item.IsPc == 1 {
  1635. var res FJ3507Result
  1636. var struct3507 models.Struct3507
  1637. struct3507.FixmedinsBchno = item.Bchno
  1638. struct3507.InvDataType = "1"
  1639. struct3507.Opter = roles.UserName
  1640. struct3507.OrgName = miConfig.OrgName
  1641. struct3507.AccessKey = miConfig.AccessKey
  1642. struct3507.RequestUrl = miConfig.Url
  1643. struct3507.FixmedinsCode = miConfig.Code
  1644. struct3507.Code = miConfig.Code
  1645. struct3507.SecretKey = miConfig.SecretKey
  1646. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1647. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1648. struct3507.Url = miConfig.Url
  1649. struct3507.AppId = miConfig.Cainfo
  1650. struct3507.AppSecret = miConfig.AppSecret
  1651. struct3507.Enckey = miConfig.EncKey
  1652. struct3507.SignKey = miConfig.SignKey
  1653. struct3507.SecretKey = miConfig.SecretKey
  1654. if miConfig.MdtrtareaAdmvs == "350500" {
  1655. result, result1, _ := service.FJyb3507(struct3507)
  1656. saveLog(result, result1, "3507", "3507")
  1657. var respJSON2 map[string]interface{}
  1658. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. return
  1662. }
  1663. userJSONBytes2, _ := json.Marshal(respJSON2)
  1664. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1665. utils.ErrorLog("解析失败:%v", err)
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1667. return
  1668. }
  1669. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1670. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1671. saveLog(result2, result1, "3507", "3507")
  1672. var respJSON2 map[string]interface{}
  1673. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. userJSONBytes2, _ := json.Marshal(respJSON2)
  1679. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1680. utils.ErrorLog("解析失败:%v", err)
  1681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1682. return
  1683. }
  1684. } else {
  1685. data := make(map[string]interface{})
  1686. data["struct_3507s"] = struct3507
  1687. client := &http.Client{}
  1688. bytesData, _ := json.Marshal(data)
  1689. var req *http.Request
  1690. if miConfig.MdtrtareaAdmvs == "320830" {
  1691. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1692. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1693. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1694. } else {
  1695. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1696. }
  1697. resp, _ := client.Do(req)
  1698. defer resp.Body.Close()
  1699. body, ioErr := ioutil.ReadAll(resp.Body)
  1700. if ioErr != nil {
  1701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1702. }
  1703. var respJSON map[string]interface{}
  1704. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1707. return
  1708. }
  1709. var resSix10265 ResultSix10265 //1101结果
  1710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1711. result, _ := json.Marshal(respJSON)
  1712. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1713. utils.ErrorLog("解析失败:%v", err)
  1714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1715. return
  1716. }
  1717. res.InfRefmsgid = resSix10265.InfRefmsgid
  1718. //res.Output = resSix10265.Output
  1719. res.ErrMsg = resSix10265.ErrMsg
  1720. res.Cainfo = resSix10265.Cainfo
  1721. res.WarnMsg = resSix10265.WarnMsg
  1722. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1723. res.Infcode = infocode
  1724. }
  1725. if res.Infcode == 0 {
  1726. item.IsPc = 0
  1727. service.SaveW(item)
  1728. } else {
  1729. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1730. }
  1731. }
  1732. }
  1733. if len(err) == 0 {
  1734. c.ServeSuccessJSON(map[string]interface{}{
  1735. "msg": "删除盘存变更成功",
  1736. })
  1737. } else {
  1738. c.ServeSuccessJSON(map[string]interface{}{
  1739. "failed_code": -10,
  1740. "msg": err,
  1741. })
  1742. }
  1743. }
  1744. func (c *HisApiController) DeleteXSandBG() {
  1745. ids := c.GetString("ids")
  1746. id_arr := strings.Split(ids, ",")
  1747. admin_user_id, _ := c.GetInt64("admin_user_id")
  1748. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1749. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1751. var err []string
  1752. for _, item := range flows {
  1753. if item.IsSale == 1 && item.IsChange == 1 {
  1754. var res FJ3507Result
  1755. var res2 FJ3507Result
  1756. var struct3507 models.Struct3507
  1757. struct3507.FixmedinsBchno = item.Bchno
  1758. struct3507.InvDataType = "4"
  1759. struct3507.Opter = roles.UserName
  1760. struct3507.OrgName = miConfig.OrgName
  1761. struct3507.AccessKey = miConfig.AccessKey
  1762. struct3507.RequestUrl = miConfig.Url
  1763. struct3507.FixmedinsCode = miConfig.Code
  1764. struct3507.SecretKey = miConfig.SecretKey
  1765. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1766. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1767. struct3507.Url = miConfig.Url
  1768. struct3507.AppId = miConfig.Cainfo
  1769. struct3507.AppSecret = miConfig.AppSecret
  1770. struct3507.Enckey = miConfig.EncKey
  1771. struct3507.SignKey = miConfig.SignKey
  1772. struct3507.SecretKey = miConfig.SecretKey
  1773. //result, result1, _ := service.FJyb3507(struct3507)
  1774. //saveLog(result, result1, "3507", "3507")
  1775. if miConfig.MdtrtareaAdmvs == "350500" {
  1776. result, result1, _ := service.FJyb3507(struct3507)
  1777. saveLog(result, result1, "3507", "3507")
  1778. var respJSON2 map[string]interface{}
  1779. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1782. return
  1783. }
  1784. userJSONBytes2, _ := json.Marshal(respJSON2)
  1785. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1786. utils.ErrorLog("解析失败:%v", err)
  1787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1788. return
  1789. }
  1790. } else {
  1791. data := make(map[string]interface{})
  1792. data["struct_3507s"] = struct3507
  1793. client := &http.Client{}
  1794. bytesData, _ := json.Marshal(data)
  1795. var req *http.Request
  1796. if miConfig.MdtrtareaAdmvs == "320830" {
  1797. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1798. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1800. } else {
  1801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1802. }
  1803. resp, _ := client.Do(req)
  1804. defer resp.Body.Close()
  1805. body, ioErr := ioutil.ReadAll(resp.Body)
  1806. if ioErr != nil {
  1807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1808. }
  1809. var respJSON map[string]interface{}
  1810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1813. return
  1814. }
  1815. var resSix10265 ResultSix10265 //1101结果
  1816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1817. result, _ := json.Marshal(respJSON)
  1818. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1819. utils.ErrorLog("解析失败:%v", err)
  1820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1821. return
  1822. }
  1823. res.InfRefmsgid = resSix10265.InfRefmsgid
  1824. //res.Output = resSix10265.Output
  1825. res.ErrMsg = resSix10265.ErrMsg
  1826. res.Cainfo = resSix10265.Cainfo
  1827. res.WarnMsg = resSix10265.WarnMsg
  1828. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1829. res.Infcode = infocode
  1830. }
  1831. if res.Infcode == 0 {
  1832. item.IsSale = 0
  1833. item.SaleDate = ""
  1834. item.Bchno = ""
  1835. err2 := service.SaveDF(item)
  1836. if err2 == nil {
  1837. var struct3507_2 models.Struct3507
  1838. struct3507_2.OrgName = miConfig.OrgName
  1839. struct3507_2.AccessKey = miConfig.AccessKey
  1840. struct3507_2.RequestUrl = miConfig.Url
  1841. struct3507_2.Opter = roles.UserName
  1842. struct3507_2.FixmedinsCode = miConfig.Code
  1843. struct3507_2.Code = miConfig.Code
  1844. struct3507_2.SecretKey = miConfig.SecretKey
  1845. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1846. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1847. struct3507_2.Url = miConfig.Url
  1848. struct3507_2.AppId = miConfig.Cainfo
  1849. struct3507_2.AppSecret = miConfig.AppSecret
  1850. struct3507_2.Enckey = miConfig.EncKey
  1851. struct3507_2.SignKey = miConfig.SignKey
  1852. struct3507_2.SecretKey = miConfig.SecretKey
  1853. struct3507_2.FixmedinsBchno = item.BgBchno
  1854. struct3507_2.InvDataType = "2"
  1855. if miConfig.MdtrtareaAdmvs == "350500" {
  1856. result11, result22, _ := service.FJyb3507(struct3507_2)
  1857. saveLog(result11, result22, "3507", "3507")
  1858. var respJSON3 map[string]interface{}
  1859. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1862. return
  1863. }
  1864. userJSONBytes3, _ := json.Marshal(respJSON3)
  1865. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1866. utils.ErrorLog("解析失败:%v", err)
  1867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1868. return
  1869. }
  1870. } else {
  1871. data := make(map[string]interface{})
  1872. data["struct_3507s"] = struct3507_2
  1873. client := &http.Client{}
  1874. bytesData, _ := json.Marshal(data)
  1875. var req *http.Request
  1876. if miConfig.MdtrtareaAdmvs == "320830" {
  1877. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1878. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1879. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1880. } else {
  1881. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1882. }
  1883. resp, _ := client.Do(req)
  1884. defer resp.Body.Close()
  1885. body, ioErr := ioutil.ReadAll(resp.Body)
  1886. if ioErr != nil {
  1887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1888. }
  1889. var respJSON map[string]interface{}
  1890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1893. return
  1894. }
  1895. var resSix10265 ResultSix10265 //1101结果
  1896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1897. result, _ := json.Marshal(respJSON)
  1898. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1899. utils.ErrorLog("解析失败:%v", err)
  1900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1901. return
  1902. }
  1903. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1904. //res.Output = resSix10265.Output
  1905. res2.ErrMsg = resSix10265.ErrMsg
  1906. res2.Cainfo = resSix10265.Cainfo
  1907. res2.WarnMsg = resSix10265.WarnMsg
  1908. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1909. res2.Infcode = infocode
  1910. }
  1911. if res2.Infcode == 0 {
  1912. item.IsChange = 0
  1913. item.BgBchno = ""
  1914. service.SaveDF2(item)
  1915. } else {
  1916. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1917. }
  1918. }
  1919. } else {
  1920. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1921. }
  1922. }
  1923. if item.IsSale == 2 && item.IsChange == 1 {
  1924. var res FJ3507Result
  1925. var res2 FJ3507Result
  1926. var struct3507 models.Struct3507
  1927. struct3507.FixmedinsBchno = item.Bchno
  1928. struct3507.InvDataType = "4"
  1929. struct3507.Opter = roles.UserName
  1930. struct3507.OrgName = miConfig.OrgName
  1931. struct3507.AccessKey = miConfig.AccessKey
  1932. struct3507.RequestUrl = miConfig.Url
  1933. struct3507.FixmedinsCode = miConfig.Code
  1934. struct3507.Code = miConfig.Code
  1935. struct3507.SecretKey = miConfig.SecretKey
  1936. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1937. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1938. struct3507.Url = miConfig.Url
  1939. struct3507.AppId = miConfig.Cainfo
  1940. struct3507.AppSecret = miConfig.AppSecret
  1941. struct3507.Enckey = miConfig.EncKey
  1942. struct3507.SignKey = miConfig.SignKey
  1943. struct3507.SecretKey = miConfig.SecretKey
  1944. //result, result1, _ := service.FJyb3507(struct3507)
  1945. //saveLog(result, result1, "3507", "3507")
  1946. //
  1947. //var respJSON2 map[string]interface{}
  1948. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1949. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1951. // return
  1952. //}
  1953. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1954. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1955. // utils.ErrorLog("解析失败:%v", err)
  1956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1957. // return
  1958. //}
  1959. if miConfig.MdtrtareaAdmvs == "350500" {
  1960. result, result1, _ := service.FJyb3507(struct3507)
  1961. saveLog(result, result1, "3507", "3507")
  1962. var respJSON2 map[string]interface{}
  1963. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1966. return
  1967. }
  1968. userJSONBytes2, _ := json.Marshal(respJSON2)
  1969. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1970. utils.ErrorLog("解析失败:%v", err)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. return
  1973. }
  1974. } else {
  1975. data := make(map[string]interface{})
  1976. data["struct_3507s"] = struct3507
  1977. client := &http.Client{}
  1978. bytesData, _ := json.Marshal(data)
  1979. var req *http.Request
  1980. if miConfig.MdtrtareaAdmvs == "320830" {
  1981. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1982. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1983. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1984. } else {
  1985. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1986. }
  1987. resp, _ := client.Do(req)
  1988. defer resp.Body.Close()
  1989. body, ioErr := ioutil.ReadAll(resp.Body)
  1990. if ioErr != nil {
  1991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1992. }
  1993. var respJSON map[string]interface{}
  1994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1997. return
  1998. }
  1999. var resSix10265 ResultSix10265 //1101结果
  2000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2001. result, _ := json.Marshal(respJSON)
  2002. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2003. utils.ErrorLog("解析失败:%v", err)
  2004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2005. return
  2006. }
  2007. res.InfRefmsgid = resSix10265.InfRefmsgid
  2008. //res.Output = resSix10265.Output
  2009. res.ErrMsg = resSix10265.ErrMsg
  2010. res.Cainfo = resSix10265.Cainfo
  2011. res.WarnMsg = resSix10265.WarnMsg
  2012. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2013. res.Infcode = infocode
  2014. }
  2015. if res.Infcode == 0 {
  2016. item.IsSale = 0
  2017. item.SaleDate = ""
  2018. item.Bchno = ""
  2019. err2 := service.SaveDF(item)
  2020. if err2 == nil {
  2021. var struct3507_2 models.Struct3507
  2022. struct3507_2.OrgName = miConfig.OrgName
  2023. struct3507_2.AccessKey = miConfig.AccessKey
  2024. struct3507_2.RequestUrl = miConfig.Url
  2025. struct3507_2.Opter = roles.UserName
  2026. struct3507_2.FixmedinsCode = miConfig.Code
  2027. struct3507_2.Code = miConfig.Code
  2028. struct3507_2.SecretKey = miConfig.SecretKey
  2029. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2030. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2031. struct3507_2.Url = miConfig.Url
  2032. struct3507_2.AppId = miConfig.Cainfo
  2033. struct3507_2.AppSecret = miConfig.AppSecret
  2034. struct3507_2.Enckey = miConfig.EncKey
  2035. struct3507_2.SignKey = miConfig.SignKey
  2036. struct3507_2.SecretKey = miConfig.SecretKey
  2037. struct3507_2.FixmedinsBchno = item.BgBchno
  2038. struct3507_2.InvDataType = "2"
  2039. //result11, result22, _ := service.FJyb3507(struct3507_2)
  2040. //saveLog(result11, result22, "3507", "3507")
  2041. //var respJSON3 map[string]interface{}
  2042. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2043. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2045. // return
  2046. //}
  2047. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2048. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2049. // utils.ErrorLog("解析失败:%v", err)
  2050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. // return
  2052. //}
  2053. if miConfig.MdtrtareaAdmvs == "350500" {
  2054. result11, result22, _ := service.FJyb3507(struct3507_2)
  2055. saveLog(result11, result22, "3507", "3507")
  2056. var respJSON3 map[string]interface{}
  2057. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2060. return
  2061. }
  2062. userJSONBytes3, _ := json.Marshal(respJSON3)
  2063. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2064. utils.ErrorLog("解析失败:%v", err)
  2065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. return
  2067. }
  2068. } else {
  2069. data := make(map[string]interface{})
  2070. data["struct_3507s"] = struct3507_2
  2071. client := &http.Client{}
  2072. bytesData, _ := json.Marshal(data)
  2073. var req *http.Request
  2074. if miConfig.MdtrtareaAdmvs == "320830" {
  2075. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2076. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2077. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2078. } else {
  2079. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2080. }
  2081. resp, _ := client.Do(req)
  2082. defer resp.Body.Close()
  2083. body, ioErr := ioutil.ReadAll(resp.Body)
  2084. if ioErr != nil {
  2085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2086. }
  2087. var respJSON map[string]interface{}
  2088. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2091. return
  2092. }
  2093. var resSix10265 ResultSix10265 //1101结果
  2094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2095. result, _ := json.Marshal(respJSON)
  2096. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2097. utils.ErrorLog("解析失败:%v", err)
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2099. return
  2100. }
  2101. res2.InfRefmsgid = resSix10265.InfRefmsgid
  2102. //res.Output = resSix10265.Output
  2103. res2.ErrMsg = resSix10265.ErrMsg
  2104. res2.Cainfo = resSix10265.Cainfo
  2105. res2.WarnMsg = resSix10265.WarnMsg
  2106. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2107. res2.Infcode = infocode
  2108. }
  2109. if res2.Infcode == 0 {
  2110. item.IsChange = 0
  2111. item.BgBchno = ""
  2112. service.SaveDF2(item)
  2113. } else {
  2114. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2115. }
  2116. }
  2117. } else {
  2118. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2119. }
  2120. }
  2121. if item.IsSale == 1 && item.IsChange == 0 {
  2122. var res FJ3507Result
  2123. var struct3507 models.Struct3507
  2124. struct3507.FixmedinsBchno = item.Bchno
  2125. struct3507.InvDataType = "4"
  2126. struct3507.Opter = roles.UserName
  2127. struct3507.FixmedinsCode = miConfig.Code
  2128. struct3507.Code = miConfig.Code
  2129. struct3507.OrgName = miConfig.OrgName
  2130. struct3507.AccessKey = miConfig.AccessKey
  2131. struct3507.RequestUrl = miConfig.Url
  2132. struct3507.SecretKey = miConfig.SecretKey
  2133. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2134. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2135. struct3507.Url = miConfig.Url
  2136. struct3507.AppId = miConfig.Cainfo
  2137. struct3507.AppSecret = miConfig.AppSecret
  2138. struct3507.Enckey = miConfig.EncKey
  2139. struct3507.SignKey = miConfig.SignKey
  2140. struct3507.SecretKey = miConfig.SecretKey
  2141. //result, result1, _ := service.FJyb3507(struct3507)
  2142. //saveLog(result, result1, "3507", "3507")
  2143. //
  2144. //var respJSON3 map[string]interface{}
  2145. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2146. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2148. // return
  2149. //}
  2150. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2151. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2152. // utils.ErrorLog("解析失败:%v", err)
  2153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2154. // return
  2155. //}
  2156. if miConfig.MdtrtareaAdmvs == "350500" {
  2157. result, result1, _ := service.FJyb3507(struct3507)
  2158. saveLog(result, result1, "3507", "3507")
  2159. var respJSON2 map[string]interface{}
  2160. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2163. return
  2164. }
  2165. userJSONBytes2, _ := json.Marshal(respJSON2)
  2166. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2167. utils.ErrorLog("解析失败:%v", err)
  2168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2169. return
  2170. }
  2171. } else {
  2172. data := make(map[string]interface{})
  2173. data["struct_3507s"] = struct3507
  2174. client := &http.Client{}
  2175. bytesData, _ := json.Marshal(data)
  2176. var req *http.Request
  2177. if miConfig.MdtrtareaAdmvs == "320830" {
  2178. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2179. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2180. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2181. } else {
  2182. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2183. }
  2184. resp, _ := client.Do(req)
  2185. defer resp.Body.Close()
  2186. body, ioErr := ioutil.ReadAll(resp.Body)
  2187. if ioErr != nil {
  2188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2189. }
  2190. var respJSON map[string]interface{}
  2191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. return
  2195. }
  2196. var resSix10265 ResultSix10265 //1101结果
  2197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2198. result, _ := json.Marshal(respJSON)
  2199. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2200. utils.ErrorLog("解析失败:%v", err)
  2201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2202. return
  2203. }
  2204. res.InfRefmsgid = resSix10265.InfRefmsgid
  2205. //res.Output = resSix10265.Output
  2206. res.ErrMsg = resSix10265.ErrMsg
  2207. res.Cainfo = resSix10265.Cainfo
  2208. res.WarnMsg = resSix10265.WarnMsg
  2209. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2210. res.Infcode = infocode
  2211. }
  2212. if res.Infcode == 0 {
  2213. item.IsSale = 0
  2214. item.SaleDate = ""
  2215. service.SaveDF(item)
  2216. } else {
  2217. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2218. }
  2219. }
  2220. if item.IsSale == 2 && item.IsChange == 0 {
  2221. var res FJ3507Result
  2222. var struct3507 models.Struct3507
  2223. struct3507.FixmedinsBchno = item.Bchno
  2224. struct3507.InvDataType = "4"
  2225. struct3507.Opter = roles.UserName
  2226. struct3507.FixmedinsCode = miConfig.Code
  2227. struct3507.Code = miConfig.Code
  2228. struct3507.OrgName = miConfig.OrgName
  2229. struct3507.AccessKey = miConfig.AccessKey
  2230. struct3507.RequestUrl = miConfig.Url
  2231. struct3507.SecretKey = miConfig.SecretKey
  2232. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2233. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2234. struct3507.Url = miConfig.Url
  2235. struct3507.AppId = miConfig.Cainfo
  2236. struct3507.AppSecret = miConfig.AppSecret
  2237. struct3507.Enckey = miConfig.EncKey
  2238. struct3507.SignKey = miConfig.SignKey
  2239. struct3507.SecretKey = miConfig.SecretKey
  2240. //result, result1, _ := service.FJyb3507(struct3507)
  2241. //saveLog(result, result1, "3507", "3507")
  2242. //
  2243. //var respJSON3 map[string]interface{}
  2244. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2245. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2247. // return
  2248. //}
  2249. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2250. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2251. // utils.ErrorLog("解析失败:%v", err)
  2252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2253. // return
  2254. //}
  2255. if miConfig.MdtrtareaAdmvs == "350500" {
  2256. result, result1, _ := service.FJyb3507(struct3507)
  2257. saveLog(result, result1, "3507", "3507")
  2258. var respJSON2 map[string]interface{}
  2259. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2262. return
  2263. }
  2264. userJSONBytes2, _ := json.Marshal(respJSON2)
  2265. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2266. utils.ErrorLog("解析失败:%v", err)
  2267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2268. return
  2269. }
  2270. } else {
  2271. data := make(map[string]interface{})
  2272. data["struct_3507s"] = struct3507
  2273. client := &http.Client{}
  2274. bytesData, _ := json.Marshal(data)
  2275. var req *http.Request
  2276. if miConfig.MdtrtareaAdmvs == "320830" {
  2277. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2278. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2279. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2280. } else {
  2281. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2282. }
  2283. resp, _ := client.Do(req)
  2284. defer resp.Body.Close()
  2285. body, ioErr := ioutil.ReadAll(resp.Body)
  2286. if ioErr != nil {
  2287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2288. }
  2289. var respJSON map[string]interface{}
  2290. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2293. return
  2294. }
  2295. var resSix10265 ResultSix10265 //1101结果
  2296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2297. result, _ := json.Marshal(respJSON)
  2298. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2299. utils.ErrorLog("解析失败:%v", err)
  2300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2301. return
  2302. }
  2303. res.InfRefmsgid = resSix10265.InfRefmsgid
  2304. //res.Output = resSix10265.Output
  2305. res.ErrMsg = resSix10265.ErrMsg
  2306. res.Cainfo = resSix10265.Cainfo
  2307. res.WarnMsg = resSix10265.WarnMsg
  2308. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2309. res.Infcode = infocode
  2310. }
  2311. if res.Infcode == 0 {
  2312. item.IsSale = 0
  2313. item.SaleDate = ""
  2314. item.Bchno = ""
  2315. service.SaveDF(item)
  2316. } else {
  2317. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2318. }
  2319. }
  2320. if item.IsSale == 0 && item.IsChange == 1 {
  2321. var res FJ3507Result
  2322. var struct3507 models.Struct3507
  2323. struct3507.FixmedinsBchno = item.BgBchno
  2324. struct3507.InvDataType = "2"
  2325. struct3507.Opter = roles.UserName
  2326. struct3507.FixmedinsCode = miConfig.Code
  2327. struct3507.Code = miConfig.Code
  2328. struct3507.OrgName = miConfig.OrgName
  2329. struct3507.AccessKey = miConfig.AccessKey
  2330. struct3507.RequestUrl = miConfig.Url
  2331. struct3507.SecretKey = miConfig.SecretKey
  2332. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2333. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2334. struct3507.Url = miConfig.Url
  2335. struct3507.AppId = miConfig.Cainfo
  2336. struct3507.AppSecret = miConfig.AppSecret
  2337. struct3507.Enckey = miConfig.EncKey
  2338. struct3507.SignKey = miConfig.SignKey
  2339. struct3507.SecretKey = miConfig.SecretKey
  2340. //result, result1, _ := service.FJyb3507(struct3507)
  2341. //saveLog(result, result1, "3507", "3507")
  2342. //
  2343. //var respJSON3 map[string]interface{}
  2344. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2345. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2347. // return
  2348. //}
  2349. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2350. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2351. // utils.ErrorLog("解析失败:%v", err)
  2352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. // return
  2354. //}
  2355. if miConfig.MdtrtareaAdmvs == "350500" {
  2356. result, result1, _ := service.FJyb3507(struct3507)
  2357. saveLog(result, result1, "3507", "3507")
  2358. var respJSON2 map[string]interface{}
  2359. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. return
  2363. }
  2364. userJSONBytes2, _ := json.Marshal(respJSON2)
  2365. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2366. utils.ErrorLog("解析失败:%v", err)
  2367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2368. return
  2369. }
  2370. } else {
  2371. data := make(map[string]interface{})
  2372. data["struct_3507s"] = struct3507
  2373. client := &http.Client{}
  2374. bytesData, _ := json.Marshal(data)
  2375. var req *http.Request
  2376. if miConfig.MdtrtareaAdmvs == "320830" {
  2377. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2378. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2379. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2380. } else {
  2381. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2382. }
  2383. resp, _ := client.Do(req)
  2384. defer resp.Body.Close()
  2385. body, ioErr := ioutil.ReadAll(resp.Body)
  2386. if ioErr != nil {
  2387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2388. }
  2389. var respJSON map[string]interface{}
  2390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2393. return
  2394. }
  2395. var resSix10265 ResultSix10265 //1101结果
  2396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2397. result, _ := json.Marshal(respJSON)
  2398. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2399. utils.ErrorLog("解析失败:%v", err)
  2400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2401. return
  2402. }
  2403. res.InfRefmsgid = resSix10265.InfRefmsgid
  2404. //res.Output = resSix10265.Output
  2405. res.ErrMsg = resSix10265.ErrMsg
  2406. res.Cainfo = resSix10265.Cainfo
  2407. res.WarnMsg = resSix10265.WarnMsg
  2408. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2409. res.Infcode = infocode
  2410. }
  2411. if res.Infcode == 0 {
  2412. item.IsChange = 0
  2413. item.BgBchno = ""
  2414. service.SaveDF2(item)
  2415. } else {
  2416. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2417. }
  2418. }
  2419. }
  2420. if len(err) == 0 {
  2421. c.ServeSuccessJSON(map[string]interface{}{
  2422. "msg": "删除销售变更成功",
  2423. })
  2424. } else {
  2425. c.ServeSuccessJSON(map[string]interface{}{
  2426. "failed_code": -10,
  2427. "msg": err,
  2428. })
  2429. }
  2430. }
  2431. //func (c *HisApiController) BatchFJ3501AND3502() {
  2432. // //ids := c.GetString("ids")
  2433. // start_time := c.GetString("start_time")
  2434. // end_time := c.GetString("end_time")
  2435. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2436. //
  2437. //
  2438. // timeLayout := "2006-01-02"
  2439. // loc, _ := time.LoadLocation("Local")
  2440. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2441. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2442. //
  2443. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2444. // //id_arr := strings.Split(ids, ",")
  2445. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2446. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2447. // //库盘
  2448. // var errs []string
  2449. // for _, drug := range drugs {
  2450. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2451. // var res2 ResultSix
  2452. // var res3 ResultSix
  2453. //
  2454. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2455. // var struct3501 models.Struct3501
  2456. // struct3501.Code = miConfig.Code
  2457. // struct3501.OrgName = miConfig.OrgName
  2458. // struct3501.AccessKey = miConfig.AccessKey
  2459. // struct3501.Opter = roles.UserName
  2460. // struct3501.RequestUrl = miConfig.Url
  2461. // struct3501.Url = miConfig.Url
  2462. // struct3501.AppId = miConfig.Cainfo
  2463. // struct3501.AppSecret = miConfig.AppSecret
  2464. // struct3501.Enckey = miConfig.EncKey
  2465. // struct3501.SignKey = miConfig.SignKey
  2466. // struct3501.SecretKey = miConfig.SecretKey
  2467. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2468. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2469. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2470. // struct3501.RxFlag = "1"
  2471. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2472. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2473. //
  2474. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2475. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2476. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2477. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2478. // struct3501.FixmedinsBchno = number
  2479. // struct3501.DrugTracCodg = drug.DrugCode
  2480. // memo := make(map[string]interface{})
  2481. // memo["pric"] = drug.Price
  2482. // bytesData, _ := json.Marshal(memo)
  2483. // struct3501.Memo = string(bytesData)
  2484. //
  2485. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2486. //
  2487. // result1, result2, _ := service.FJyb3501(struct3501)
  2488. // saveLog(result1, result2, "3501", "3501")
  2489. // //saveLog(result, requestLog, "2201", "挂号")
  2490. //
  2491. // var respJSON2 map[string]interface{}
  2492. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2493. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2495. // return
  2496. // }
  2497. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2498. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2499. // utils.ErrorLog("解析失败:%v", err)
  2500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2501. // return
  2502. // }
  2503. //
  2504. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2505. // data := make(map[string]interface{})
  2506. // data["struct_3501s"] = struct3501
  2507. // client := &http.Client{}
  2508. // bytesData, _ := json.Marshal(data)
  2509. // var req *http.Request
  2510. // if miConfig.MdtrtareaAdmvs == "320921" {
  2511. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2512. // } else {
  2513. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2514. // }
  2515. //
  2516. // resp, _ := client.Do(req)
  2517. // defer resp.Body.Close()
  2518. // body, ioErr := ioutil.ReadAll(resp.Body)
  2519. // if ioErr != nil {
  2520. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2521. // }
  2522. // var respJSON map[string]interface{}
  2523. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2524. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2526. // return
  2527. // }
  2528. // var resSix10265 ResultSix10265 //1101结果
  2529. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2530. // result, _ := json.Marshal(respJSON)
  2531. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2532. // utils.ErrorLog("解析失败:%v", err)
  2533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2534. // return
  2535. // }
  2536. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2537. // res2.Output = resSix10265.Output
  2538. // res2.ErrMsg = resSix10265.ErrMsg
  2539. // res2.Cainfo = resSix10265.Cainfo
  2540. // res2.WarnMsg = resSix10265.WarnMsg
  2541. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2542. // res2.Infcode = infocode
  2543. //
  2544. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2545. // data := make(map[string]interface{})
  2546. // data["struct_3501s"] = struct3501
  2547. // client := &http.Client{}
  2548. // bytesData, _ := json.Marshal(data)
  2549. // var req *http.Request
  2550. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2551. // resp, _ := client.Do(req)
  2552. // defer resp.Body.Close()
  2553. // body, ioErr := ioutil.ReadAll(resp.Body)
  2554. // if ioErr != nil {
  2555. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2556. // }
  2557. // var respJSON map[string]interface{}
  2558. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2559. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2561. // return
  2562. // }
  2563. // var resSix10265 ResultSix10265 //1101结果
  2564. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2565. // result, _ := json.Marshal(respJSON)
  2566. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2567. // utils.ErrorLog("解析失败:%v", err)
  2568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2569. // return
  2570. // }
  2571. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2572. // res2.Output = resSix10265.Output
  2573. // res2.ErrMsg = resSix10265.ErrMsg
  2574. // res2.Cainfo = resSix10265.Cainfo
  2575. // res2.WarnMsg = resSix10265.WarnMsg
  2576. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2577. // res2.Infcode = infocode
  2578. //
  2579. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2580. // data := make(map[string]interface{})
  2581. // data["struct_3501s"] = struct3501
  2582. // client := &http.Client{}
  2583. // bytesData, _ := json.Marshal(data)
  2584. // var req *http.Request
  2585. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2586. // resp, _ := client.Do(req)
  2587. // defer resp.Body.Close()
  2588. // body, ioErr := ioutil.ReadAll(resp.Body)
  2589. // if ioErr != nil {
  2590. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2591. // }
  2592. // var respJSON map[string]interface{}
  2593. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2594. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2596. // return
  2597. // }
  2598. // var resSix10265 ResultSix10265 //1101结果
  2599. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2600. // result, _ := json.Marshal(respJSON)
  2601. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2602. // utils.ErrorLog("解析失败:%v", err)
  2603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2604. // return
  2605. // }
  2606. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2607. // res2.Output = resSix10265.Output
  2608. // res2.ErrMsg = resSix10265.ErrMsg
  2609. // res2.Cainfo = resSix10265.Cainfo
  2610. // res2.WarnMsg = resSix10265.WarnMsg
  2611. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2612. // res2.Infcode = infocode
  2613. //
  2614. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2615. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2616. // saveLog(result1, result2, "3501", "3501")
  2617. // //saveLog(result, requestLog, "2201", "挂号")
  2618. //
  2619. // var respJSON2 map[string]interface{}
  2620. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2621. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2623. // return
  2624. // }
  2625. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2626. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2627. // utils.ErrorLog("解析失败:%v", err)
  2628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2629. // return
  2630. // }
  2631. //
  2632. // }
  2633. //
  2634. // if res2.Infcode != -1 {
  2635. // drug.IsPc = 1
  2636. // drug.Bchno = number
  2637. // drug.PcDate = time.Now().Unix()
  2638. // err := service.SaveW(drug)
  2639. // if err == nil {
  2640. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2641. // var struct3502 models.Struct3502
  2642. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2643. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2644. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2645. // struct3502.FixmedinsCode = miConfig.Code
  2646. // struct3502.Code = miConfig.Code
  2647. //
  2648. // struct3502.RxFlag = "0"
  2649. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2650. // struct3502.OrgName = miConfig.OrgName
  2651. // struct3502.Opter = roles.UserName
  2652. // struct3502.AccessKey = miConfig.AccessKey
  2653. // struct3502.RequestUrl = miConfig.Url
  2654. // struct3502.SecretKey = miConfig.SecretKey
  2655. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2656. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2657. // struct3502.Url = miConfig.Url
  2658. // struct3502.AppId = miConfig.Cainfo
  2659. // struct3502.AppSecret = miConfig.AppSecret
  2660. // struct3502.Enckey = miConfig.EncKey
  2661. // struct3502.SignKey = miConfig.SignKey
  2662. // struct3502.SecretKey = miConfig.SecretKey
  2663. // struct3502.DrugTracCodg = drug.DrugCode
  2664. //
  2665. // struct3502.Memo = ""
  2666. // struct3502.InvChgType = "108"
  2667. // struct3502.FixmedinsBchno = bg_number
  2668. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2669. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2670. //
  2671. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2672. // result11, result22, _ := service.FJyb3502(struct3502)
  2673. // saveLog(result11, result22, "3502", "3502")
  2674. //
  2675. // var respJSON3 map[string]interface{}
  2676. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2677. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. // return
  2680. // }
  2681. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2682. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2683. // utils.ErrorLog("解析失败:%v", err)
  2684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2685. // return
  2686. // }
  2687. //
  2688. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2689. // data := make(map[string]interface{})
  2690. // data["struct_3502s"] = struct3502
  2691. // client := &http.Client{}
  2692. // bytesData, _ := json.Marshal(data)
  2693. // var req *http.Request
  2694. // if miConfig.MdtrtareaAdmvs == "320921" {
  2695. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2696. // } else {
  2697. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2698. // }
  2699. //
  2700. // resp, _ := client.Do(req)
  2701. // defer resp.Body.Close()
  2702. // body, ioErr := ioutil.ReadAll(resp.Body)
  2703. // if ioErr != nil {
  2704. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2705. // }
  2706. // var respJSON map[string]interface{}
  2707. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2708. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2710. // return
  2711. // }
  2712. // var resSix10265 ResultSix10265 //1101结果
  2713. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2714. // result, _ := json.Marshal(respJSON)
  2715. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2716. // utils.ErrorLog("解析失败:%v", err)
  2717. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2718. // return
  2719. // }
  2720. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2721. // res3.Output = resSix10265.Output
  2722. // res3.ErrMsg = resSix10265.ErrMsg
  2723. // res3.Cainfo = resSix10265.Cainfo
  2724. // res3.WarnMsg = resSix10265.WarnMsg
  2725. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2726. // res3.Infcode = infocode
  2727. //
  2728. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2729. //
  2730. // data := make(map[string]interface{})
  2731. // data["struct_3502s"] = struct3502
  2732. // client := &http.Client{}
  2733. // bytesData, _ := json.Marshal(data)
  2734. // var req *http.Request
  2735. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2736. // resp, _ := client.Do(req)
  2737. // defer resp.Body.Close()
  2738. // body, ioErr := ioutil.ReadAll(resp.Body)
  2739. // if ioErr != nil {
  2740. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2741. // }
  2742. // var respJSON map[string]interface{}
  2743. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2744. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2746. // return
  2747. // }
  2748. // var resSix10265 ResultSix10265 //1101结果
  2749. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2750. // result, _ := json.Marshal(respJSON)
  2751. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2752. // utils.ErrorLog("解析失败:%v", err)
  2753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2754. // return
  2755. // }
  2756. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2757. // res3.Output = resSix10265.Output
  2758. // res3.ErrMsg = resSix10265.ErrMsg
  2759. // res3.Cainfo = resSix10265.Cainfo
  2760. // res3.WarnMsg = resSix10265.WarnMsg
  2761. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2762. // res3.Infcode = infocode
  2763. //
  2764. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2765. //
  2766. // data := make(map[string]interface{})
  2767. // data["struct_3501s"] = struct3501
  2768. // client := &http.Client{}
  2769. // bytesData, _ := json.Marshal(data)
  2770. // var req *http.Request
  2771. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2772. // resp, _ := client.Do(req)
  2773. // defer resp.Body.Close()
  2774. // body, ioErr := ioutil.ReadAll(resp.Body)
  2775. // if ioErr != nil {
  2776. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2777. // }
  2778. // var respJSON map[string]interface{}
  2779. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2780. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2782. // return
  2783. // }
  2784. // var resSix10265 ResultSix10265 //1101结果
  2785. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2786. // result, _ := json.Marshal(respJSON)
  2787. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2788. // utils.ErrorLog("解析失败:%v", err)
  2789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2790. // return
  2791. // }
  2792. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2793. // res2.Output = resSix10265.Output
  2794. // res2.ErrMsg = resSix10265.ErrMsg
  2795. // res2.Cainfo = resSix10265.Cainfo
  2796. // res2.WarnMsg = resSix10265.WarnMsg
  2797. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2798. // res2.Infcode = infocode
  2799. //
  2800. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2801. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2802. // saveLog(result11, result22, "3502", "3502")
  2803. //
  2804. // var respJSON3 map[string]interface{}
  2805. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2806. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2808. // return
  2809. // }
  2810. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2811. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2812. // utils.ErrorLog("解析失败:%v", err)
  2813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2814. // return
  2815. // }
  2816. // }
  2817. // if res3.Infcode == -1 {
  2818. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2819. // c.ServeSuccessJSON(map[string]interface{}{
  2820. // "failed_code": -10,
  2821. // "msg": res3.ErrMsg,
  2822. // })
  2823. // } else {
  2824. // drug.IsBg = 1
  2825. // drug.BgBchno = bg_number
  2826. // service.SaveW(drug)
  2827. // }
  2828. // }
  2829. // } else {
  2830. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2831. // }
  2832. // }
  2833. // //变更
  2834. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2835. // var res3 ResultSix
  2836. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2837. //
  2838. // var struct3502 models.Struct3502
  2839. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2840. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2841. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2842. // struct3502.FixmedinsCode = miConfig.Code
  2843. // struct3502.Code = miConfig.Code
  2844. //
  2845. // struct3502.Opter = roles.UserName
  2846. // struct3502.RxFlag = "0"
  2847. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2848. // struct3502.OrgName = miConfig.OrgName
  2849. // struct3502.AccessKey = miConfig.AccessKey
  2850. // struct3502.RequestUrl = miConfig.Url
  2851. // struct3502.SecretKey = miConfig.SecretKey
  2852. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2853. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2854. // struct3502.InvChgType = "108"
  2855. // struct3502.DrugTracCodg = drug.DrugCode
  2856. //
  2857. // struct3502.Url = miConfig.Url
  2858. // struct3502.AppId = miConfig.Cainfo
  2859. // struct3502.AppSecret = miConfig.AppSecret
  2860. // struct3502.Enckey = miConfig.EncKey
  2861. // struct3502.SignKey = miConfig.SignKey
  2862. // struct3502.SecretKey = miConfig.SecretKey
  2863. //
  2864. // struct3502.FixmedinsBchno = bg_number
  2865. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2866. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2867. //
  2868. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2869. // result1, result2, _ := service.FJyb3502(struct3502)
  2870. // saveLog(result1, result2, "3502", "3502")
  2871. // var respJSON3 map[string]interface{}
  2872. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2873. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. // return
  2876. // }
  2877. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2878. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2879. // utils.ErrorLog("解析失败:%v", err)
  2880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2881. // return
  2882. // }
  2883. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2884. // data := make(map[string]interface{})
  2885. // data["struct_3502s"] = struct3502
  2886. // client := &http.Client{}
  2887. // bytesData, _ := json.Marshal(data)
  2888. // var req *http.Request
  2889. // if miConfig.MdtrtareaAdmvs == "320921" {
  2890. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2891. // } else {
  2892. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2893. // }
  2894. // resp, _ := client.Do(req)
  2895. // defer resp.Body.Close()
  2896. // body, ioErr := ioutil.ReadAll(resp.Body)
  2897. // if ioErr != nil {
  2898. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2899. // }
  2900. // var respJSON map[string]interface{}
  2901. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2902. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2904. // return
  2905. // }
  2906. // var resSix10265 ResultSix10265 //1101结果
  2907. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2908. // result, _ := json.Marshal(respJSON)
  2909. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2910. // utils.ErrorLog("解析失败:%v", err)
  2911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2912. // return
  2913. // }
  2914. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2915. // res3.Output = resSix10265.Output
  2916. // res3.ErrMsg = resSix10265.ErrMsg
  2917. // res3.Cainfo = resSix10265.Cainfo
  2918. // res3.WarnMsg = resSix10265.WarnMsg
  2919. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2920. // res3.Infcode = infocode
  2921. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2922. //
  2923. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2924. //
  2925. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2926. //
  2927. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2928. //
  2929. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2930. // saveLog(result1, result2, "3501", "3501")
  2931. // //saveLog(result, requestLog, "2201", "挂号")
  2932. //
  2933. // var respJSON2 map[string]interface{}
  2934. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2937. // return
  2938. // }
  2939. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2940. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2941. // utils.ErrorLog("解析失败:%v", err)
  2942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2943. // return
  2944. // }
  2945. //
  2946. // }
  2947. // if res3.Infcode == -1 {
  2948. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2949. // } else {
  2950. // drug.IsBg = 1
  2951. // drug.BgBchno = bg_number
  2952. // service.SaveW(drug)
  2953. // }
  2954. // }
  2955. // }
  2956. //
  2957. // if len(errs) == 0 {
  2958. // c.ServeSuccessJSON(map[string]interface{}{
  2959. // "msg": "盘存变更成功",
  2960. // })
  2961. // } else {
  2962. // c.ServeSuccessJSON(map[string]interface{}{
  2963. // "failed_code": -10,
  2964. // "msg": errs,
  2965. // })
  2966. // }
  2967. //}
  2968. func (c *HisApiController) DeleteXSandBGTwo() {
  2969. id, _ := c.GetInt64("id")
  2970. admin_user_id, _ := c.GetInt64("admin_user_id")
  2971. var errs []string
  2972. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2973. //for _, item := range advicelist {
  2974. // flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2975. // flows = append(flows, flow...)
  2976. //}
  2977. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2978. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2979. for _, item := range advicelist {
  2980. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  2981. if prescription.OrderStatus != 2 {
  2982. // 将时间戳转换为time.Time类型
  2983. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  2984. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  2985. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+"医嘱没结算无法撤销上传")
  2986. }
  2987. if len(item.DrugCode) > 0 {
  2988. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  2989. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  2990. codes := strings.Split(item.DrugCode, ",")
  2991. for _, code := range codes {
  2992. if len(code) > 0 {
  2993. if len(code) != 20 {
  2994. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"位数不是20位")
  2995. }
  2996. if IsDigit(code) == false {
  2997. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"不是纯数字")
  2998. }
  2999. }
  3000. }
  3001. }
  3002. }
  3003. if len(errs) > 0 {
  3004. c.ServeSuccessJSON(map[string]interface{}{
  3005. "failed_code": -10,
  3006. "msg": errs,
  3007. })
  3008. return
  3009. }
  3010. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3011. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3013. for _, item := range advicelist {
  3014. flow, _ := service.GetNewDrugFlowInfoByPatient(item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3015. //Drug ,_ := service.GetDrugLibById( drug.DrugId)
  3016. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3017. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, flow, miConfig, roles, strconv.Itoa(int(item.ID)), item)
  3018. result111, result222 = CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, flow, miConfig, roles, flow.Bchno, item)
  3019. saveLog(result111, result222, "3506", "销售退货")
  3020. var res FJ3507Result
  3021. var res3507for10188 FJ3507ResultFor10188
  3022. //进行商品销售接口
  3023. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3024. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3025. var respJSON3 map[string]interface{}
  3026. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3029. return
  3030. }
  3031. userJSONBytes3, _ := json.Marshal(respJSON3)
  3032. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3033. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3034. utils.ErrorLog("解析失败:%v", err)
  3035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3036. return
  3037. }
  3038. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3039. res.ErrMsg = res3507for10188.ErrMsg
  3040. res.Cainfo = res3507for10188.Cainfo
  3041. res.WarnMsg = res3507for10188.WarnMsg
  3042. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3043. res.Infcode = infocode
  3044. } else {
  3045. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3046. utils.ErrorLog("解析失败:%v", err)
  3047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3048. return
  3049. }
  3050. }
  3051. if res.Infcode == 0 {
  3052. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3053. } else {
  3054. errs = append(errs, item.AdviceName+",销售退货失败:"+res.ErrMsg)
  3055. }
  3056. }
  3057. c.ServeSuccessJSON(map[string]interface{}{
  3058. "msg": "销售退货成功",
  3059. })
  3060. }
  3061. // 删除
  3062. //func (c *HisApiController) DeleteXSandBGThree() {
  3063. // id, _ := c.GetInt64("id")
  3064. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3065. //
  3066. // advicelist, _ := service.FinddelHisAdviceDocAdvice(id)
  3067. // //var flows []*models.DrugFlow
  3068. // //for _, item := range advicelist {
  3069. // // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3070. // // flows = append(flows, flow...)
  3071. // //}
  3072. //
  3073. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3074. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3075. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3076. //
  3077. // var err []string
  3078. // for _, item := range advicelist {
  3079. //
  3080. // var res FJ3507Result
  3081. //
  3082. // var struct3507 models.Struct3507
  3083. // struct3507.FixmedinsBchno = item.ID
  3084. // struct3507.InvDataType = "4"
  3085. // struct3507.Opter = roles.UserName
  3086. // struct3507.OrgName = miConfig.OrgName
  3087. // struct3507.AccessKey = miConfig.AccessKey
  3088. // struct3507.RequestUrl = miConfig.Url
  3089. // struct3507.FixmedinsCode = miConfig.Code
  3090. // struct3507.SecretKey = miConfig.SecretKey
  3091. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3092. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3093. // struct3507.Url = miConfig.Url
  3094. // struct3507.AppId = miConfig.Cainfo
  3095. // struct3507.AppSecret = miConfig.AppSecret
  3096. // struct3507.Enckey = miConfig.EncKey
  3097. // struct3507.SignKey = miConfig.SignKey
  3098. // struct3507.SecretKey = miConfig.SecretKey
  3099. //
  3100. // if miConfig.MdtrtareaAdmvs == "350500" {
  3101. // result, result1, _ := service.FJyb3507(struct3507)
  3102. // saveLog(result, result1, "3507", "3507")
  3103. // var respJSON2 map[string]interface{}
  3104. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3105. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3107. // return
  3108. // }
  3109. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3110. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3111. // utils.ErrorLog("解析失败:%v", err)
  3112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3113. // return
  3114. // }
  3115. // } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3116. // data := make(map[string]interface{})
  3117. // data["struct_3507s"] = struct3507
  3118. // client := &http.Client{}
  3119. // bytesData, _ := json.Marshal(data)
  3120. // var req *http.Request
  3121. // if miConfig.MdtrtareaAdmvs == "320830" {
  3122. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3123. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  3124. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3125. // } else {
  3126. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3127. // }
  3128. //
  3129. // resp, _ := client.Do(req)
  3130. // defer resp.Body.Close()
  3131. // body, ioErr := ioutil.ReadAll(resp.Body)
  3132. // if ioErr != nil {
  3133. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3134. // }
  3135. // var respJSON map[string]interface{}
  3136. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3137. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3139. // return
  3140. // }
  3141. // var resSix10265 ResultSix10265 //1101结果
  3142. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3143. // result, _ := json.Marshal(respJSON)
  3144. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3145. // utils.ErrorLog("解析失败:%v", err)
  3146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3147. // return
  3148. // }
  3149. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3150. // //res.Output = resSix10265.Output
  3151. // res.ErrMsg = resSix10265.ErrMsg
  3152. // res.Cainfo = resSix10265.Cainfo
  3153. // res.WarnMsg = resSix10265.WarnMsg
  3154. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3155. // res.Infcode = infocode
  3156. // } else if miConfig.MdtrtareaAdmvs == "440100" {
  3157. // result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3158. // saveLog(result2, result1, "3507", "3507")
  3159. // var respJSON2 map[string]interface{}
  3160. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3161. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3162. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3163. // return
  3164. // }
  3165. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3166. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3167. // utils.ErrorLog("解析失败:%v", err)
  3168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3169. // return
  3170. // }
  3171. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3172. // result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3173. // saveLog(result2, result1, "3507", "3507")
  3174. // var respJSON2 map[string]interface{}
  3175. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3176. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3177. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3178. // return
  3179. // }
  3180. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3181. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3182. // utils.ErrorLog("解析失败:%v", err)
  3183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3184. // return
  3185. // }
  3186. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3187. // result1, result2 := service.Jxyb3507(struct3507)
  3188. // saveLog(result2, result1, "3507", "3507")
  3189. // var respJSON2 map[string]interface{}
  3190. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3191. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3193. // return
  3194. // }
  3195. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3196. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3197. // utils.ErrorLog("解析失败:%v", err)
  3198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3199. // return
  3200. // }
  3201. // } else if miConfig.MdtrtareaAdmvs == "340699" {
  3202. // result1, result2 := service.AHyb3507(struct3507)
  3203. // saveLog(result2, result1, "3507", "3507")
  3204. // var respJSON2 map[string]interface{}
  3205. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3206. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3208. // return
  3209. // }
  3210. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3211. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3212. // utils.ErrorLog("解析失败:%v", err)
  3213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3214. // return
  3215. // }
  3216. // } else if miConfig.MdtrtareaAdmvs == "150404" {
  3217. //
  3218. // data := make(map[string]interface{})
  3219. // data["struct_3507s"] = struct3507
  3220. // client := &http.Client{}
  3221. // bytesData, _ := json.Marshal(data)
  3222. // var req *http.Request
  3223. //
  3224. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3225. //
  3226. // resp, _ := client.Do(req)
  3227. // defer resp.Body.Close()
  3228. // body, ioErr := ioutil.ReadAll(resp.Body)
  3229. // if ioErr != nil {
  3230. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3231. // }
  3232. // var respJSON map[string]interface{}
  3233. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3234. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3235. // }
  3236. //
  3237. // var resSix10265 ResultSix10265 //1101结果
  3238. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3239. // result, _ := json.Marshal(respJSON)
  3240. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3241. // utils.ErrorLog("解析失败:%v", err)
  3242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3243. // return
  3244. // }
  3245. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3246. // res.ErrMsg = resSix10265.ErrMsg
  3247. // res.Cainfo = resSix10265.Cainfo
  3248. // res.WarnMsg = resSix10265.WarnMsg
  3249. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3250. // res.Infcode = infocode
  3251. // }
  3252. //
  3253. // if res.Infcode == 0 {
  3254. // service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3255. // item.IsSale = 0
  3256. // item.SaleDate = ""
  3257. // item.Bchno = ""
  3258. // service.SaveDF(item)
  3259. // } else {
  3260. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3261. // }
  3262. // }
  3263. //
  3264. // c.ServeSuccessJSON(map[string]interface{}{
  3265. // "msg": "删除销售数据成功",
  3266. // })
  3267. //
  3268. //}
  3269. // 获取当天起止时间戳
  3270. func GetNowTime() (int64, int64) {
  3271. t := time.Now()
  3272. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3273. timesamp := addTime.Unix()
  3274. return timesamp, timesamp + 86399
  3275. }
  3276. func (c *HisApiController) ChangeDrugfour() {
  3277. patient_id, _ := c.GetInt64("patient_id")
  3278. admin_user_id, _ := c.GetInt64("admin_user_id")
  3279. times := c.GetString("time", "")
  3280. timeLayout := "2006-01-02"
  3281. loc, _ := time.LoadLocation("Local")
  3282. var stime, etime int64
  3283. if times == "" {
  3284. stime, etime = GetNowTime()
  3285. } else {
  3286. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3287. stime = stmp.Unix()
  3288. etime = stime + 86399
  3289. }
  3290. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3291. //var flows []*models.DrugFlow
  3292. //for _, item := range advicelist {
  3293. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3294. // flows = append(flows, flow...)
  3295. //}
  3296. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3297. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3298. var err []string
  3299. for _, item := range advicelist {
  3300. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3301. if prescription.OrderStatus == 2 {
  3302. var res FJ3507Result
  3303. var res3507for10188 FJ3507ResultFor10188
  3304. number := strconv.FormatInt(item.ID, 10)
  3305. //进行商品销售接口
  3306. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number, stime)
  3307. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3308. var respJSON3 map[string]interface{}
  3309. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3312. return
  3313. }
  3314. userJSONBytes3, _ := json.Marshal(respJSON3)
  3315. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3316. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3317. utils.ErrorLog("解析失败:%v", err)
  3318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3319. return
  3320. }
  3321. //if res3507for10188.Infcode
  3322. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3323. //res.Output = resSix10265.Output
  3324. res.ErrMsg = res3507for10188.ErrMsg
  3325. res.Cainfo = res3507for10188.Cainfo
  3326. res.WarnMsg = res3507for10188.WarnMsg
  3327. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3328. res.Infcode = infocode
  3329. } else {
  3330. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3331. utils.ErrorLog("解析失败:%v", err)
  3332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3333. return
  3334. }
  3335. }
  3336. if res.Infcode == 0 {
  3337. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3338. } else {
  3339. err = append(err, item.AdviceName+",销售失败:"+res.ErrMsg)
  3340. }
  3341. } else { //还没结,提示用户去结算,并药品追溯上传
  3342. err = append(err, item.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3343. }
  3344. }
  3345. str := strings.Join(err, " ")
  3346. saveLog(str, str, "3505", "3505自动上传日志")
  3347. c.ServeSuccessJSON(map[string]interface{}{
  3348. "status": "1",
  3349. "msg": err,
  3350. })
  3351. }
  3352. func (c *HisApiController) ChangeDrugFive() {
  3353. id := c.GetString("id")
  3354. ids := strings.Split(id, ",")
  3355. admin_user_id, _ := c.GetInt64("admin_user_id")
  3356. var errs []string
  3357. //校验gui'ge
  3358. for _, value := range ids {
  3359. intValue, _ := strconv.ParseInt(value, 10, 64)
  3360. //file := strconv.FormatInt(int64(num), 10)
  3361. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3362. //for _, item := range advicelist {
  3363. // flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3364. // flows = append(flows, flow...)
  3365. //}
  3366. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3367. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3368. for _, item := range advicelist {
  3369. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3370. if prescription.OrderStatus != 2 {
  3371. // 将时间戳转换为time.Time类型
  3372. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3373. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  3374. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+"医嘱没结算无法上传")
  3375. }
  3376. if len(item.DrugCode) > 0 {
  3377. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3378. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  3379. codes := strings.Split(item.DrugCode, ",")
  3380. for _, code := range codes {
  3381. if len(code) > 0 {
  3382. if len(code) != 20 {
  3383. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"位数不是20位")
  3384. }
  3385. if IsDigit(code) == false {
  3386. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"不是纯数字")
  3387. }
  3388. }
  3389. }
  3390. }
  3391. }
  3392. }
  3393. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3394. if len(errs) > 0 {
  3395. c.ServeSuccessJSON(map[string]interface{}{
  3396. "failed_code": -10,
  3397. "msg": errs,
  3398. })
  3399. return
  3400. }
  3401. for _, value := range ids {
  3402. intValue, _ := strconv.ParseInt(value, 10, 64)
  3403. //file := strconv.FormatInt(int64(num), 10)
  3404. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3405. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3406. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3407. for _, item := range advicelist {
  3408. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3409. if prescription.OrderStatus == 2 {
  3410. var res FJ3507Result
  3411. var res3507for10188 FJ3507ResultFor10188
  3412. number := strconv.FormatInt(item.ID, 10)
  3413. //进行商品销售接口
  3414. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number, item.RecordDate)
  3415. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3416. var respJSON3 map[string]interface{}
  3417. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3420. return
  3421. }
  3422. userJSONBytes3, _ := json.Marshal(respJSON3)
  3423. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3424. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3425. utils.ErrorLog("解析失败:%v", err)
  3426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3427. return
  3428. }
  3429. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3430. res.ErrMsg = res3507for10188.ErrMsg
  3431. res.Cainfo = res3507for10188.Cainfo
  3432. res.WarnMsg = res3507for10188.WarnMsg
  3433. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3434. res.Infcode = infocode
  3435. } else {
  3436. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3437. utils.ErrorLog("解析失败:%v", err)
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. }
  3442. if res.Infcode == 0 {
  3443. service.SaveDoctoradviceStatus(item.ID, time.Now().Format("2006-01-02"))
  3444. } else {
  3445. errs = append(errs, item.AdviceName+",销售失败:"+res.ErrMsg)
  3446. }
  3447. } else { //还没结,提示用户去结算,并药品追溯上传
  3448. errs = append(errs, item.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3449. }
  3450. }
  3451. str := strings.Join(errs, " ")
  3452. saveLog(str, str, "3505", "3505自动上传日志")
  3453. }
  3454. c.ServeSuccessJSON(map[string]interface{}{
  3455. "status": "1",
  3456. "msg": errs,
  3457. })
  3458. }
  3459. //func (c *HisApiController) ChangeDrugfour() {
  3460. // patient_id, _ := c.GetInt64("patient_id")
  3461. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3462. // //id_arr := strings.Split(ids, ",")
  3463. // times := c.GetString("time", "")
  3464. // timeLayout := "2006-01-02"
  3465. // loc, _ := time.LoadLocation("Local")
  3466. // var stime, etime int64
  3467. // if times == "" {
  3468. // stime, etime = GetNowTime()
  3469. // } else {
  3470. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3471. // stime = stmp.Unix()
  3472. // etime = stime + 86399
  3473. // }
  3474. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3475. // var flows []*models.DrugFlow
  3476. // for _, item := range advicelist {
  3477. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3478. // flows = append(flows, flow...)
  3479. // }
  3480. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3481. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3482. // var err []string
  3483. //
  3484. // for _, item := range flows {
  3485. // var res3 ResultSix
  3486. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3487. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3488. // if prescription.OrderStatus == 2 {
  3489. // //已经结算
  3490. // //判断是否已经销售
  3491. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3492. // //是否已经变更 1是 0否
  3493. // if item.IsChange == 0 { //没变更,进行变更操作
  3494. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3495. //
  3496. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3497. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3498. // var respJSON3 map[string]interface{}
  3499. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3500. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3502. // return
  3503. // }
  3504. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3505. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3506. // utils.ErrorLog("解析失败:%v", err)
  3507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3508. // return
  3509. // }
  3510. // if res3.Infcode == 0 {
  3511. // item.IsChange = 1
  3512. // item.BgBchno = bg_number
  3513. // service.SaveDF2(item)
  3514. // } else {
  3515. //
  3516. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3517. // }
  3518. // }
  3519. // } else { //没销售,
  3520. // var res FJ3507Result
  3521. // var res3507for10188 FJ3507ResultFor10188
  3522. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3523. //
  3524. // //进行商品销售接口
  3525. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3526. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3527. // var respJSON3 map[string]interface{}
  3528. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3529. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3531. // return
  3532. // }
  3533. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3534. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3535. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3536. // utils.ErrorLog("解析失败:%v", err)
  3537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3538. // return
  3539. // }
  3540. // //if res3507for10188.Infcode
  3541. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3542. // //res.Output = resSix10265.Output
  3543. // res.ErrMsg = res3507for10188.ErrMsg
  3544. // res.Cainfo = res3507for10188.Cainfo
  3545. // res.WarnMsg = res3507for10188.WarnMsg
  3546. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3547. // res.Infcode = infocode
  3548. // } else {
  3549. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3550. // utils.ErrorLog("解析失败:%v", err)
  3551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3552. // return
  3553. // }
  3554. //
  3555. // }
  3556. // if res.Infcode == 0 {
  3557. // item.IsSale = 1
  3558. // item.Bchno = number
  3559. // item.SaleDate = time.Now().Format("2006-01-02")
  3560. //
  3561. // err5 := service.SaveDF(item)
  3562. // if err5 == nil {
  3563. // if item.IsChange == 0 { //没变更,进行变更操作
  3564. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3565. //
  3566. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3567. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3568. //
  3569. // var respJSON3 map[string]interface{}
  3570. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3571. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3573. // return
  3574. // }
  3575. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3576. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3577. // utils.ErrorLog("解析失败:%v", err)
  3578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3579. // return
  3580. // }
  3581. // //if res3507for10188.Infcode
  3582. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3583. // //res.Output = resSix10265.Output
  3584. // res3.ErrMsg = res3507for10188.ErrMsg
  3585. // res3.Cainfo = res3507for10188.Cainfo
  3586. // res3.WarnMsg = res3507for10188.WarnMsg
  3587. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3588. // res3.Infcode = infocode
  3589. // } else {
  3590. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3591. // utils.ErrorLog("解析失败:%v", err)
  3592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3593. // return
  3594. // }
  3595. // }
  3596. // if res3.Infcode == 0 {
  3597. // item.IsChange = 1
  3598. // item.BgBchno = bg_number
  3599. // service.SaveDF2(item)
  3600. // } else {
  3601. //
  3602. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3603. // }
  3604. // }
  3605. // }
  3606. // } else {
  3607. //
  3608. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3609. // }
  3610. // }
  3611. //
  3612. // } else { //还没结,提示用户去结算,并药品追溯上传
  3613. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3614. // }
  3615. // }
  3616. // }
  3617. // if len(err) == 0 {
  3618. // c.ServeSuccessJSON(map[string]interface{}{
  3619. // "msg": "销售变更成功",
  3620. // })
  3621. // } else {
  3622. // c.ServeSuccessJSON(map[string]interface{}{
  3623. // "failed_code": -10,
  3624. // "msg": err,
  3625. // })
  3626. // }
  3627. //}
  3628. //func (c *HisApiController) ChangeDrug() {
  3629. // ids := c.GetString("ids")
  3630. // id_arr := strings.Split(ids, ",")
  3631. // flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3632. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3633. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3634. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3635. // var err []string
  3636. // for _, item := range flows {
  3637. // var res3 ResultSix
  3638. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3639. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3640. // if prescription.OrderStatus == 2 {
  3641. // //已经结算
  3642. // //判断是否已经销售
  3643. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3644. // //是否已经变更 1是 0否
  3645. // if item.IsChange == 0 { //没变更,进行变更操作
  3646. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3647. //
  3648. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3649. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3650. // var respJSON3 map[string]interface{}
  3651. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3652. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3654. // return
  3655. // }
  3656. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3657. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3658. // utils.ErrorLog("解析失败:%v", err)
  3659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3660. // return
  3661. // }
  3662. // if res3.Infcode == 0 {
  3663. // item.IsChange = 1
  3664. // item.BgBchno = bg_number
  3665. // service.SaveDF2(item)
  3666. // } else {
  3667. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3668. // }
  3669. // }
  3670. // } else { //没销售,
  3671. // var res FJ3507Result
  3672. // var res3507for10188 FJ3507ResultFor10188
  3673. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3674. //
  3675. // //进行商品销售接口
  3676. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3677. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3678. // var respJSON3 map[string]interface{}
  3679. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3680. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3682. // return
  3683. // }
  3684. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3685. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3686. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3687. // utils.ErrorLog("解析失败:%v", err)
  3688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3689. // return
  3690. // }
  3691. // //if res3507for10188.Infcode
  3692. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3693. // //res.Output = resSix10265.Output
  3694. // res.ErrMsg = res3507for10188.ErrMsg
  3695. // res.Cainfo = res3507for10188.Cainfo
  3696. // res.WarnMsg = res3507for10188.WarnMsg
  3697. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3698. // res.Infcode = infocode
  3699. // } else {
  3700. //
  3701. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3702. // utils.ErrorLog("解析失败:%v", err)
  3703. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3704. // return
  3705. // }
  3706. //
  3707. // }
  3708. //
  3709. // if res.Infcode == 0 {
  3710. // item.IsSale = 1
  3711. // item.Bchno = number
  3712. // item.SaleDate = time.Now().Format("2006-01-02")
  3713. //
  3714. // err5 := service.SaveDF(item)
  3715. // if err5 == nil {
  3716. // if item.IsChange == 0 { //没变更,进行变更操作
  3717. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3718. //
  3719. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3720. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3721. //
  3722. // var respJSON3 map[string]interface{}
  3723. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3724. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3726. // return
  3727. // }
  3728. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3729. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3730. // utils.ErrorLog("解析失败:%v", err)
  3731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3732. // return
  3733. // }
  3734. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3735. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3736. // utils.ErrorLog("解析失败:%v", err)
  3737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3738. // return
  3739. // }
  3740. // //if res3507for10188.Infcode
  3741. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3742. // //res.Output = resSix10265.Output
  3743. // res3.ErrMsg = res3507for10188.ErrMsg
  3744. // res3.Cainfo = res3507for10188.Cainfo
  3745. // res3.WarnMsg = res3507for10188.WarnMsg
  3746. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3747. // res3.Infcode = infocode
  3748. // } else {
  3749. //
  3750. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3751. // utils.ErrorLog("解析失败:%v", err)
  3752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3753. // return
  3754. // }
  3755. //
  3756. // }
  3757. //
  3758. // if res3.Infcode == 0 {
  3759. // item.IsChange = 1
  3760. // item.BgBchno = bg_number
  3761. // service.SaveDF2(item)
  3762. // } else {
  3763. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3764. // }
  3765. // }
  3766. // }
  3767. // } else {
  3768. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3769. // }
  3770. // }
  3771. //
  3772. // } else { //还没结算
  3773. // var res3507for10188 FJ3507ResultFor10188
  3774. //
  3775. // if item.IsChange == 0 { //没变更,进行变更操作
  3776. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3777. //
  3778. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3779. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3780. //
  3781. // var respJSON3 map[string]interface{}
  3782. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3783. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3785. // return
  3786. // }
  3787. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3788. //
  3789. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3790. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3791. // utils.ErrorLog("解析失败:%v", err)
  3792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3793. // return
  3794. // }
  3795. // //if res3507for10188.Infcode
  3796. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3797. // //res.Output = resSix10265.Output
  3798. // res3.ErrMsg = res3507for10188.ErrMsg
  3799. // res3.Cainfo = res3507for10188.Cainfo
  3800. // res3.WarnMsg = res3507for10188.WarnMsg
  3801. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3802. // res3.Infcode = infocode
  3803. // } else {
  3804. //
  3805. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3806. // utils.ErrorLog("解析失败:%v", err)
  3807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3808. // return
  3809. // }
  3810. //
  3811. // }
  3812. //
  3813. // if res3.Infcode == 0 {
  3814. // item.IsChange = 1
  3815. // item.BgBchno = bg_number
  3816. // service.SaveDF2(item)
  3817. // } else {
  3818. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3819. // }
  3820. // }
  3821. // }
  3822. // } else if item.ConsumableType == 7 {
  3823. // var res3507for10188 FJ3507ResultFor10188
  3824. //
  3825. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3826. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3827. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3828. // //判断是否已经销售
  3829. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3830. // //是否已经变更 1是 0否
  3831. // if item.IsChange == 0 { //没变更,进行变更操作
  3832. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3833. //
  3834. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3835. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3836. //
  3837. // var respJSON3 map[string]interface{}
  3838. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3839. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3840. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3841. // return
  3842. // }
  3843. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3844. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3845. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3846. // utils.ErrorLog("解析失败:%v", err)
  3847. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3848. // return
  3849. // }
  3850. // //if res3507for10188.Infcode
  3851. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3852. // //res.Output = resSix10265.Output
  3853. // res3.ErrMsg = res3507for10188.ErrMsg
  3854. // res3.Cainfo = res3507for10188.Cainfo
  3855. // res3.WarnMsg = res3507for10188.WarnMsg
  3856. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3857. // res3.Infcode = infocode
  3858. // } else {
  3859. //
  3860. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3861. // utils.ErrorLog("解析失败:%v", err)
  3862. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3863. // return
  3864. // }
  3865. //
  3866. // }
  3867. // if res3.Infcode == 0 {
  3868. // item.IsChange = 1
  3869. // item.BgBchno = bg_number
  3870. // service.SaveDF2(item)
  3871. // } else {
  3872. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3873. // }
  3874. // }
  3875. // } else { //没销售,
  3876. // //进行商品销售退货接口
  3877. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3878. //
  3879. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3880. // saveLog(result111, result222, "3506", "销售退货")
  3881. // var res7 FJ3507Result
  3882. //
  3883. // //进行商品销售接口
  3884. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3885. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3886. // var respJSON3 map[string]interface{}
  3887. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3888. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3890. // return
  3891. // }
  3892. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3893. //
  3894. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3895. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3896. // utils.ErrorLog("解析失败:%v", err)
  3897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3898. // return
  3899. // }
  3900. // //if res3507for10188.Infcode
  3901. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3902. // //res.Output = resSix10265.Output
  3903. // res7.ErrMsg = res3507for10188.ErrMsg
  3904. // res7.Cainfo = res3507for10188.Cainfo
  3905. // res7.WarnMsg = res3507for10188.WarnMsg
  3906. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3907. // res7.Infcode = infocode
  3908. // } else {
  3909. //
  3910. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3911. // utils.ErrorLog("解析失败:%v", err)
  3912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3913. // return
  3914. // }
  3915. //
  3916. // }
  3917. // if res7.Infcode == 0 {
  3918. // item.IsSale = 2
  3919. // item.SaleDate = item.SaleDate
  3920. // item.Bchno = number
  3921. // service.SaveDF(item)
  3922. // if item.IsChange == 0 { //没变更,进行变更操作
  3923. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3924. //
  3925. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3926. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3927. //
  3928. // var respJSON3 map[string]interface{}
  3929. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3930. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3932. // return
  3933. // }
  3934. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3935. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3936. // // utils.ErrorLog("解析失败:%v", err)
  3937. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3938. // // return
  3939. // //}
  3940. //
  3941. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  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 {
  3956. //
  3957. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3958. // utils.ErrorLog("解析失败:%v", err)
  3959. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3960. // return
  3961. // }
  3962. //
  3963. // }
  3964. // if res3.Infcode == 0 {
  3965. // item.IsChange = 1
  3966. // item.BgBchno = bg_number
  3967. // service.SaveDF2(item)
  3968. // } else {
  3969. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3970. // }
  3971. // }
  3972. // } else {
  3973. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3974. // }
  3975. // }
  3976. // } else { //还没结算
  3977. // if item.IsChange == 0 { //没变更,进行变更操作
  3978. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3979. //
  3980. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3981. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3982. //
  3983. // var respJSON3 map[string]interface{}
  3984. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3985. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3987. // return
  3988. // }
  3989. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3990. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3991. // // utils.ErrorLog("解析失败:%v", err)
  3992. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3993. // // return
  3994. // //}
  3995. //
  3996. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3997. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3998. // utils.ErrorLog("解析失败:%v", err)
  3999. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4000. // return
  4001. // }
  4002. // //if res3507for10188.Infcode
  4003. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4004. // //res.Output = resSix10265.Output
  4005. // res3.ErrMsg = res3507for10188.ErrMsg
  4006. // res3.Cainfo = res3507for10188.Cainfo
  4007. // res3.WarnMsg = res3507for10188.WarnMsg
  4008. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4009. // res3.Infcode = infocode
  4010. // } else {
  4011. //
  4012. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4013. // utils.ErrorLog("解析失败:%v", err)
  4014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4015. // return
  4016. // }
  4017. //
  4018. // }
  4019. // if res3.Infcode == 0 {
  4020. // item.IsChange = 1
  4021. // item.BgBchno = bg_number
  4022. // service.SaveDF2(item)
  4023. // } else {
  4024. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4025. // }
  4026. // }
  4027. // }
  4028. // }
  4029. // }
  4030. // if len(err) == 0 {
  4031. // c.ServeSuccessJSON(map[string]interface{}{
  4032. // "msg": "销售变更成功",
  4033. // })
  4034. // } else {
  4035. // c.ServeSuccessJSON(map[string]interface{}{
  4036. // "failed_code": -10,
  4037. // "msg": err,
  4038. // })
  4039. // }
  4040. //}
  4041. //func (c *HisApiController) ChangeDrugtwo() {
  4042. //
  4043. // //ids := c.GetString("ids")
  4044. // //id_arr := strings.Split(ids, ",")
  4045. // flows, _ := service.GetNewDrugFlowInfothree123()
  4046. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4047. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4048. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4049. // var err []string
  4050. // for _, item := range flows {
  4051. // var res3 ResultSix
  4052. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4053. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4054. // if prescription.OrderStatus == 2 {
  4055. // //已经结算
  4056. // //判断是否已经销售
  4057. // //if item.IsSale == 1 { //是否已经销售,1是 0否
  4058. // // //是否已经变更 1是 0否
  4059. // // if item.IsChange == 0 { //没变更,进行变更操作
  4060. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4061. // //
  4062. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4063. // // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4064. // // var respJSON3 map[string]interface{}
  4065. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4066. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4067. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4068. // // return
  4069. // // }
  4070. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4071. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4072. // // utils.ErrorLog("解析失败:%v", err)
  4073. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4074. // // return
  4075. // // }
  4076. // // if res3.Infcode == 0 {
  4077. // // item.IsChange = 1
  4078. // // item.BgBchno = bg_number
  4079. // // service.SaveDF2(item)
  4080. // // } else {
  4081. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4082. // // }
  4083. // // }
  4084. // //}
  4085. // //else
  4086. // { //没销售,
  4087. // var res FJ3507Result
  4088. // var res3507for10188 FJ3507ResultFor10188
  4089. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4090. //
  4091. // //进行商品销售接口
  4092. // result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4093. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4094. // var respJSON3 map[string]interface{}
  4095. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4098. // return
  4099. // }
  4100. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4101. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4102. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4103. // utils.ErrorLog("解析失败:%v", err)
  4104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4105. // return
  4106. // }
  4107. // //if res3507for10188.Infcode
  4108. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4109. // //res.Output = resSix10265.Output
  4110. // res.ErrMsg = res3507for10188.ErrMsg
  4111. // res.Cainfo = res3507for10188.Cainfo
  4112. // res.WarnMsg = res3507for10188.WarnMsg
  4113. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4114. // res.Infcode = infocode
  4115. // } else {
  4116. //
  4117. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4118. // utils.ErrorLog("解析失败:%v", err)
  4119. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4120. // return
  4121. // }
  4122. //
  4123. // }
  4124. //
  4125. // if res.Infcode == 0 {
  4126. // item.IsSale = 1
  4127. // item.Bchno = number
  4128. // item.SaleDate = time.Now().Format("2006-01-02")
  4129. //
  4130. // service.SaveDF(item)
  4131. // //if err5 == nil {
  4132. // // if item.IsChange == 0 { //没变更,进行变更操作
  4133. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4134. // //
  4135. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4136. // // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4137. // //
  4138. // // var respJSON3 map[string]interface{}
  4139. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4140. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4141. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4142. // // return
  4143. // // }
  4144. // //
  4145. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4146. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4147. // // utils.ErrorLog("解析失败:%v", err)
  4148. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4149. // // return
  4150. // // }
  4151. // // //if res3507for10188.Infcode
  4152. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4153. // // //res.Output = resSix10265.Output
  4154. // // res3.ErrMsg = res3507for10188.ErrMsg
  4155. // // res3.Cainfo = res3507for10188.Cainfo
  4156. // // res3.WarnMsg = res3507for10188.WarnMsg
  4157. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4158. // // res3.Infcode = infocode
  4159. // // } else {
  4160. // //
  4161. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4162. // // utils.ErrorLog("解析失败:%v", err)
  4163. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4164. // // return
  4165. // // }
  4166. // //
  4167. // // }
  4168. // //
  4169. // // if res3.Infcode == 0 {
  4170. // // item.IsChange = 1
  4171. // // item.BgBchno = bg_number
  4172. // // service.SaveDF2(item)
  4173. // // } else {
  4174. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4175. // // }
  4176. // // }
  4177. // //}
  4178. // } else {
  4179. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4180. // }
  4181. // }
  4182. //
  4183. // } else { //还没结算
  4184. // var res3507for10188 FJ3507ResultFor10188
  4185. //
  4186. // if item.IsChange == 0 { //没变更,进行变更操作
  4187. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4188. //
  4189. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4190. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4191. //
  4192. // var respJSON3 map[string]interface{}
  4193. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4194. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4196. // return
  4197. // }
  4198. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4199. //
  4200. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4201. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4202. // utils.ErrorLog("解析失败:%v", err)
  4203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4204. // return
  4205. // }
  4206. // //if res3507for10188.Infcode
  4207. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4208. // //res.Output = resSix10265.Output
  4209. // res3.ErrMsg = res3507for10188.ErrMsg
  4210. // res3.Cainfo = res3507for10188.Cainfo
  4211. // res3.WarnMsg = res3507for10188.WarnMsg
  4212. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4213. // res3.Infcode = infocode
  4214. // } else {
  4215. //
  4216. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4217. // utils.ErrorLog("解析失败:%v", err)
  4218. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4219. // return
  4220. // }
  4221. //
  4222. // }
  4223. //
  4224. // if res3.Infcode == 0 {
  4225. // item.IsChange = 1
  4226. // item.BgBchno = bg_number
  4227. // service.SaveDF2(item)
  4228. // } else {
  4229. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4230. // }
  4231. // }
  4232. // }
  4233. // }
  4234. // //if item.ConsumableType == 7 {
  4235. // // var res3507for10188 FJ3507ResultFor10188
  4236. // //
  4237. // // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4238. // // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4239. // // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4240. // // //判断是否已经销售
  4241. // // if item.IsSale == 2 { //是否已经销售,1是 0否
  4242. // // //是否已经变更 1是 0否
  4243. // // if item.IsChange == 0 { //没变更,进行变更操作
  4244. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4245. // //
  4246. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4247. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4248. // //
  4249. // // var respJSON3 map[string]interface{}
  4250. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4251. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4252. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4253. // // return
  4254. // // }
  4255. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4256. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4257. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4258. // // utils.ErrorLog("解析失败:%v", err)
  4259. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4260. // // return
  4261. // // }
  4262. // // //if res3507for10188.Infcode
  4263. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4264. // // //res.Output = resSix10265.Output
  4265. // // res3.ErrMsg = res3507for10188.ErrMsg
  4266. // // res3.Cainfo = res3507for10188.Cainfo
  4267. // // res3.WarnMsg = res3507for10188.WarnMsg
  4268. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4269. // // res3.Infcode = infocode
  4270. // // } else {
  4271. // //
  4272. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4273. // // utils.ErrorLog("解析失败:%v", err)
  4274. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4275. // // return
  4276. // // }
  4277. // //
  4278. // // }
  4279. // // if res3.Infcode == 0 {
  4280. // // item.IsChange = 1
  4281. // // item.BgBchno = bg_number
  4282. // // service.SaveDF2(item)
  4283. // // } else {
  4284. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4285. // // }
  4286. // // }
  4287. // // } else { //没销售,
  4288. // // //进行商品销售退货接口
  4289. // // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4290. // //
  4291. // // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4292. // // saveLog(result111, result222, "3506", "销售退货")
  4293. // // var res7 FJ3507Result
  4294. // //
  4295. // // //进行商品销售接口
  4296. // // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4297. // // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4298. // // var respJSON3 map[string]interface{}
  4299. // // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4300. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4301. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4302. // // return
  4303. // // }
  4304. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4305. // //
  4306. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4307. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4308. // // utils.ErrorLog("解析失败:%v", err)
  4309. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4310. // // return
  4311. // // }
  4312. // // //if res3507for10188.Infcode
  4313. // // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4314. // // //res.Output = resSix10265.Output
  4315. // // res7.ErrMsg = res3507for10188.ErrMsg
  4316. // // res7.Cainfo = res3507for10188.Cainfo
  4317. // // res7.WarnMsg = res3507for10188.WarnMsg
  4318. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4319. // // res7.Infcode = infocode
  4320. // // } else {
  4321. // //
  4322. // // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4323. // // utils.ErrorLog("解析失败:%v", err)
  4324. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4325. // // return
  4326. // // }
  4327. // //
  4328. // // }
  4329. // // if res7.Infcode == 0 {
  4330. // // item.IsSale = 2
  4331. // // item.SaleDate = item.SaleDate
  4332. // // item.Bchno = number
  4333. // // service.SaveDF(item)
  4334. // // if item.IsChange == 0 { //没变更,进行变更操作
  4335. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4336. // //
  4337. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4338. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4339. // //
  4340. // // var respJSON3 map[string]interface{}
  4341. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4342. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4343. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. // // return
  4345. // // }
  4346. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4347. // // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4348. // // // utils.ErrorLog("解析失败:%v", err)
  4349. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. // // // return
  4351. // // //}
  4352. // //
  4353. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4354. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4355. // // utils.ErrorLog("解析失败:%v", err)
  4356. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4357. // // return
  4358. // // }
  4359. // // //if res3507for10188.Infcode
  4360. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4361. // // //res.Output = resSix10265.Output
  4362. // // res3.ErrMsg = res3507for10188.ErrMsg
  4363. // // res3.Cainfo = res3507for10188.Cainfo
  4364. // // res3.WarnMsg = res3507for10188.WarnMsg
  4365. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4366. // // res3.Infcode = infocode
  4367. // // } else {
  4368. // //
  4369. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4370. // // utils.ErrorLog("解析失败:%v", err)
  4371. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4372. // // return
  4373. // // }
  4374. // //
  4375. // // }
  4376. // // if res3.Infcode == 0 {
  4377. // // item.IsChange = 1
  4378. // // item.BgBchno = bg_number
  4379. // // service.SaveDF2(item)
  4380. // // } else {
  4381. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4382. // // }
  4383. // // }
  4384. // // } else {
  4385. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4386. // // }
  4387. // // }
  4388. // // } else { //还没结算
  4389. // // if item.IsChange == 0 { //没变更,进行变更操作
  4390. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4391. // //
  4392. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4393. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4394. // //
  4395. // // var respJSON3 map[string]interface{}
  4396. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4397. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4398. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. // // return
  4400. // // }
  4401. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4402. // // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4403. // // // utils.ErrorLog("解析失败:%v", err)
  4404. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4405. // // // return
  4406. // // //}
  4407. // //
  4408. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4409. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4410. // // utils.ErrorLog("解析失败:%v", err)
  4411. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4412. // // return
  4413. // // }
  4414. // // //if res3507for10188.Infcode
  4415. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4416. // // //res.Output = resSix10265.Output
  4417. // // res3.ErrMsg = res3507for10188.ErrMsg
  4418. // // res3.Cainfo = res3507for10188.Cainfo
  4419. // // res3.WarnMsg = res3507for10188.WarnMsg
  4420. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4421. // // res3.Infcode = infocode
  4422. // // } else {
  4423. // //
  4424. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4425. // // utils.ErrorLog("解析失败:%v", err)
  4426. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4427. // // return
  4428. // // }
  4429. // //
  4430. // // }
  4431. // // if res3.Infcode == 0 {
  4432. // // item.IsChange = 1
  4433. // // item.BgBchno = bg_number
  4434. // // service.SaveDF2(item)
  4435. // // } else {
  4436. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4437. // // }
  4438. // // }
  4439. // // }
  4440. // //}
  4441. // }
  4442. // if len(err) == 0 {
  4443. // c.ServeSuccessJSON(map[string]interface{}{
  4444. // "msg": "销售变更成功",
  4445. // })
  4446. // } else {
  4447. // c.ServeSuccessJSON(map[string]interface{}{
  4448. // "failed_code": -10,
  4449. // "msg": err,
  4450. // })
  4451. // }
  4452. //}
  4453. //
  4454. //func (c *HisApiController) ChangeDrugthree() {
  4455. //
  4456. // //ids := c.GetString("ids")
  4457. // //id_arr := strings.Split(ids, ",")
  4458. // flows, _ := service.GetNewDrugFlowInfothree()
  4459. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4460. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4461. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4462. // var err []string
  4463. // for _, item := range flows {
  4464. // var res3 ResultSix
  4465. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4466. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4467. // if prescription.OrderStatus == 2 {
  4468. // //已经结算
  4469. // //判断是否已经销售
  4470. // if item.IsSale == 1 { //是否已经销售,1是 0否
  4471. // //是否已经变更 1是 0否
  4472. // if item.IsChange == 0 { //没变更,进行变更操作
  4473. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4474. //
  4475. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4476. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4477. // var respJSON3 map[string]interface{}
  4478. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4479. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4481. // return
  4482. // }
  4483. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4484. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4485. // utils.ErrorLog("解析失败:%v", err)
  4486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4487. // return
  4488. // }
  4489. // if res3.Infcode == 0 {
  4490. // item.IsChange = 1
  4491. // item.BgBchno = bg_number
  4492. // service.SaveDF2(item)
  4493. // } else {
  4494. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4495. // }
  4496. // }
  4497. // } else { //没销售,
  4498. // var res FJ3507Result
  4499. // var res3507for10188 FJ3507ResultFor10188
  4500. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4501. //
  4502. // //进行商品销售接口
  4503. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4504. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4505. // var respJSON3 map[string]interface{}
  4506. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4509. // return
  4510. // }
  4511. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4512. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4513. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4514. // utils.ErrorLog("解析失败:%v", err)
  4515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4516. // return
  4517. // }
  4518. // //if res3507for10188.Infcode
  4519. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4520. // //res.Output = resSix10265.Output
  4521. // res.ErrMsg = res3507for10188.ErrMsg
  4522. // res.Cainfo = res3507for10188.Cainfo
  4523. // res.WarnMsg = res3507for10188.WarnMsg
  4524. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4525. // res.Infcode = infocode
  4526. // } else {
  4527. //
  4528. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4529. // utils.ErrorLog("解析失败:%v", err)
  4530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4531. // return
  4532. // }
  4533. //
  4534. // }
  4535. //
  4536. // if res.Infcode == 0 {
  4537. // item.IsSale = 1
  4538. // item.Bchno = number
  4539. // item.SaleDate = time.Now().Format("2006-01-02")
  4540. //
  4541. // err5 := service.SaveDF(item)
  4542. // if err5 == nil {
  4543. // if item.IsChange == 0 { //没变更,进行变更操作
  4544. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4545. //
  4546. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4547. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4548. //
  4549. // var respJSON3 map[string]interface{}
  4550. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4551. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4553. // return
  4554. // }
  4555. //
  4556. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4557. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4558. // utils.ErrorLog("解析失败:%v", err)
  4559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4560. // return
  4561. // }
  4562. // //if res3507for10188.Infcode
  4563. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4564. // //res.Output = resSix10265.Output
  4565. // res3.ErrMsg = res3507for10188.ErrMsg
  4566. // res3.Cainfo = res3507for10188.Cainfo
  4567. // res3.WarnMsg = res3507for10188.WarnMsg
  4568. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4569. // res3.Infcode = infocode
  4570. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4571. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4572. // utils.ErrorLog("解析失败:%v", err)
  4573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4574. // return
  4575. // }
  4576. // //if res3507for10188.Infcode
  4577. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4578. // //res.Output = resSix10265.Output
  4579. // res3.ErrMsg = res3507for10188.ErrMsg
  4580. // res3.Cainfo = res3507for10188.Cainfo
  4581. // res3.WarnMsg = res3507for10188.WarnMsg
  4582. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4583. // res3.Infcode = infocode
  4584. //
  4585. // } else {
  4586. //
  4587. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4588. // utils.ErrorLog("解析失败:%v", err)
  4589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4590. // return
  4591. // }
  4592. //
  4593. // }
  4594. //
  4595. // if res3.Infcode == 0 {
  4596. // item.IsChange = 1
  4597. // item.BgBchno = bg_number
  4598. // service.SaveDF2(item)
  4599. // } else {
  4600. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4601. // }
  4602. // }
  4603. // }
  4604. // } else {
  4605. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4606. // }
  4607. // }
  4608. //
  4609. // } else { //还没结算
  4610. // var res3507for10188 FJ3507ResultFor10188
  4611. //
  4612. // if item.IsChange == 0 { //没变更,进行变更操作
  4613. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4614. //
  4615. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4616. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4617. //
  4618. // var respJSON3 map[string]interface{}
  4619. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4620. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4622. // return
  4623. // }
  4624. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4625. //
  4626. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4627. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4628. // utils.ErrorLog("解析失败:%v", err)
  4629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. // return
  4631. // }
  4632. // //if res3507for10188.Infcode
  4633. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4634. // //res.Output = resSix10265.Output
  4635. // res3.ErrMsg = res3507for10188.ErrMsg
  4636. // res3.Cainfo = res3507for10188.Cainfo
  4637. // res3.WarnMsg = res3507for10188.WarnMsg
  4638. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4639. // res3.Infcode = infocode
  4640. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4641. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4642. // utils.ErrorLog("解析失败:%v", err)
  4643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. // return
  4645. // }
  4646. // //if res3507for10188.Infcode
  4647. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4648. // //res.Output = resSix10265.Output
  4649. // res3.ErrMsg = res3507for10188.ErrMsg
  4650. // res3.Cainfo = res3507for10188.Cainfo
  4651. // res3.WarnMsg = res3507for10188.WarnMsg
  4652. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4653. // res3.Infcode = infocode
  4654. //
  4655. // } else {
  4656. //
  4657. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4658. // utils.ErrorLog("解析失败:%v", err)
  4659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4660. // return
  4661. // }
  4662. //
  4663. // }
  4664. //
  4665. // if res3.Infcode == 0 {
  4666. // item.IsChange = 1
  4667. // item.BgBchno = bg_number
  4668. // service.SaveDF2(item)
  4669. // } else {
  4670. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4671. // }
  4672. // }
  4673. // }
  4674. // } else if item.ConsumableType == 7 {
  4675. // var res3507for10188 FJ3507ResultFor10188
  4676. //
  4677. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4678. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4679. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4680. // //判断是否已经销售
  4681. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4682. // //是否已经变更 1是 0否
  4683. // if item.IsChange == 0 { //没变更,进行变更操作
  4684. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4685. //
  4686. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4687. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4688. //
  4689. // var respJSON3 map[string]interface{}
  4690. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4691. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4692. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4693. // return
  4694. // }
  4695. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4696. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4697. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4698. // utils.ErrorLog("解析失败:%v", err)
  4699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4700. // return
  4701. // }
  4702. // //if res3507for10188.Infcode
  4703. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4704. // //res.Output = resSix10265.Output
  4705. // res3.ErrMsg = res3507for10188.ErrMsg
  4706. // res3.Cainfo = res3507for10188.Cainfo
  4707. // res3.WarnMsg = res3507for10188.WarnMsg
  4708. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4709. // res3.Infcode = infocode
  4710. // } else {
  4711. //
  4712. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4713. // utils.ErrorLog("解析失败:%v", err)
  4714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4715. // return
  4716. // }
  4717. //
  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. // } else { //没销售,
  4728. // //进行商品销售退货接口
  4729. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4730. //
  4731. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4732. // saveLog(result111, result222, "3506", "销售退货")
  4733. // var res7 FJ3507Result
  4734. //
  4735. // //进行商品销售接口
  4736. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4737. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4738. // var respJSON3 map[string]interface{}
  4739. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4740. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4741. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4742. // return
  4743. // }
  4744. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4745. //
  4746. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4747. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4748. // utils.ErrorLog("解析失败:%v", err)
  4749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4750. // return
  4751. // }
  4752. // //if res3507for10188.Infcode
  4753. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4754. // //res.Output = resSix10265.Output
  4755. // res7.ErrMsg = res3507for10188.ErrMsg
  4756. // res7.Cainfo = res3507for10188.Cainfo
  4757. // res7.WarnMsg = res3507for10188.WarnMsg
  4758. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4759. // res7.Infcode = infocode
  4760. // } else {
  4761. //
  4762. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4763. // utils.ErrorLog("解析失败:%v", err)
  4764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. // return
  4766. // }
  4767. //
  4768. // }
  4769. // if res7.Infcode == 0 {
  4770. // item.IsSale = 2
  4771. // item.SaleDate = item.SaleDate
  4772. // item.Bchno = number
  4773. // service.SaveDF(item)
  4774. // if item.IsChange == 0 { //没变更,进行变更操作
  4775. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4776. //
  4777. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4778. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4779. //
  4780. // var respJSON3 map[string]interface{}
  4781. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4782. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4784. // return
  4785. // }
  4786. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4787. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4788. // // utils.ErrorLog("解析失败:%v", err)
  4789. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4790. // // return
  4791. // //}
  4792. //
  4793. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4794. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4795. // utils.ErrorLog("解析失败:%v", err)
  4796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. // return
  4798. // }
  4799. // //if res3507for10188.Infcode
  4800. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4801. // //res.Output = resSix10265.Output
  4802. // res3.ErrMsg = res3507for10188.ErrMsg
  4803. // res3.Cainfo = res3507for10188.Cainfo
  4804. // res3.WarnMsg = res3507for10188.WarnMsg
  4805. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4806. // res3.Infcode = infocode
  4807. // } else {
  4808. //
  4809. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4810. // utils.ErrorLog("解析失败:%v", err)
  4811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4812. // return
  4813. // }
  4814. //
  4815. // }
  4816. // if res3.Infcode == 0 {
  4817. // item.IsChange = 1
  4818. // item.BgBchno = bg_number
  4819. // service.SaveDF2(item)
  4820. // } else {
  4821. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4822. // }
  4823. // }
  4824. // } else {
  4825. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4826. // }
  4827. // }
  4828. // } else { //还没结算
  4829. // if item.IsChange == 0 { //没变更,进行变更操作
  4830. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4831. //
  4832. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4833. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4834. //
  4835. // var respJSON3 map[string]interface{}
  4836. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4837. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4839. // return
  4840. // }
  4841. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4842. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4843. // // utils.ErrorLog("解析失败:%v", err)
  4844. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4845. // // return
  4846. // //}
  4847. //
  4848. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4849. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4850. // utils.ErrorLog("解析失败:%v", err)
  4851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4852. // return
  4853. // }
  4854. // //if res3507for10188.Infcode
  4855. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4856. // //res.Output = resSix10265.Output
  4857. // res3.ErrMsg = res3507for10188.ErrMsg
  4858. // res3.Cainfo = res3507for10188.Cainfo
  4859. // res3.WarnMsg = res3507for10188.WarnMsg
  4860. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4861. // res3.Infcode = infocode
  4862. // } else {
  4863. //
  4864. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4865. // utils.ErrorLog("解析失败:%v", err)
  4866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. // return
  4868. // }
  4869. //
  4870. // }
  4871. // if res3.Infcode == 0 {
  4872. // item.IsChange = 1
  4873. // item.BgBchno = bg_number
  4874. // service.SaveDF2(item)
  4875. // } else {
  4876. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4877. // }
  4878. // }
  4879. // }
  4880. // }
  4881. // }
  4882. // if len(err) == 0 {
  4883. // c.ServeSuccessJSON(map[string]interface{}{
  4884. // "msg": "销售变更成功",
  4885. // })
  4886. // } else {
  4887. // c.ServeSuccessJSON(map[string]interface{}{
  4888. // "failed_code": -10,
  4889. // "msg": err,
  4890. // })
  4891. // }
  4892. //}
  4893. //func (c *HisApiController) ChangeDrugTen() {
  4894. // start_time_str := c.GetString("start_time")
  4895. // end_time_str := c.GetString("end_time")
  4896. // //ids := c.GetString("ids")
  4897. // //id_arr := strings.Split(ids, ",")
  4898. // timeLayout := "2006-01-02"
  4899. // loc, _ := time.LoadLocation("Local")
  4900. // theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4901. //
  4902. // recordStartTime := theStartTime.Unix()
  4903. //
  4904. // theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4905. //
  4906. // recordEndTime := theEndTime.Unix()
  4907. //
  4908. // //timestamp := int64(1729612800)
  4909. // flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4910. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4911. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4912. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4913. // var err []string
  4914. // for _, item := range flows {
  4915. // var res3 ResultSix
  4916. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4917. // if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4918. // continue
  4919. // }
  4920. // if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4921. // continue
  4922. // }
  4923. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4924. //
  4925. // if prescription.OrderStatus == 2 {
  4926. // //已经结算
  4927. // //判断 是否已经销售
  4928. // //if item.IsSale == 1 { //是否已经销售,1是 0否
  4929. // ////是否已经变更 1是 0否
  4930. // //if item.IsChange == 0 { //没变更,进行变更操作
  4931. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4932. // //
  4933. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4934. // // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4935. // // var respJSON3 map[string]interface{}
  4936. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4937. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4938. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4939. // // return
  4940. // // }
  4941. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4942. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4943. // // utils.ErrorLog("解析失败:%v", err)
  4944. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4945. // // return
  4946. // // }
  4947. // // if res3.Infcode == 0 {
  4948. // // item.IsChange = 1
  4949. // // item.BgBchno = bg_number
  4950. // // service.SaveDF2(item)
  4951. // // } else {
  4952. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4953. // // }
  4954. // //}
  4955. //
  4956. // //} else
  4957. // if item.IsSale == 0 { //没销售,
  4958. // var res FJ3507Result
  4959. // var res3507for10188 FJ3507ResultFor10188
  4960. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4961. //
  4962. // //进行商品销售接口
  4963. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4964. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4965. // var respJSON3 map[string]interface{}
  4966. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4967. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4968. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4969. // return
  4970. // }
  4971. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4972. // if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  4973. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4974. // utils.ErrorLog("解析失败:%v", err)
  4975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4976. // return
  4977. // }
  4978. // //if res3507for10188.Infcode
  4979. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4980. // //res.Output = resSix10265.Output
  4981. // res.ErrMsg = res3507for10188.ErrMsg
  4982. // res.Cainfo = res3507for10188.Cainfo
  4983. // res.WarnMsg = res3507for10188.WarnMsg
  4984. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4985. // res.Infcode = infocode
  4986. // } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4987. //
  4988. // } else {
  4989. //
  4990. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4991. // utils.ErrorLog("解析失败:%v", err)
  4992. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4993. // return
  4994. // }
  4995. //
  4996. // }
  4997. //
  4998. // if res.Infcode == 0 {
  4999. // item.IsSale = 1
  5000. // item.Bchno = number
  5001. // item.SaleDate = time.Now().Format("2006-01-02")
  5002. // service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  5003. //
  5004. // err5 := service.SaveDF(item)
  5005. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  5006. // //if err5 == nil {
  5007. // //
  5008. // // if item.IsChange == 1 { //没变更,进行变更操作
  5009. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5010. // //
  5011. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5012. // // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5013. // //
  5014. // // var respJSON3 map[string]interface{}
  5015. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5016. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5017. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5018. // // return
  5019. // // }
  5020. // //
  5021. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  5022. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5023. // // utils.ErrorLog("解析失败:%v", err)
  5024. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. // // return
  5026. // // }
  5027. // // //if res3507for10188.Infcode
  5028. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5029. // // //res.Output = resSix10265.Output
  5030. // // res3.ErrMsg = res3507for10188.ErrMsg
  5031. // // res3.Cainfo = res3507for10188.Cainfo
  5032. // // res3.WarnMsg = res3507for10188.WarnMsg
  5033. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5034. // // res3.Infcode = infocode
  5035. // // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5036. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5037. // // utils.ErrorLog("解析失败:%v", err)
  5038. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5039. // // return
  5040. // // }
  5041. // // //if res3507for10188.Infcode
  5042. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5043. // // //res.Output = resSix10265.Output
  5044. // // res3.ErrMsg = res3507for10188.ErrMsg
  5045. // // res3.Cainfo = res3507for10188.Cainfo
  5046. // // res3.WarnMsg = res3507for10188.WarnMsg
  5047. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5048. // // res3.Infcode = infocode
  5049. // //
  5050. // // } else {
  5051. // //
  5052. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5053. // // utils.ErrorLog("解析失败:%v", err)
  5054. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5055. // // return
  5056. // // }
  5057. // //
  5058. // // }
  5059. // //
  5060. // // if res3.Infcode == 0 {
  5061. // // item.IsChange = 1
  5062. // // item.BgBchno = bg_number
  5063. // // service.SaveDF2(item)
  5064. // // return
  5065. // // } else {
  5066. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5067. // // }
  5068. // // }
  5069. // //}
  5070. // } else {
  5071. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5072. // }
  5073. // }
  5074. //
  5075. // }
  5076. // } else if item.ConsumableType == 7 {
  5077. // var res3507for10188 FJ3507ResultFor10188
  5078. //
  5079. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5080. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  5081. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  5082. // //判断是否已经销售
  5083. // if item.IsSale == 2 { //是否已经销售,1是 0否
  5084. // //是否已经变更 1是 0否
  5085. // if item.IsChange == 0 { //没变更,进行变更操作
  5086. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5087. //
  5088. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5089. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5090. //
  5091. // var respJSON3 map[string]interface{}
  5092. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5093. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5095. // return
  5096. // }
  5097. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5098. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5099. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5100. // utils.ErrorLog("解析失败:%v", err)
  5101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5102. // return
  5103. // }
  5104. // //if res3507for10188.Infcode
  5105. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5106. // //res.Output = resSix10265.Output
  5107. // res3.ErrMsg = res3507for10188.ErrMsg
  5108. // res3.Cainfo = res3507for10188.Cainfo
  5109. // res3.WarnMsg = res3507for10188.WarnMsg
  5110. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5111. // res3.Infcode = infocode
  5112. // } else {
  5113. //
  5114. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5115. // utils.ErrorLog("解析失败:%v", err)
  5116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5117. // return
  5118. // }
  5119. //
  5120. // }
  5121. // if res3.Infcode == 0 {
  5122. // item.IsChange = 1
  5123. // item.BgBchno = bg_number
  5124. // service.SaveDF2(item)
  5125. // } else {
  5126. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5127. // }
  5128. // }
  5129. // } else { //没销售,
  5130. // //进行商品销售退货接口
  5131. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  5132. //
  5133. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  5134. // saveLog(result111, result222, "3506", "销售退货")
  5135. // var res7 FJ3507Result
  5136. //
  5137. // //进行商品销售接口
  5138. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5139. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5140. // var respJSON3 map[string]interface{}
  5141. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5142. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5144. // return
  5145. // }
  5146. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5147. //
  5148. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5149. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5150. // utils.ErrorLog("解析失败:%v", err)
  5151. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5152. // return
  5153. // }
  5154. // //if res3507for10188.Infcode
  5155. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5156. // //res.Output = resSix10265.Output
  5157. // res7.ErrMsg = res3507for10188.ErrMsg
  5158. // res7.Cainfo = res3507for10188.Cainfo
  5159. // res7.WarnMsg = res3507for10188.WarnMsg
  5160. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5161. // res7.Infcode = infocode
  5162. // } else {
  5163. //
  5164. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5165. // utils.ErrorLog("解析失败:%v", err)
  5166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5167. // return
  5168. // }
  5169. //
  5170. // }
  5171. // if res7.Infcode == 0 {
  5172. // item.IsSale = 2
  5173. // item.SaleDate = item.SaleDate
  5174. // item.Bchno = number
  5175. // service.SaveDF(item)
  5176. // if item.IsChange == 0 { //没变更,进行变更操作
  5177. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5178. //
  5179. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5180. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5181. //
  5182. // var respJSON3 map[string]interface{}
  5183. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5184. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5186. // return
  5187. // }
  5188. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5189. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5190. // // utils.ErrorLog("解析失败:%v", err)
  5191. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5192. // // return
  5193. // //}
  5194. //
  5195. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5196. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5197. // utils.ErrorLog("解析失败:%v", err)
  5198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5199. // return
  5200. // }
  5201. // //if res3507for10188.Infcode
  5202. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5203. // //res.Output = resSix10265.Output
  5204. // res3.ErrMsg = res3507for10188.ErrMsg
  5205. // res3.Cainfo = res3507for10188.Cainfo
  5206. // res3.WarnMsg = res3507for10188.WarnMsg
  5207. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5208. // res3.Infcode = infocode
  5209. // } else {
  5210. //
  5211. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5212. // utils.ErrorLog("解析失败:%v", err)
  5213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5214. // return
  5215. // }
  5216. //
  5217. // }
  5218. // if res3.Infcode == 0 {
  5219. // item.IsChange = 1
  5220. // item.BgBchno = bg_number
  5221. // service.SaveDF2(item)
  5222. // } else {
  5223. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5224. // }
  5225. // }
  5226. // } else {
  5227. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5228. // }
  5229. // }
  5230. // } else { //还没结算
  5231. // if item.IsChange == 0 { //没变更,进行变更操作
  5232. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5233. //
  5234. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5235. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5236. //
  5237. // var respJSON3 map[string]interface{}
  5238. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5239. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5241. // return
  5242. // }
  5243. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5244. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5245. // // utils.ErrorLog("解析失败:%v", err)
  5246. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5247. // // return
  5248. // //}
  5249. //
  5250. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5251. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5252. // utils.ErrorLog("解析失败:%v", err)
  5253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5254. // return
  5255. // }
  5256. // //if res3507for10188.Infcode
  5257. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5258. // //res.Output = resSix10265.Output
  5259. // res3.ErrMsg = res3507for10188.ErrMsg
  5260. // res3.Cainfo = res3507for10188.Cainfo
  5261. // res3.WarnMsg = res3507for10188.WarnMsg
  5262. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5263. // res3.Infcode = infocode
  5264. // } else {
  5265. //
  5266. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5267. // utils.ErrorLog("解析失败:%v", err)
  5268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5269. // return
  5270. // }
  5271. //
  5272. // }
  5273. // if res3.Infcode == 0 {
  5274. // item.IsChange = 1
  5275. // item.BgBchno = bg_number
  5276. // service.SaveDF2(item)
  5277. // } else {
  5278. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5279. // }
  5280. // }
  5281. // }
  5282. // }
  5283. // }
  5284. // if len(err) == 0 {
  5285. // c.ServeSuccessJSON(map[string]interface{}{
  5286. // "msg": "销售变更成功",
  5287. // })
  5288. // } else {
  5289. // c.ServeSuccessJSON(map[string]interface{}{
  5290. // "failed_code": -10,
  5291. // "msg": err,
  5292. // })
  5293. // }
  5294. //}
  5295. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5296. var struct3502 models.Struct3502
  5297. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5298. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5299. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5300. struct3502.FixmedinsCode = miConfig.Code
  5301. struct3502.Code = miConfig.Code
  5302. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5303. struct3502.Opter = role.UserName
  5304. struct3502.RxFlag = "1"
  5305. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5306. struct3502.OrgName = miConfig.OrgName
  5307. struct3502.AccessKey = miConfig.AccessKey
  5308. struct3502.RequestUrl = miConfig.Url
  5309. struct3502.SecretKey = miConfig.SecretKey
  5310. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5311. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5312. struct3502.Url = miConfig.Url
  5313. struct3502.AppId = miConfig.Cainfo
  5314. struct3502.AppSecret = miConfig.AppSecret
  5315. struct3502.Enckey = miConfig.EncKey
  5316. struct3502.SignKey = miConfig.SignKey
  5317. struct3502.SecretKey = miConfig.SecretKey
  5318. struct3502.InvChgType = chgType
  5319. struct3502.FixmedinsBchno = number
  5320. struct3502.Cnt = strconv.FormatInt(count, 10)
  5321. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5322. //result1, result2, _ := service.FJyb3502(struct3502)
  5323. if miConfig.MdtrtareaAdmvs == "350500" {
  5324. result1, result2, _ := service.FJyb3502(struct3502)
  5325. //saveLog(result1, result2, "3502", "3502")
  5326. return result1, result2
  5327. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5328. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5329. return result1, result2
  5330. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5331. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5332. return result1, result2
  5333. } else {
  5334. data := make(map[string]interface{})
  5335. data["struct_3502s"] = struct3502
  5336. client := &http.Client{}
  5337. bytesData, _ := json.Marshal(data)
  5338. var req *http.Request
  5339. if miConfig.MdtrtareaAdmvs == "320830" {
  5340. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5341. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5342. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5343. } else {
  5344. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5345. }
  5346. resp, _ := client.Do(req)
  5347. defer resp.Body.Close()
  5348. body, ioErr := ioutil.ReadAll(resp.Body)
  5349. if ioErr != nil {
  5350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5351. }
  5352. var respJSON map[string]interface{}
  5353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5355. }
  5356. //var resSix10265 ResultSix10265 //1101结果
  5357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5358. result, _ := json.Marshal(respJSON)
  5359. return string(result), ""
  5360. }
  5361. }
  5362. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string, stime int64) (string, string) {
  5363. flow, _ := service.GetNewDrugFlowInfoByPatient(drug.DrugId, stime, org_id)
  5364. Drug, _ := service.GetDrugLibById(drug.DrugId)
  5365. var struct3505 models.Struct3505
  5366. struct3505.MedListCodg = Drug.MedicalInsuranceNumber
  5367. struct3505.FixmedinsHilistId = Drug.MedicalInsuranceNumber
  5368. struct3505.FixmedinsHilistName = Drug.DrugName
  5369. struct3505.FixmedinsBchno = number
  5370. struct3505.Opter = role.UserName
  5371. struct3505.Bchno = "---"
  5372. struct3505.FixmedinsCode = miConfig.Code
  5373. struct3505.Code = miConfig.Code
  5374. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.Price, 'f', -1, 64)
  5375. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5376. struct3505.PrscDrName = roles.UserName
  5377. if org_id == 10191 {
  5378. struct3505.PharName = "刘水山"
  5379. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5380. }
  5381. if org_id == 10188 {
  5382. struct3505.PharName = "李汉清"
  5383. struct3505.PharPracCertNo = "30220200932022010034"
  5384. }
  5385. if org_id == 10217 {
  5386. struct3505.PharName = "张敏"
  5387. struct3505.PharPracCertNo = "30220230432090100108"
  5388. }
  5389. if org_id == 10318 {
  5390. struct3505.PharName = "邹刘阳"
  5391. struct3505.PharPracCertNo = "210441200001378"
  5392. }
  5393. if org_id == 10402 {
  5394. struct3505.PharName = "刘韶健"
  5395. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5396. }
  5397. if org_id == 9919 {
  5398. struct3505.PharName = "周君权"
  5399. struct3505.PharPracCertNo = "089644396094401375"
  5400. }
  5401. if org_id == 10644 {
  5402. struct3505.PharName = "陈金娣"
  5403. struct3505.PharPracCertNo = "20181441500320100066"
  5404. }
  5405. if org_id == 10567 {
  5406. struct3505.PharName = "范小兰"
  5407. struct3505.PharPracCertNo = "0200102079485"
  5408. }
  5409. if org_id == 10721 {
  5410. struct3505.PharName = "孙莉侠"
  5411. struct3505.PharPracCertNo = "060399"
  5412. }
  5413. if org_id == 10726 {
  5414. struct3505.PharName = "彭建福"
  5415. struct3505.PharPracCertNo = "D445281006261"
  5416. }
  5417. if org_id == 10697 {
  5418. struct3505.PharName = "陶海兰"
  5419. struct3505.PharPracCertNo = "0010933"
  5420. }
  5421. if org_id == 10265 {
  5422. struct3505.PharName = "李彩星"
  5423. struct3505.PharPracCertNo = "20171110600110100019"
  5424. }
  5425. if org_id == 10028 {
  5426. struct3505.PharName = "曾细平"
  5427. struct3505.PharPracCertNo = "D440307022134"
  5428. }
  5429. if org_id == 10138 {
  5430. struct3505.PharName = "彭斯遥"
  5431. struct3505.PharPracCertNo = "30220200943042010052"
  5432. }
  5433. if org_id == 10278 {
  5434. struct3505.PharName = "彭斯遥"
  5435. struct3505.PharPracCertNo = "30220200943042010052"
  5436. }
  5437. if org_id == 10610 {
  5438. struct3505.PharName = "彭斯遥"
  5439. struct3505.PharPracCertNo = "30220200943042010052"
  5440. }
  5441. if org_id == 10537 {
  5442. struct3505.PharName = "彭斯遥"
  5443. struct3505.PharPracCertNo = "30220200943042010052"
  5444. }
  5445. if org_id == 9504 {
  5446. struct3505.PharName = "资美红"
  5447. struct3505.PharPracCertNo = "D440904006635"
  5448. }
  5449. if org_id == 10480 {
  5450. struct3505.PharName = "陈思"
  5451. struct3505.PharPracCertNo = "30220240434110010470"
  5452. }
  5453. if org_id == 10653 {
  5454. struct3505.PharName = "邓树英"
  5455. struct3505.PharPracCertNo = "201910026440004734"
  5456. }
  5457. if org_id == 10571 {
  5458. struct3505.PharName = "廖志平"
  5459. struct3505.PharPracCertNo = "0136425"
  5460. }
  5461. if org_id == 10387 {
  5462. struct3505.PharName = "易圣"
  5463. struct3505.PharPracCertNo = "D430726002209"
  5464. }
  5465. if org_id == 10633 {
  5466. struct3505.PharName = "王敏"
  5467. struct3505.PharPracCertNo = "342222199107214042"
  5468. }
  5469. if org_id == 9478 {
  5470. struct3505.PharName = "祁仲钰"
  5471. struct3505.PharPracCertNo = "D440111043488"
  5472. }
  5473. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5474. struct3505.SetlId = order.SetlId
  5475. struct3505.MdtrtSn = order.MdtrtId
  5476. struct3505.ManuLotnum = flow.BatchNumber
  5477. struct3505.ManuDate = time.Unix(flow.ProductDate, 0).Format("2006-01-02")
  5478. struct3505.ExpyEnd = time.Unix(flow.ExpireDate, 0).Format("2006-01-02")
  5479. struct3505.RxFlag = "1"
  5480. if drug.PrescribingNumberUnit != drug.BaseDrugLib.MinUnit {
  5481. struct3505.TrdnFlag = "0"
  5482. } else {
  5483. struct3505.TrdnFlag = "1"
  5484. }
  5485. if drug.ZeroFlag == 1 {
  5486. struct3505.TrdnFlag = "1"
  5487. }
  5488. if drug.ZeroFlag == 2 {
  5489. struct3505.TrdnFlag = "0"
  5490. }
  5491. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 || org_id == 9478 {
  5492. if Drug.IsZeroFlag == 1 {
  5493. struct3505.TrdnFlag = "1"
  5494. }
  5495. if Drug.IsZeroFlag == 2 {
  5496. struct3505.TrdnFlag = "0"
  5497. }
  5498. }
  5499. struct3505.RtalDocno = order.Number
  5500. struct3505.PsnCertType = "01"
  5501. struct3505.CertNo = order.Certno
  5502. struct3505.PsnNo = order.PsnNo
  5503. struct3505.PsnName = order.PsnName
  5504. struct3505.Url = miConfig.Url
  5505. struct3505.AppId = miConfig.Cainfo
  5506. struct3505.AppSecret = miConfig.AppSecret
  5507. struct3505.Enckey = miConfig.EncKey
  5508. struct3505.SignKey = miConfig.SignKey
  5509. struct3505.SecretKey = miConfig.SecretKey
  5510. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  5511. struct3505.SelRetnCnt = strValue
  5512. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5513. struct3505.SelRetnOpterName = role.UserName
  5514. if order.IsMedicineInsurance == 1 {
  5515. struct3505.MdtrtSetlType = "1"
  5516. } else {
  5517. struct3505.MdtrtSetlType = "2"
  5518. }
  5519. struct3505.OrgName = miConfig.OrgName
  5520. struct3505.AccessKey = miConfig.AccessKey
  5521. struct3505.RequestUrl = miConfig.Url
  5522. struct3505.SecretKey = miConfig.SecretKey
  5523. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5524. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5525. struct3505.Cainfo = miConfig.Cainfo
  5526. struct3505.DrugTracCodg = drug.DrugCode
  5527. if miConfig.MdtrtareaAdmvs == "350500" {
  5528. result1, result2, _ := service.FJyb3505(struct3505)
  5529. return result1, result2
  5530. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5531. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5532. return result1, result2
  5533. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5534. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5535. return result1, result2
  5536. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5537. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5538. return result1, result2
  5539. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5540. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5541. return result1, result2
  5542. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5543. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5544. return result1, result2
  5545. } else if miConfig.MdtrtareaAdmvs == "150404" {
  5546. data := make(map[string]interface{})
  5547. data["struct_3505s"] = struct3505
  5548. client := &http.Client{}
  5549. bytesData, _ := json.Marshal(data)
  5550. var req *http.Request
  5551. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5552. resp, _ := client.Do(req)
  5553. defer resp.Body.Close()
  5554. body, ioErr := ioutil.ReadAll(resp.Body)
  5555. if ioErr != nil {
  5556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5557. }
  5558. var respJSON map[string]interface{}
  5559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5561. }
  5562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5563. result, _ := json.Marshal(respJSON)
  5564. return string(result), ""
  5565. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5566. data := make(map[string]interface{})
  5567. data["struct_3505s"] = struct3505
  5568. client := &http.Client{}
  5569. bytesData, _ := json.Marshal(data)
  5570. var req *http.Request
  5571. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5572. resp, _ := client.Do(req)
  5573. defer resp.Body.Close()
  5574. body, ioErr := ioutil.ReadAll(resp.Body)
  5575. if ioErr != nil {
  5576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5577. }
  5578. var respJSON map[string]interface{}
  5579. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5581. }
  5582. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5583. if status == "0" {
  5584. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5585. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5586. }
  5587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5588. result, _ := json.Marshal(respJSON)
  5589. return string(result), ""
  5590. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5591. result1, result2 := service.Hnyb3505(struct3505)
  5592. return result1, result2
  5593. } else {
  5594. data := make(map[string]interface{})
  5595. data["struct_3505s"] = struct3505
  5596. client := &http.Client{}
  5597. bytesData, _ := json.Marshal(data)
  5598. var req *http.Request
  5599. if miConfig.MdtrtareaAdmvs == "320830" {
  5600. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5601. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5602. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5603. } else {
  5604. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5605. }
  5606. resp, _ := client.Do(req)
  5607. defer resp.Body.Close()
  5608. body, ioErr := ioutil.ReadAll(resp.Body)
  5609. if ioErr != nil {
  5610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5611. }
  5612. var respJSON map[string]interface{}
  5613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5615. }
  5616. //var resSix10265 ResultSix10265 //1101结果
  5617. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5618. result, _ := json.Marshal(respJSON)
  5619. return string(result), ""
  5620. }
  5621. }
  5622. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5623. var struct3505 models.Struct3505
  5624. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5625. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5626. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5627. struct3505.FixmedinsBchno = number
  5628. struct3505.Opter = role.UserName
  5629. struct3505.FixmedinsCode = miConfig.Code
  5630. struct3505.Code = miConfig.Code
  5631. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5632. struct3505.PrscDrName = roles.UserName
  5633. if org_id == 10191 {
  5634. struct3505.PharName = "刘水山"
  5635. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5636. }
  5637. if org_id == 10188 {
  5638. struct3505.PharName = "李汉清"
  5639. struct3505.PharPracCertNo = "30220200932022010034"
  5640. }
  5641. if org_id == 10217 {
  5642. struct3505.PharName = "张敏"
  5643. struct3505.PharPracCertNo = "30220230432090100108"
  5644. }
  5645. if org_id == 10318 {
  5646. struct3505.PharName = "邹刘阳"
  5647. struct3505.PharPracCertNo = "210441200001378"
  5648. }
  5649. if org_id == 10402 {
  5650. struct3505.PharName = "刘韶健"
  5651. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5652. }
  5653. if org_id == 9919 {
  5654. struct3505.PharName = "周君权"
  5655. struct3505.PharPracCertNo = "089644396094401375"
  5656. }
  5657. if org_id == 10644 {
  5658. struct3505.PharName = "陈金娣"
  5659. struct3505.PharPracCertNo = "20181441500320100066"
  5660. }
  5661. if org_id == 10567 {
  5662. struct3505.PharName = "范小兰"
  5663. struct3505.PharPracCertNo = "0200102079485"
  5664. }
  5665. if org_id == 10721 {
  5666. struct3505.PharName = "孙莉侠"
  5667. struct3505.PharPracCertNo = "060399"
  5668. }
  5669. if org_id == 10726 {
  5670. struct3505.PharName = "彭建福"
  5671. struct3505.PharPracCertNo = "D445281006261"
  5672. }
  5673. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5674. struct3505.SetlId = order.SetlId
  5675. struct3505.MdtrtSn = order.MdtrtId
  5676. struct3505.ManuLotnum = drug.Number
  5677. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5678. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5679. struct3505.RxFlag = "1"
  5680. struct3505.TrdnFlag = "0"
  5681. struct3505.RtalDocno = order.Number
  5682. struct3505.PsnCertType = "01"
  5683. struct3505.CertNo = order.Certno
  5684. struct3505.PsnNo = order.PsnNo
  5685. struct3505.PsnName = order.PsnName
  5686. struct3505.Url = miConfig.Url
  5687. struct3505.AppId = miConfig.Cainfo
  5688. struct3505.AppSecret = miConfig.AppSecret
  5689. struct3505.Enckey = miConfig.EncKey
  5690. struct3505.SignKey = miConfig.SignKey
  5691. struct3505.SecretKey = miConfig.SecretKey
  5692. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5693. struct3505.SelRetnCnt = strValue
  5694. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5695. struct3505.SelRetnOpterName = role.UserName
  5696. if order.IsMedicineInsurance == 1 {
  5697. struct3505.MdtrtSetlType = "1"
  5698. } else {
  5699. struct3505.MdtrtSetlType = "2"
  5700. }
  5701. struct3505.OrgName = miConfig.OrgName
  5702. struct3505.AccessKey = miConfig.AccessKey
  5703. struct3505.RequestUrl = miConfig.Url
  5704. struct3505.SecretKey = miConfig.SecretKey
  5705. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5706. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5707. struct3505.Cainfo = miConfig.Cainfo
  5708. struct3505.DrugTracCodg = drug.DrugCode
  5709. if miConfig.MdtrtareaAdmvs == "350500" {
  5710. result1, result2, _ := service.FJyb3505(struct3505)
  5711. return result1, result2
  5712. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5713. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5714. return result1, result2
  5715. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5716. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5717. return result1, result2
  5718. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5719. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5720. return result1, result2
  5721. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5722. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5723. return result1, result2
  5724. } else {
  5725. data := make(map[string]interface{})
  5726. data["struct_3505s"] = struct3505
  5727. client := &http.Client{}
  5728. bytesData, _ := json.Marshal(data)
  5729. var req *http.Request
  5730. if miConfig.MdtrtareaAdmvs == "320830" {
  5731. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5732. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5733. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5734. } else {
  5735. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5736. }
  5737. resp, _ := client.Do(req)
  5738. defer resp.Body.Close()
  5739. body, ioErr := ioutil.ReadAll(resp.Body)
  5740. if ioErr != nil {
  5741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5742. }
  5743. var respJSON map[string]interface{}
  5744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5746. }
  5747. //var resSix10265 ResultSix10265 //1101结果
  5748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5749. result, _ := json.Marshal(respJSON)
  5750. return string(result), ""
  5751. }
  5752. }
  5753. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, role models.UserAdminRole, number string, doc *models.HisDoctorAdviceInfo) (string, string) {
  5754. var struct3506 models.Struct3506
  5755. struct3506.MedListCodg = doc.BaseDrugLib.MedicalInsuranceNumber
  5756. struct3506.FixmedinsHilistId = doc.BaseDrugLib.MedicalInsuranceNumber
  5757. struct3506.FixmedinsHilistName = doc.BaseDrugLib.DrugName
  5758. struct3506.FixmedinsCode = miConfig.Code
  5759. struct3506.Code = miConfig.Code
  5760. struct3506.FixmedinsBchno = number
  5761. struct3506.Opter = role.UserName
  5762. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5763. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5764. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5765. struct3506.MdtrtSn = order.MdtrtId
  5766. struct3506.ExpyEnd = ""
  5767. struct3506.RxFlag = "0"
  5768. if doc.PrescribingNumberUnit != doc.BaseDrugLib.MinUnit {
  5769. struct3506.TrdnFlag = "0"
  5770. } else {
  5771. struct3506.TrdnFlag = "1"
  5772. }
  5773. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 || org_id == 9478 {
  5774. if doc.BaseDrugLib.IsZeroFlag == 1 {
  5775. struct3506.TrdnFlag = "1"
  5776. }
  5777. if doc.BaseDrugLib.IsZeroFlag == 2 {
  5778. struct3506.TrdnFlag = "0"
  5779. }
  5780. }
  5781. struct3506.TrdnFlag = "1"
  5782. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5783. struct3506.SelRetnCnt = strValue
  5784. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5785. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5786. struct3506.SelRetnOpterName = role.UserName
  5787. struct3506.OrgName = miConfig.OrgName
  5788. struct3506.AccessKey = miConfig.AccessKey
  5789. struct3506.RequestUrl = miConfig.Url
  5790. struct3506.SecretKey = miConfig.SecretKey
  5791. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5792. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5793. struct3506.Url = miConfig.Url
  5794. struct3506.AppId = miConfig.Cainfo
  5795. struct3506.AppSecret = miConfig.AppSecret
  5796. struct3506.Enckey = miConfig.EncKey
  5797. struct3506.SignKey = miConfig.SignKey
  5798. struct3506.SecretKey = miConfig.SecretKey
  5799. struct3506.DrugTracCodg = drug.DrugCode
  5800. if miConfig.MdtrtareaAdmvs == "350500" {
  5801. result1, result2, _ := service.FJyb3506(struct3506)
  5802. return result1, result2
  5803. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5804. result1, result2 := service.Gzyb3506(struct3506, struct3506.SecretKey)
  5805. return result1, result2
  5806. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5807. result1, result2 := service.Gdyb3506(struct3506, struct3506.SecretKey)
  5808. return result1, result2
  5809. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5810. result1, result2 := service.JXyb3506(struct3506, struct3506.SecretKey, struct3506.AccessKey, struct3506.RequestUrl)
  5811. return result1, result2
  5812. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5813. result1, result2 := service.JXyb3506(struct3506, struct3506.SecretKey, struct3506.AccessKey, struct3506.RequestUrl)
  5814. return result1, result2
  5815. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5816. result1, result2 := service.AHyb3506(struct3506, struct3506.SecretKey, struct3506.RequestUrl)
  5817. return result1, result2
  5818. } else if miConfig.MdtrtareaAdmvs == "150404" {
  5819. data := make(map[string]interface{})
  5820. data["struct_3506s"] = struct3506
  5821. client := &http.Client{}
  5822. bytesData, _ := json.Marshal(data)
  5823. var req *http.Request
  5824. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3506", bytes.NewReader(bytesData))
  5825. resp, _ := client.Do(req)
  5826. defer resp.Body.Close()
  5827. body, ioErr := ioutil.ReadAll(resp.Body)
  5828. if ioErr != nil {
  5829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5830. }
  5831. var respJSON map[string]interface{}
  5832. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5834. }
  5835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5836. result, _ := json.Marshal(respJSON)
  5837. return string(result), ""
  5838. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5839. data := make(map[string]interface{})
  5840. data["struct_3506s"] = struct3506
  5841. client := &http.Client{}
  5842. bytesData, _ := json.Marshal(data)
  5843. var req *http.Request
  5844. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3506", bytes.NewReader(bytesData))
  5845. resp, _ := client.Do(req)
  5846. defer resp.Body.Close()
  5847. body, ioErr := ioutil.ReadAll(resp.Body)
  5848. if ioErr != nil {
  5849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5850. }
  5851. var respJSON map[string]interface{}
  5852. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5854. }
  5855. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5856. if status == "0" {
  5857. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5858. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5859. }
  5860. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5861. result, _ := json.Marshal(respJSON)
  5862. return string(result), ""
  5863. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5864. result1, result2 := service.Hnyb3506(struct3506)
  5865. return result1, result2
  5866. } else {
  5867. data := make(map[string]interface{})
  5868. data["struct_3506s"] = struct3506
  5869. client := &http.Client{}
  5870. bytesData, _ := json.Marshal(data)
  5871. var req *http.Request
  5872. if miConfig.MdtrtareaAdmvs == "320830" {
  5873. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5874. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5875. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5876. } else {
  5877. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5878. }
  5879. resp, _ := client.Do(req)
  5880. defer resp.Body.Close()
  5881. body, ioErr := ioutil.ReadAll(resp.Body)
  5882. if ioErr != nil {
  5883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5884. }
  5885. var respJSON map[string]interface{}
  5886. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5888. }
  5889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5890. result, _ := json.Marshal(respJSON)
  5891. return string(result), ""
  5892. }
  5893. }
  5894. func (c *HisApiController) Get1318() {
  5895. adminUser := c.GetAdminUserInfo()
  5896. admin_user_id, _ := c.GetInt64("admin_user_id")
  5897. code := c.GetString("code")
  5898. code = ""
  5899. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5900. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5901. api := ""
  5902. if miConfig.MdtrtareaAdmvs == "320830" {
  5903. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5904. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5905. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5906. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5907. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5908. } else {
  5909. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5910. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5911. }
  5912. resp, requestErr := http.Get(api)
  5913. if requestErr != nil {
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. body, ioErr := ioutil.ReadAll(resp.Body)
  5918. if ioErr != nil {
  5919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. return
  5922. }
  5923. var respJSON map[string]interface{}
  5924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5927. return
  5928. }
  5929. //var res Result2406
  5930. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5931. result, _ := json.Marshal(respJSON)
  5932. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5933. utils.ErrorLog("解析失败:%v", err)
  5934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5935. return
  5936. }
  5937. if res.Infcode == "0" {
  5938. c.ServeSuccessJSON(map[string]interface{}{
  5939. "result": "",
  5940. })
  5941. } else {
  5942. c.ServeSuccessJSON(map[string]interface{}{
  5943. "failed_code": -10,
  5944. "msg": res.ErrMsg,
  5945. })
  5946. */return
  5947. //}
  5948. }
  5949. func (c *HisApiController) Get2503() {
  5950. adminUser := c.GetAdminUserInfo()
  5951. admin_user_id, _ := c.GetInt64("admin_user_id")
  5952. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5953. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5954. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5955. }
  5956. func (c *HisApiController) Get2406() {
  5957. id, _ := c.GetInt64("id")
  5958. record_time := c.GetString("record_time")
  5959. his_patient_id, _ := c.GetInt64("his_patient_id")
  5960. admin_user_id, _ := c.GetInt64("admin_user_id")
  5961. diagnosis_id := c.GetString("diagnosis")
  5962. timeLayout := "2006-01-02"
  5963. loc, _ := time.LoadLocation("Local")
  5964. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5965. if err != nil {
  5966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5967. return
  5968. }
  5969. recordDateTime := theTime.Unix()
  5970. adminUser := c.GetAdminUserInfo()
  5971. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5972. var config []*models.HisXtDiagnoseConfig
  5973. for _, item := range diagnosis_ids {
  5974. id, _ := strconv.ParseInt(item, 10, 64)
  5975. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5976. config = append(config, &diagnosisConfig)
  5977. }
  5978. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5979. fmt.Println(his_patient_id)
  5980. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5981. //timestamp := time.Now().Unix()
  5982. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5983. var patientPrescription models.HisPrescriptionInfo
  5984. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5985. if patientPrescription.ID == 0 {
  5986. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5987. }
  5988. var res2 Result2406
  5989. if miConfig.MdtrtareaAdmvs == "341203" {
  5990. data := make(map[string]interface{})
  5991. client := &http.Client{}
  5992. data["psn_no"] = his.PsnNo
  5993. data["mdtrt_id"] = his.Number
  5994. data["operator"] = roles.UserName
  5995. data["cert_no"] = his.IdCardNo
  5996. data["org_name"] = miConfig.OrgName
  5997. data["psn_name"] = his.Name
  5998. data["ipt_otp_no"] = his.IptOtpNo
  5999. data["ipt_psn_sp_flag_type"] = "0901"
  6000. data["ipt_psn_sp_flag"] = "1"
  6001. data["fixmedins_code"] = miConfig.Code
  6002. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6003. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6004. data["url"] = miConfig.Url
  6005. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  6006. bytesData, _ := json.Marshal(data)
  6007. var req *http.Request
  6008. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  6009. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  6010. resp, _ := client.Do(req)
  6011. defer resp.Body.Close()
  6012. body, ioErr := ioutil.ReadAll(resp.Body)
  6013. if ioErr != nil {
  6014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. return
  6017. }
  6018. var respJSON map[string]interface{}
  6019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6022. return
  6023. }
  6024. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6025. if status == "0" {
  6026. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6027. c.ServeSuccessJSON(map[string]interface{}{
  6028. "failed_code": -10,
  6029. "msg": err_msg,
  6030. })
  6031. return
  6032. }
  6033. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6034. userJSONBytes, _ := json.Marshal(respJSON)
  6035. fmt.Println("log")
  6036. fmt.Println(string(userJSONBytes))
  6037. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6038. utils.ErrorLog("解析失败:%v", err)
  6039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6040. return
  6041. }
  6042. } else if miConfig.MdtrtareaAdmvs == "340699" {
  6043. data := make(map[string]interface{})
  6044. client := &http.Client{}
  6045. data["psn_no"] = his.PsnNo
  6046. data["mdtrt_id"] = his.Number
  6047. data["operator"] = roles.UserName
  6048. data["cert_no"] = his.IdCardNo
  6049. data["org_name"] = miConfig.OrgName
  6050. data["psn_name"] = his.Name
  6051. data["ipt_otp_no"] = his.IptOtpNo
  6052. data["ipt_psn_sp_flag_type"] = "0901"
  6053. data["ipt_psn_sp_flag"] = "1"
  6054. data["fixmedins_code"] = miConfig.Code
  6055. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6056. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6057. data["url"] = miConfig.Url
  6058. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  6059. bytesData, _ := json.Marshal(data)
  6060. var req *http.Request
  6061. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  6062. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  6063. resp, _ := client.Do(req)
  6064. defer resp.Body.Close()
  6065. body, ioErr := ioutil.ReadAll(resp.Body)
  6066. if ioErr != nil {
  6067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6069. return
  6070. }
  6071. var respJSON map[string]interface{}
  6072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6075. return
  6076. }
  6077. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6078. if status == "0" {
  6079. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6080. c.ServeSuccessJSON(map[string]interface{}{
  6081. "failed_code": -10,
  6082. "msg": err_msg,
  6083. })
  6084. return
  6085. }
  6086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6087. userJSONBytes, _ := json.Marshal(respJSON)
  6088. fmt.Println("log")
  6089. fmt.Println(string(userJSONBytes))
  6090. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6091. utils.ErrorLog("解析失败:%v", err)
  6092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6093. return
  6094. }
  6095. }
  6096. if res2.Infcode != 0 {
  6097. adminUser := c.GetAdminUserInfo()
  6098. errlog := &models.HisOrderError{
  6099. UserOrgId: adminUser.CurrentOrgId,
  6100. Ctime: time.Now().Unix(),
  6101. Mtime: time.Now().Unix(),
  6102. ErrMsg: res2.ErrMsg,
  6103. Status: 1,
  6104. PatientId: id,
  6105. RecordTime: recordDateTime,
  6106. Stage: 3,
  6107. }
  6108. service.CreateErrMsgLog(errlog)
  6109. c.ServeSuccessJSON(map[string]interface{}{
  6110. "failed_code": -10,
  6111. "msg": res2.ErrMsg,
  6112. })
  6113. return
  6114. } else {
  6115. c.ServeSuccessJSON(map[string]interface{}{
  6116. "msg": "上传成功",
  6117. })
  6118. return
  6119. }
  6120. }
  6121. func (c *HisApiController) Get4105() {
  6122. }
  6123. func (c *HisApiController) Post5302() {
  6124. patient_id, _ := c.GetInt64("id")
  6125. admin_user_id, _ := c.GetInt64("admin_user_id")
  6126. p, _ := service.GetHisPatientById(patient_id)
  6127. adminUser := c.GetAdminUserInfo()
  6128. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6129. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6130. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6131. }
  6132. func (c *HisApiController) Get4104() {
  6133. }
  6134. type Output struct {
  6135. CertNo string `json:"certno"`
  6136. PsnName string `json:"psn_name"`
  6137. CardNo string `json:"card_no"`
  6138. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6139. CardSN string `json:"card_sn"`
  6140. PsnCertType string `json:"psn_cert_type"`
  6141. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6142. MdtrtCertType string `json:"mdtrt_cert_type"`
  6143. QRCode string `json:"qrCode"`
  6144. EcToken string `json:"ecToken"`
  6145. }
  6146. type AHResponse struct {
  6147. Body AHBody `json:"body"`
  6148. Code int `json:"code"`
  6149. CSBCode int `json:"csbCode"`
  6150. Message string `json:"message"`
  6151. RequestID string `json:"requestId"`
  6152. State struct{} `json:"state"`
  6153. }
  6154. type AHBody struct {
  6155. ErrMsg string `json:"err_msg"`
  6156. InfRefMsgID string `json:"inf_refmsgid"`
  6157. InfCode int `json:"infcode"`
  6158. Output struct {
  6159. Result []struct {
  6160. BasMednFlag string `json:"bas_medn_flag"`
  6161. ChldMedcFlag string `json:"chld_medc_flag"`
  6162. ChrgitmLv string `json:"chrgitm_lv"`
  6163. Cnt float64 `json:"cnt"`
  6164. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6165. DrtReimFlag string `json:"drt_reim_flag"`
  6166. FeedetlSn string `json:"feedetl_sn"`
  6167. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6168. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6169. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6170. ListSpItemFlag string `json:"list_sp_item_flag"`
  6171. LmtUsedFlag string `json:"lmt_used_flag"`
  6172. MedChrgitmType string `json:"med_chrgitm_type"`
  6173. Memo string `json:"memo"`
  6174. OverlmtAmt float64 `json:"overlmt_amt"`
  6175. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6176. Pric float64 `json:"pric"`
  6177. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6178. SelfpayProp float64 `json:"selfpay_prop"`
  6179. } `json:"result"`
  6180. } `json:"output"`
  6181. }
  6182. type Response struct {
  6183. Output Output `json:"output"`
  6184. Infcode int `json:"infcode"`
  6185. InfRefMsgID string `json:"inf_refmsgid"`
  6186. RefMsgTime string `json:"refmsg_time"`
  6187. RespondTime string `json:"respond_time"`
  6188. ErrMsg string `json:"err_msg"`
  6189. WarnMsg string `json:"warn_msg"`
  6190. SignType string `json:"signtype"`
  6191. CAInfo string `json:"cainfo"`
  6192. }
  6193. func (c *HisApiController) Getquerydata() {
  6194. query_type, _ := c.GetInt64("type")
  6195. refd_setl_flag := c.GetString("refd_setl_flag")
  6196. med_type := c.GetString("med_type")
  6197. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6198. cert_no := c.GetString("cert_no")
  6199. psn_no := c.GetString("psn_no")
  6200. start_time := c.GetString("start_time")
  6201. end_time := c.GetString("end_time")
  6202. page, _ := c.GetInt64("page")
  6203. limit, _ := c.GetInt64("limit")
  6204. var bp models.BusinessParams5262
  6205. bp.RefdSetlFlag = refd_setl_flag
  6206. bp.MedType = med_type
  6207. bp.Certno = cert_no
  6208. bp.Psnno = psn_no
  6209. bp.QBegntime = start_time
  6210. bp.QEndtime = end_time
  6211. if query_type == 1 { //本地
  6212. Post5262(c, bp, page, limit)
  6213. } else { //异地
  6214. Post5267(c, bp, page, limit)
  6215. }
  6216. }
  6217. func (c *HisApiController) Drugscheck() {
  6218. admin_user_id, _ := c.GetInt64("admin_user_id")
  6219. adminUser := c.GetAdminUserInfo()
  6220. var queryResult []QueryResult
  6221. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6222. for _, item := range drugs {
  6223. result := QueryResult{
  6224. ID: item.ID,
  6225. Name: item.DrugName,
  6226. Code: item.MedicalInsuranceNumber,
  6227. List_type_code: "101",
  6228. }
  6229. queryResult = append(queryResult, result)
  6230. }
  6231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6232. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6233. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6234. for _, item := range queryResult {
  6235. 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)
  6236. }
  6237. }
  6238. func (c *HisApiController) Goodcheck() {
  6239. admin_user_id, _ := c.GetInt64("admin_user_id")
  6240. adminUser := c.GetAdminUserInfo()
  6241. var queryResult []QueryResult
  6242. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6243. for _, item := range goods {
  6244. result := QueryResult{
  6245. ID: item.ID,
  6246. Name: item.GoodName,
  6247. Code: item.SocialSecurityDirectoryCode,
  6248. List_type_code: "301",
  6249. }
  6250. queryResult = append(queryResult, result)
  6251. }
  6252. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6253. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6254. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6255. for _, item := range queryResult {
  6256. 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)
  6257. //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)
  6258. }
  6259. }
  6260. func (c *HisApiController) Projectcheck() {
  6261. admin_user_id, _ := c.GetInt64("admin_user_id")
  6262. adminUser := c.GetAdminUserInfo()
  6263. var queryResult []QueryResult
  6264. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6265. for _, item := range projects {
  6266. result := QueryResult{
  6267. ID: item.ID,
  6268. Name: item.ProjectName,
  6269. Code: item.MedicalCode,
  6270. List_type_code: "201",
  6271. }
  6272. queryResult = append(queryResult, result)
  6273. }
  6274. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6275. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6276. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6277. for _, item := range queryResult {
  6278. 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)
  6279. }
  6280. }
  6281. //func (c *HisApiController)CancleDia(){
  6282. //
  6283. // id, _ := c.GetInt64("id")
  6284. // record_time := c.GetString("record_time")
  6285. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6286. //
  6287. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6288. //
  6289. // diagnosis_id := c.GetString("diagnosis")
  6290. // sick_type, _ := c.GetInt64("sick_type")
  6291. // reg_type, _ := c.GetInt64("p_type")
  6292. // begin_time := c.GetString("begin_time")
  6293. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6294. //
  6295. //
  6296. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6297. //
  6298. // fmt.Println(acct_used_flag)
  6299. //
  6300. //
  6301. // timeLayout := "2006-01-02"
  6302. // loc, _ := time.LoadLocation("Local")
  6303. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6304. // if err != nil {
  6305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6306. // return
  6307. // }
  6308. // recordDateTime := theTime.Unix()
  6309. // adminUser := c.GetAdminUserInfo()
  6310. //
  6311. //
  6312. //
  6313. //
  6314. //
  6315. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6316. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6317. // var patientPrescription models.HisPrescriptionInfo
  6318. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6319. // if patientPrescription.ID == 0 {
  6320. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6321. // }
  6322. // //if patientPrescription.Do
  6323. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6324. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6325. //
  6326. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6327. //
  6328. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6329. //
  6330. // var config []*models.HisXtDiagnoseConfig
  6331. // for _, item := range diagnosis_ids {
  6332. // id, _ := strconv.ParseInt(item, 10, 64)
  6333. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6334. // config = append(config, &diagnosisConfig)
  6335. // }
  6336. //
  6337. // sickConfig, _ := service.FindSickById(sick_type)
  6338. //
  6339. //
  6340. // data := make(map[string]interface{})
  6341. // client := &http.Client{}
  6342. // data["psn_no"] = his.PsnNo
  6343. // data["mdtrt_id"] = his.Number
  6344. // data["doctor"] = roles.UserName
  6345. // data["department"] = department.Name
  6346. // data["org_name"] = miConfig.OrgName
  6347. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6348. // data["doctor_id"] = doctor_info.DoctorNumber
  6349. // data["new_doctor_name"] = doctor_info.UserName
  6350. // data["fixmedins_code"] = miConfig.Code
  6351. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6352. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6353. // data["secret_key"] = miConfig.SecretKey
  6354. // data["sick_code"] = sickConfig.CountryCode
  6355. // data["sick_name"] = sickConfig.ClassName
  6356. // data["url"] = miConfig.Url
  6357. // data["ak"] = miConfig.AccessKey
  6358. // data["begin_time"] = begin_time
  6359. // data["cainfo"] = miConfig.Cainfo
  6360. // data["is_vaild"] = "0"
  6361. //
  6362. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6363. // data["config"] = config
  6364. // bytesData, _ := json.Marshal(data)
  6365. //
  6366. // var req *http.Request
  6367. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6368. // resp, _ := client.Do(req)
  6369. // defer resp.Body.Close()
  6370. // body, ioErr := ioutil.ReadAll(resp.Body)
  6371. // if ioErr != nil {
  6372. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. // return
  6375. // }
  6376. // var respJSON map[string]interface{}
  6377. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6380. // return
  6381. // }
  6382. //
  6383. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6384. // userJSONBytes, _ := json.Marshal(respJSON)
  6385. // fmt.Println("log")
  6386. // fmt.Println(string(userJSONBytes))
  6387. //
  6388. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6389. // utils.ErrorLog("解析失败:%v", err)
  6390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6391. // return
  6392. // }
  6393. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6394. // res2.Output = ressix10265.Output
  6395. // res2.ErrMsg = ressix10265.ErrMsg
  6396. // res2.Cainfo = ressix10265.Cainfo
  6397. // res2.WarnMsg = ressix10265.WarnMsg
  6398. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6399. // res2.Infcode = infocode
  6400. //
  6401. //}
  6402. func (c *HisApiController) Get4102() {
  6403. order_id, _ := c.GetInt64("order_id")
  6404. admin_user_id, _ := c.GetInt64("admin_user_id")
  6405. stas_type := c.GetString("stas_type")
  6406. order, _ := service.GetHisOrderByIDTwo(order_id)
  6407. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6408. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6409. var pp models.PublicParams
  6410. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6411. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6412. pp.FixmedinsName = miConfig.OrgName
  6413. pp.FixmedinsCode = miConfig.Code
  6414. pp.RequestUrl = miConfig.Url
  6415. pp.Cainfo = miConfig.Cainfo
  6416. pp.SecretKey = miConfig.SecretKey
  6417. pp.AccessKey = miConfig.AccessKey
  6418. pp.OpterName = curRoles.UserName
  6419. if miConfig.MdtrtareaAdmvs == "350500" {
  6420. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6421. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6422. saveLog(result, request, "4102", "清单确认")
  6423. var dat map[string]interface{}
  6424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6425. fmt.Println(dat)
  6426. } else {
  6427. fmt.Println(err)
  6428. }
  6429. var empty ResultFourteen
  6430. userJSONBytes, _ := json.Marshal(dat)
  6431. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6432. utils.ErrorLog("解析失败:%v", err)
  6433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6434. return
  6435. }
  6436. if empty.Infcode == 0 {
  6437. c.ServeSuccessJSON(map[string]interface{}{
  6438. "msg": "确认成功",
  6439. })
  6440. return
  6441. }
  6442. } else {
  6443. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6444. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6445. result3, request3 := service.Jxyb4105(pp)
  6446. saveLog(result, request, "4102", "清单确认")
  6447. saveLog(result2, request2, "4103", "清单确认")
  6448. saveLog(result3, request3, "4105", "清单统计")
  6449. var dat map[string]interface{}
  6450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6451. fmt.Println(dat)
  6452. } else {
  6453. fmt.Println(err)
  6454. }
  6455. var empty ResultFourteen
  6456. userJSONBytes, _ := json.Marshal(dat)
  6457. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6458. utils.ErrorLog("解析失败:%v", err)
  6459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6460. return
  6461. }
  6462. if empty.Infcode == 0 {
  6463. c.ServeSuccessJSON(map[string]interface{}{
  6464. "msg": "确认成功",
  6465. })
  6466. return
  6467. }
  6468. }
  6469. }
  6470. // 对账权限查询
  6471. func (c *HisApiController) Get3260() {
  6472. admin_user_id, _ := c.GetInt64("admin_user_id")
  6473. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6474. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6475. var api string
  6476. var res models.JSResult3260
  6477. if miConfig.MdtrtareaAdmvs == "320830" {
  6478. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6479. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6480. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6481. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6482. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6483. } else {
  6484. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6485. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6486. }
  6487. resp, requestErr := http.Get(api)
  6488. if requestErr != nil {
  6489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6490. return
  6491. }
  6492. body, ioErr := ioutil.ReadAll(resp.Body)
  6493. if ioErr != nil {
  6494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6496. return
  6497. }
  6498. var respJSON map[string]interface{}
  6499. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6502. return
  6503. }
  6504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6505. result, _ := json.Marshal(respJSON)
  6506. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6507. utils.ErrorLog("解析失败:%v", err)
  6508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6509. return
  6510. }
  6511. if res.Infcode == "0" {
  6512. c.ServeSuccessJSON(map[string]interface{}{
  6513. "result": res.Output.Data,
  6514. })
  6515. } else {
  6516. c.ServeSuccessJSON(map[string]interface{}{
  6517. "failed_code": -10,
  6518. "msg": res.ErrMsg,
  6519. })
  6520. return
  6521. }
  6522. }
  6523. func (c *HisApiController) Get3261() {
  6524. admin_user_id, _ := c.GetInt64("admin_user_id")
  6525. //month := c.GetString("month")
  6526. startTime := c.GetString("start_time")
  6527. //endTime, _ := c.GetString("end_time")
  6528. times := strings.Split(startTime, "-")
  6529. stmt_mon := times[0] + times[1]
  6530. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6531. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6532. var api string
  6533. var res models.JSResult3261
  6534. //var res10265 Result5301For10265
  6535. if miConfig.MdtrtareaAdmvs == "320830" {
  6536. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6537. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6538. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6539. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6540. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6541. } else {
  6542. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6543. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6544. }
  6545. resp, requestErr := http.Get(api)
  6546. if requestErr != nil {
  6547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6548. return
  6549. }
  6550. body, ioErr := ioutil.ReadAll(resp.Body)
  6551. if ioErr != nil {
  6552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. return
  6555. }
  6556. var respJSON map[string]interface{}
  6557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6560. return
  6561. }
  6562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6563. result, _ := json.Marshal(respJSON)
  6564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6565. utils.ErrorLog("解析失败:%v", err)
  6566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6567. return
  6568. }
  6569. if res.Infcode == "0" {
  6570. c.ServeSuccessJSON(map[string]interface{}{
  6571. "result": res.Output,
  6572. })
  6573. } else {
  6574. c.ServeSuccessJSON(map[string]interface{}{
  6575. "failed_code": -10,
  6576. "msg": res.ErrMsg,
  6577. })
  6578. return
  6579. }
  6580. }
  6581. type TempFun struct {
  6582. FundKey string
  6583. FundCode string
  6584. }
  6585. func (c *HisApiController) Get3262() {
  6586. admin_user_id, _ := c.GetInt64("admin_user_id")
  6587. startTime := c.GetString("start_time")
  6588. endTime := c.GetString("end_time")
  6589. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6590. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6591. //timeLayout := "2006-01-02"
  6592. //loc, _ := time.LoadLocation("Local")
  6593. //var theStartTIme int64
  6594. //if len(startTime) > 0 {
  6595. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6596. // if err != nil {
  6597. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6598. // return
  6599. // }
  6600. // theStartTIme = theTime.Unix()
  6601. //}
  6602. //var theEndtTIme int64
  6603. //if len(endTime) > 0 {
  6604. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6605. // if err != nil {
  6606. // utils.ErrorLog(err.Error())
  6607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6608. // return
  6609. // }
  6610. // theEndtTIme = theTime.Unix()
  6611. //}
  6612. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6613. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6614. for _, team := range datas {
  6615. fmt.Println(team.PsnTime)
  6616. for _, team_two := range datas_two {
  6617. fmt.Println(team_two.PsnTime)
  6618. if team.FundKey == team_two.FundKey {
  6619. fmt.Println(team_two.PsnTime)
  6620. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6621. fmt.Println(team.PsnTime)
  6622. }
  6623. }
  6624. }
  6625. fmt.Println("1111")
  6626. fmt.Println(datas)
  6627. fmt.Println("1111")
  6628. var twos []models.FixMonRecDetailFileInTwo
  6629. for _, team := range datas {
  6630. var two models.FixMonRecDetailFileInTwo
  6631. two.MedType = team.MedType
  6632. two.Insutype = team.Insutype
  6633. two.PsnType = team.PsnType
  6634. two.MedType = team.MedType
  6635. two.FixBlngAdmdvs = "999999"
  6636. two.InsuAdmdvs = "555555"
  6637. two.PsnTime = team.PsnTime
  6638. two.PsnCnt = team.PsnCnt
  6639. two.FundKey = team.FundKey
  6640. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6641. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6642. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6643. two.MedfeeSumAmt = ms
  6644. two.InscpAmt = ia
  6645. two.FundPaySumAmt = fps
  6646. twos = append(twos, two)
  6647. }
  6648. //startTime := c.GetString("start_time")
  6649. //endTime, _ := c.GetString("end_time")
  6650. times := strings.Split(startTime, "-")
  6651. stmt_mon := times[0] + times[1]
  6652. var funs []models.FundDetail
  6653. for _, item := range datas {
  6654. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6655. funs = append(funs, fun...)
  6656. }
  6657. var funInfos []models.Fund
  6658. //for _, item := range funs {
  6659. // var rf []models.FundInfo
  6660. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6661. // for _, subitem := range rf {
  6662. // var fund models.Fund
  6663. // fund.FundCode = subitem.FundPayType
  6664. // fund.FundName = subitem.FundPayTypeName
  6665. // fund.FundAmt = subitem.FundPayAmt
  6666. // fund.FundKey = item.FundKey
  6667. // fund.InsuAdmdvs = "555555"
  6668. // fund.FixBlngAdmdvs = "999999"
  6669. // funInfos = append(funInfos, fund)
  6670. // }
  6671. //}
  6672. var tempFuns []TempFun
  6673. for _, funInfo := range funInfos {
  6674. var tempFun TempFun
  6675. tempFun.FundKey = funInfo.FundKey
  6676. tempFun.FundCode = funInfo.FundCode
  6677. tempFuns = append(tempFuns, tempFun)
  6678. }
  6679. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6680. fmt.Println(tempFuns)
  6681. var funInfosTwo []models.Fund
  6682. decimal.DivisionPrecision = 2
  6683. for _, item := range tempFuns {
  6684. var fund models.Fund
  6685. for _, subItem := range funInfos {
  6686. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6687. fund.FundKey = subItem.FundKey
  6688. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6689. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6690. fund.FundName = subItem.FundName
  6691. fund.FundCode = subItem.FundCode
  6692. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6693. }
  6694. }
  6695. funInfosTwo = append(funInfosTwo, fund)
  6696. }
  6697. fmt.Println("funInfosTwo")
  6698. fmt.Println(funInfosTwo)
  6699. var upld_btch string
  6700. var empty models.JSResultEmpty
  6701. data := make(map[string]interface{})
  6702. data["org_name"] = miConfig.OrgName
  6703. data["doctor"] = curRoles.UserName
  6704. data["doctor_name"] = curRoles.UserName
  6705. data["fixmedins_code"] = miConfig.Code
  6706. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6707. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6708. data["secret_key"] = miConfig.SecretKey
  6709. data["url"] = miConfig.Url
  6710. data["ak"] = miConfig.AccessKey
  6711. data["cainfo"] = miConfig.Cainfo
  6712. data["datas"] = twos
  6713. data["fund"] = funInfosTwo
  6714. fmt.Println(twos)
  6715. month := time.Unix(1557042972, 0).Format("1")
  6716. year := time.Now().Format("2006")
  6717. month = time.Now().Format("01")
  6718. day := time.Now().Format("02")
  6719. hour := time.Now().Format("15")
  6720. min := time.Now().Format("04")
  6721. sec := time.Now().Format("05")
  6722. fix_fill_date := year + month + day + hour + min + sec
  6723. data["fix_fill_dept"] = miConfig.OrgName
  6724. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6725. data["fix_fill_psn"] = curRoles.UserName
  6726. data["fix_fill_date"] = fix_fill_date
  6727. data["stmt_loc"] = "2"
  6728. data["setl_mon"] = stmt_mon
  6729. upld_btch = "0"
  6730. data["upld_btch"] = upld_btch
  6731. //fmt.Println(data)
  6732. client := &http.Client{}
  6733. bytesData, _ := json.Marshal(data)
  6734. var req *http.Request
  6735. if miConfig.MdtrtareaAdmvs == "320830" {
  6736. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6737. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6738. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6739. } else {
  6740. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6741. }
  6742. resp, _ := client.Do(req)
  6743. defer resp.Body.Close()
  6744. body, ioErr := ioutil.ReadAll(resp.Body)
  6745. if ioErr != nil {
  6746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6748. }
  6749. var respJSON map[string]interface{}
  6750. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6753. }
  6754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6755. //fmt.Println(respJSON)
  6756. result, _ := json.Marshal(respJSON)
  6757. //fmt.Println(result)
  6758. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6759. utils.ErrorLog("解析失败:%v", err)
  6760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6761. }
  6762. if empty.Infcode != "0" {
  6763. c.ServeSuccessJSON(map[string]interface{}{
  6764. "failed_code": -10,
  6765. "msg": empty.ErrMsg,
  6766. })
  6767. return
  6768. } else {
  6769. c.ServeSuccessJSON(map[string]interface{}{
  6770. "msg": "上传成功",
  6771. })
  6772. return
  6773. }
  6774. }
  6775. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6776. newArr = make([]TempFun, 0)
  6777. for i := 0; i < len(arr); i++ {
  6778. repeat := false
  6779. for j := i + 1; j < len(arr); j++ {
  6780. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6781. repeat = true
  6782. break
  6783. }
  6784. }
  6785. if !repeat {
  6786. newArr = append(newArr, arr[i])
  6787. }
  6788. }
  6789. return
  6790. }
  6791. func (c *HisApiController) Get3263() {
  6792. admin_user_id, _ := c.GetInt64("admin_user_id")
  6793. startTime := c.GetString("start_time")
  6794. //endTime, _ := c.GetString("end_time")
  6795. times := strings.Split(startTime, "-")
  6796. setl_mon := times[0] + times[1]
  6797. upld_btch := "0"
  6798. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6799. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6800. var result3263 models.JSResult3263
  6801. data := make(map[string]interface{})
  6802. data["org_name"] = miConfig.OrgName
  6803. data["doctor"] = curRoles.UserName
  6804. data["doctor_name"] = curRoles.UserName
  6805. data["fixmedins_code"] = miConfig.Code
  6806. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6807. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6808. data["secret_key"] = miConfig.SecretKey
  6809. data["url"] = miConfig.Url
  6810. data["ak"] = miConfig.AccessKey
  6811. data["cainfo"] = miConfig.Cainfo
  6812. data["setl_mon"] = setl_mon
  6813. data["stmt_loc"] = "2"
  6814. data["upld_btch"] = upld_btch
  6815. client := &http.Client{}
  6816. bytesData, _ := json.Marshal(data)
  6817. var req *http.Request
  6818. if miConfig.MdtrtareaAdmvs == "320830" {
  6819. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6820. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6821. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6822. } else {
  6823. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6824. }
  6825. resp, _ := client.Do(req)
  6826. defer resp.Body.Close()
  6827. body, ioErr := ioutil.ReadAll(resp.Body)
  6828. if ioErr != nil {
  6829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6831. }
  6832. var respJSON map[string]interface{}
  6833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6836. }
  6837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6838. fmt.Println(respJSON)
  6839. result, _ := json.Marshal(respJSON)
  6840. fmt.Println(result)
  6841. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6842. utils.ErrorLog("解析失败:%v", err)
  6843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6844. }
  6845. if result3263.Infcode != "0" {
  6846. c.ServeSuccessJSON(map[string]interface{}{
  6847. "failed_code": -10,
  6848. "msg": result3263.ErrMsg,
  6849. })
  6850. return
  6851. } else {
  6852. c.ServeSuccessJSON(map[string]interface{}{
  6853. "list": result3263.Output,
  6854. })
  6855. return
  6856. }
  6857. }
  6858. func (c *HisApiController) Get3264() {
  6859. admin_user_id, _ := c.GetInt64("admin_user_id")
  6860. startTime := c.GetString("start_time")
  6861. //endTime, _ := c.GetString("end_time")
  6862. times := strings.Split(startTime, "-")
  6863. setl_mon := times[0] + times[1]
  6864. upld_btch := "0"
  6865. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6866. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6867. //solidify_id := []
  6868. var result3263 models.JSResult3263
  6869. data := make(map[string]interface{})
  6870. data["org_name"] = miConfig.OrgName
  6871. data["doctor"] = curRoles.UserName
  6872. data["doctor_name"] = curRoles.UserName
  6873. data["fixmedins_code"] = miConfig.Code
  6874. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6875. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6876. data["secret_key"] = miConfig.SecretKey
  6877. data["url"] = miConfig.Url
  6878. data["ak"] = miConfig.AccessKey
  6879. data["cainfo"] = miConfig.Cainfo
  6880. data["setl_mon"] = setl_mon
  6881. data["stmt_loc"] = "2"
  6882. data["upld_btch"] = upld_btch
  6883. client := &http.Client{}
  6884. bytesData, _ := json.Marshal(data)
  6885. var req3263 *http.Request
  6886. if miConfig.MdtrtareaAdmvs == "320830" {
  6887. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6888. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6889. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6890. } else {
  6891. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6892. }
  6893. resp, _ := client.Do(req3263)
  6894. defer resp.Body.Close()
  6895. body, ioErr := ioutil.ReadAll(resp.Body)
  6896. if ioErr != nil {
  6897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6899. }
  6900. var respJSON3263 map[string]interface{}
  6901. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6904. }
  6905. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6906. fmt.Println(respJSON3263)
  6907. result, _ := json.Marshal(respJSON3263)
  6908. fmt.Println(result)
  6909. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6910. utils.ErrorLog("解析失败:%v", err)
  6911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6912. }
  6913. var ids []string
  6914. for _, item := range result3263.Output {
  6915. ids = append(ids, item.SolidifyID)
  6916. }
  6917. var empty models.JSResultEmpty
  6918. data2 := make(map[string]interface{})
  6919. data2["org_name"] = miConfig.OrgName
  6920. data2["doctor"] = curRoles.UserName
  6921. data2["doctor_name"] = curRoles.UserName
  6922. data2["fixmedins_code"] = miConfig.Code
  6923. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6924. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6925. data2["secret_key"] = miConfig.SecretKey
  6926. data2["url"] = miConfig.Url
  6927. data2["ak"] = miConfig.AccessKey
  6928. data2["cainfo"] = miConfig.Cainfo
  6929. data2["setl_mon"] = setl_mon
  6930. data2["stmt_loc"] = "2"
  6931. data2["upld_btch"] = upld_btch
  6932. data2["solidify_id"] = ids
  6933. client2 := &http.Client{}
  6934. bytesData2, _ := json.Marshal(data2)
  6935. var req *http.Request
  6936. if miConfig.MdtrtareaAdmvs == "320830" {
  6937. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6938. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6939. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6940. } else {
  6941. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6942. }
  6943. resp2, _ := client2.Do(req)
  6944. defer resp.Body.Close()
  6945. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6946. if ioErr2 != nil {
  6947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. }
  6950. var respJSON map[string]interface{}
  6951. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6954. }
  6955. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6956. fmt.Println(respJSON)
  6957. result2, _ := json.Marshal(respJSON)
  6958. fmt.Println(result2)
  6959. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6960. utils.ErrorLog("解析失败:%v", err)
  6961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6962. }
  6963. if empty.Infcode != "0" {
  6964. c.ServeSuccessJSON(map[string]interface{}{
  6965. "failed_code": -10,
  6966. "msg": empty.ErrMsg,
  6967. })
  6968. return
  6969. } else {
  6970. c.ServeSuccessJSON(map[string]interface{}{
  6971. "msg": "",
  6972. })
  6973. return
  6974. }
  6975. }
  6976. func (c *HisApiController) Get3265() {
  6977. admin_user_id, _ := c.GetInt64("admin_user_id")
  6978. startTime := c.GetString("start_time")
  6979. //endTime, _ := c.GetString("end_time")
  6980. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6981. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6982. times := strings.Split(startTime, "-")
  6983. setl_mon := times[0] + times[1]
  6984. var upld_btch string
  6985. upld_btch = "0"
  6986. //var empty models.JSResultEmpty
  6987. var result3265 models.JSResult3264
  6988. var result3263 models.JSResult3263
  6989. data2 := make(map[string]interface{})
  6990. data2["org_name"] = miConfig.OrgName
  6991. data2["doctor"] = curRoles.UserName
  6992. data2["doctor_name"] = curRoles.UserName
  6993. data2["fixmedins_code"] = miConfig.Code
  6994. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6995. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6996. data2["secret_key"] = miConfig.SecretKey
  6997. data2["url"] = miConfig.Url
  6998. data2["ak"] = miConfig.AccessKey
  6999. data2["cainfo"] = miConfig.Cainfo
  7000. data2["setl_mon"] = setl_mon
  7001. data2["stmt_loc"] = "2"
  7002. data2["upld_btch"] = upld_btch
  7003. client2 := &http.Client{}
  7004. bytesData2, _ := json.Marshal(data2)
  7005. var req3263 *http.Request
  7006. if miConfig.MdtrtareaAdmvs == "320830" {
  7007. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  7008. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7009. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  7010. } else {
  7011. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  7012. }
  7013. resp2, _ := client2.Do(req3263)
  7014. defer resp2.Body.Close()
  7015. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7016. if ioErr2 != nil {
  7017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7019. }
  7020. var respJSON3263 map[string]interface{}
  7021. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7024. }
  7025. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7026. fmt.Println(respJSON3263)
  7027. result2, _ := json.Marshal(respJSON3263)
  7028. fmt.Println(result2)
  7029. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7030. utils.ErrorLog("解析失败:%v", err)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. }
  7033. var ids []string
  7034. for _, item := range result3263.Output {
  7035. ids = append(ids, item.SolidifyID)
  7036. }
  7037. data := make(map[string]interface{})
  7038. data["org_name"] = miConfig.OrgName
  7039. data["doctor"] = curRoles.UserName
  7040. data["doctor_name"] = curRoles.UserName
  7041. data["fixmedins_code"] = miConfig.Code
  7042. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7043. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7044. data["secret_key"] = miConfig.SecretKey
  7045. data["url"] = miConfig.Url
  7046. data["ak"] = miConfig.AccessKey
  7047. data["cainfo"] = miConfig.Cainfo
  7048. data["setl_mon"] = setl_mon
  7049. data["solidify_id"] = ids
  7050. month := time.Unix(1557042972, 0).Format("1")
  7051. year := time.Now().Format("2006")
  7052. month = time.Now().Format("01")
  7053. day := time.Now().Format("02")
  7054. hour := time.Now().Format("15")
  7055. min := time.Now().Format("04")
  7056. sec := time.Now().Format("05")
  7057. fix_fill_date := year + month + day + hour + min + sec
  7058. data["fix_fill_dept"] = miConfig.OrgName
  7059. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7060. data["fix_fill_psn"] = curRoles.UserName
  7061. data["fix_fill_date"] = fix_fill_date
  7062. data["stmt_loc"] = "2"
  7063. data["upld_btch"] = upld_btch
  7064. client := &http.Client{}
  7065. bytesData, _ := json.Marshal(data)
  7066. var req *http.Request
  7067. if miConfig.MdtrtareaAdmvs == "320830" {
  7068. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  7069. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7070. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  7071. } else {
  7072. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  7073. }
  7074. resp, _ := client.Do(req)
  7075. defer resp.Body.Close()
  7076. body, ioErr := ioutil.ReadAll(resp.Body)
  7077. if ioErr != nil {
  7078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7080. }
  7081. var respJSON map[string]interface{}
  7082. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7085. }
  7086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7087. fmt.Println(respJSON)
  7088. result, _ := json.Marshal(respJSON)
  7089. fmt.Println(result)
  7090. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7091. utils.ErrorLog("解析失败:%v", err)
  7092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. }
  7094. if result3265.Infcode != "0" {
  7095. c.ServeSuccessJSON(map[string]interface{}{
  7096. "failed_code": -10,
  7097. "msg": result3265.ErrMsg,
  7098. })
  7099. return
  7100. } else {
  7101. c.ServeSuccessJSON(map[string]interface{}{
  7102. "info": result3265.Output,
  7103. })
  7104. return
  7105. }
  7106. }
  7107. func (c *HisApiController) Get3266() {
  7108. admin_user_id, _ := c.GetInt64("admin_user_id")
  7109. startTime := c.GetString("start_time")
  7110. //endTime, _ := c.GetString("end_time")
  7111. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7112. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7113. times := strings.Split(startTime, "-")
  7114. stmt_mon := times[0] + times[1]
  7115. var upld_btch string
  7116. //var empty models.JSResultEmpty
  7117. var result3265 models.JSResult3264
  7118. data := make(map[string]interface{})
  7119. data["org_name"] = miConfig.OrgName
  7120. data["doctor"] = curRoles.UserName
  7121. data["doctor_name"] = curRoles.UserName
  7122. data["fixmedins_code"] = miConfig.Code
  7123. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7124. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7125. data["secret_key"] = miConfig.SecretKey
  7126. data["url"] = miConfig.Url
  7127. data["ak"] = miConfig.AccessKey
  7128. data["cainfo"] = miConfig.Cainfo
  7129. data["setl_mon"] = stmt_mon
  7130. month := time.Unix(1557042972, 0).Format("1")
  7131. year := time.Now().Format("2006")
  7132. month = time.Now().Format("01")
  7133. day := time.Now().Format("02")
  7134. hour := time.Now().Format("15")
  7135. min := time.Now().Format("04")
  7136. sec := time.Now().Format("05")
  7137. fix_fill_date := year + month + day + hour + min + sec
  7138. data["fix_fill_dept"] = miConfig.OrgName
  7139. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7140. data["fix_fill_psn"] = curRoles.UserName
  7141. data["fix_fill_date"] = fix_fill_date
  7142. data["stmt_loc"] = "2"
  7143. upld_btch = "0"
  7144. data["upld_btch"] = upld_btch
  7145. client := &http.Client{}
  7146. bytesData, _ := json.Marshal(data)
  7147. var req *http.Request
  7148. if miConfig.MdtrtareaAdmvs == "320830" {
  7149. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7150. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7151. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7152. } else {
  7153. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7154. }
  7155. resp, _ := client.Do(req)
  7156. defer resp.Body.Close()
  7157. body, ioErr := ioutil.ReadAll(resp.Body)
  7158. if ioErr != nil {
  7159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7161. }
  7162. var respJSON map[string]interface{}
  7163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7166. }
  7167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7168. fmt.Println(respJSON)
  7169. result, _ := json.Marshal(respJSON)
  7170. fmt.Println(result)
  7171. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7172. utils.ErrorLog("解析失败:%v", err)
  7173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7174. }
  7175. if result3265.Infcode != "0" {
  7176. c.ServeSuccessJSON(map[string]interface{}{
  7177. "failed_code": -10,
  7178. "msg": result3265.ErrMsg,
  7179. })
  7180. return
  7181. } else {
  7182. c.ServeSuccessJSON(map[string]interface{}{
  7183. "info": result3265.Output,
  7184. })
  7185. return
  7186. }
  7187. }
  7188. func (c *HisApiController) Get3267() {
  7189. admin_user_id, _ := c.GetInt64("admin_user_id")
  7190. startTime := c.GetString("start_time")
  7191. //endTime, _ := c.GetString("end_time")
  7192. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7193. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7194. times := strings.Split(startTime, "-")
  7195. setl_mon := times[0] + times[1]
  7196. var upld_btch string
  7197. //var empty models.JSResultEmpty
  7198. var result3265 models.JSResult3264
  7199. upld_btch = "0"
  7200. data := make(map[string]interface{})
  7201. data["org_name"] = miConfig.OrgName
  7202. data["doctor"] = curRoles.UserName
  7203. data["doctor_name"] = curRoles.UserName
  7204. data["fixmedins_code"] = miConfig.Code
  7205. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7206. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7207. data["secret_key"] = miConfig.SecretKey
  7208. data["url"] = miConfig.Url
  7209. data["ak"] = miConfig.AccessKey
  7210. data["cainfo"] = miConfig.Cainfo
  7211. data["setl_mon"] = setl_mon
  7212. data["stmt_loc"] = "2"
  7213. data["upld_btch"] = upld_btch
  7214. client := &http.Client{}
  7215. bytesData, _ := json.Marshal(data)
  7216. var req *http.Request
  7217. if miConfig.MdtrtareaAdmvs == "320830" {
  7218. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7219. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7221. } else {
  7222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7223. }
  7224. resp, _ := client.Do(req)
  7225. defer resp.Body.Close()
  7226. body, ioErr := ioutil.ReadAll(resp.Body)
  7227. if ioErr != nil {
  7228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7230. }
  7231. var respJSON map[string]interface{}
  7232. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7235. }
  7236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7237. fmt.Println(respJSON)
  7238. result, _ := json.Marshal(respJSON)
  7239. fmt.Println(result)
  7240. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7241. utils.ErrorLog("解析失败:%v", err)
  7242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7243. }
  7244. if result3265.Infcode != "0" {
  7245. c.ServeSuccessJSON(map[string]interface{}{
  7246. "failed_code": -10,
  7247. "msg": result3265.ErrMsg,
  7248. })
  7249. return
  7250. } else {
  7251. c.ServeSuccessJSON(map[string]interface{}{
  7252. "info": result3265.Output.Data,
  7253. })
  7254. return
  7255. }
  7256. }
  7257. func (c *HisApiController) Get3268() {
  7258. admin_user_id, _ := c.GetInt64("admin_user_id")
  7259. startTime := c.GetString("start_time")
  7260. endTime := c.GetString("end_time")
  7261. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7263. times := strings.Split(startTime, "-")
  7264. setl_mon := times[0] + times[1]
  7265. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7266. var twos []models.FixMonRecDetailFileInTwo
  7267. var funs []models.FundDetail
  7268. for _, item := range datas {
  7269. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7270. funs = append(funs, fun...)
  7271. }
  7272. var funInfos []models.Fund
  7273. //for _, item := range funs {
  7274. // var rf []models.FundInfo
  7275. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7276. // for _, subitem := range rf {
  7277. // var fund models.Fund
  7278. // fund.FundCode = subitem.FundPayType
  7279. // fund.FundName = subitem.FundPayTypeName
  7280. // fund.FundAmt = subitem.FundPayAmt
  7281. // fund.FundKey = item.FundKey
  7282. // fund.InsuAdmdvs = "555555"
  7283. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7284. // funInfos = append(funInfos, fund)
  7285. // }
  7286. //}
  7287. for _, team := range datas {
  7288. var two models.FixMonRecDetailFileInTwo
  7289. two.SetlDate = time.Now().Format("2006-01-02")
  7290. two.MedType = team.MedType
  7291. two.Insutype = team.Insutype
  7292. two.PsnType = team.PsnType
  7293. two.MedType = team.MedType
  7294. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7295. two.InsuAdmdvs = team.InsuAdmdvs
  7296. two.PsnTime = team.PsnTime
  7297. two.PsnCnt = team.PsnCnt
  7298. two.FundKey = team.FundKey
  7299. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7300. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7301. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7302. two.MedfeeSumAmt = ms
  7303. two.InscpAmt = ia
  7304. two.FundPaySumAmt = fps
  7305. twos = append(twos, two)
  7306. }
  7307. var upld_btch string
  7308. upld_btch = "0"
  7309. var empty models.JSResultEmpty
  7310. data := make(map[string]interface{})
  7311. data["org_name"] = miConfig.OrgName
  7312. data["doctor"] = curRoles.UserName
  7313. data["doctor_name"] = curRoles.UserName
  7314. data["fixmedins_code"] = miConfig.Code
  7315. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7316. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7317. data["secret_key"] = miConfig.SecretKey
  7318. data["url"] = miConfig.Url
  7319. data["ak"] = miConfig.AccessKey
  7320. data["cainfo"] = miConfig.Cainfo
  7321. data["datas"] = twos
  7322. data["fund"] = funInfos
  7323. data["setl_mon"] = setl_mon
  7324. month := time.Unix(1557042972, 0).Format("1")
  7325. year := time.Now().Format("2006")
  7326. month = time.Now().Format("01")
  7327. day := time.Now().Format("02")
  7328. hour := time.Now().Format("15")
  7329. min := time.Now().Format("04")
  7330. sec := time.Now().Format("05")
  7331. fix_fill_date := year + month + day + hour + min + sec
  7332. data["fix_fill_dept"] = miConfig.OrgName
  7333. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7334. data["fix_fill_psn"] = curRoles.UserName
  7335. data["fix_fill_date"] = fix_fill_date
  7336. data["stmt_loc"] = "2"
  7337. data["upld_btch"] = upld_btch
  7338. client := &http.Client{}
  7339. bytesData, _ := json.Marshal(data)
  7340. var req *http.Request
  7341. if miConfig.MdtrtareaAdmvs == "320830" {
  7342. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7343. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7344. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7345. } else {
  7346. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7347. }
  7348. resp, _ := client.Do(req)
  7349. defer resp.Body.Close()
  7350. body, ioErr := ioutil.ReadAll(resp.Body)
  7351. if ioErr != nil {
  7352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7354. }
  7355. var respJSON map[string]interface{}
  7356. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7359. }
  7360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7361. fmt.Println(respJSON)
  7362. result, _ := json.Marshal(respJSON)
  7363. fmt.Println(result)
  7364. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7365. utils.ErrorLog("解析失败:%v", err)
  7366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7367. }
  7368. if empty.Infcode != "0" {
  7369. c.ServeSuccessJSON(map[string]interface{}{
  7370. "failed_code": -10,
  7371. "msg": empty.ErrMsg,
  7372. })
  7373. return
  7374. } else {
  7375. c.ServeSuccessJSON(map[string]interface{}{
  7376. "msg": "上传成功",
  7377. })
  7378. return
  7379. }
  7380. }
  7381. func (c *HisApiController) Get3269() {
  7382. admin_user_id, _ := c.GetInt64("admin_user_id")
  7383. startTime := c.GetString("start_time")
  7384. //endTime, _ := c.GetString("end_time")
  7385. times := strings.Split(startTime, "-")
  7386. setl_mon := times[0] + times[1]
  7387. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7388. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7389. var result3263 models.JSResult3263
  7390. data := make(map[string]interface{})
  7391. data["org_name"] = miConfig.OrgName
  7392. data["doctor"] = curRoles.UserName
  7393. data["doctor_name"] = curRoles.UserName
  7394. data["fixmedins_code"] = miConfig.Code
  7395. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7396. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7397. data["secret_key"] = miConfig.SecretKey
  7398. data["url"] = miConfig.Url
  7399. data["ak"] = miConfig.AccessKey
  7400. data["cainfo"] = miConfig.Cainfo
  7401. data["setl_mon"] = setl_mon
  7402. data["stmt_loc"] = "2"
  7403. client := &http.Client{}
  7404. bytesData, _ := json.Marshal(data)
  7405. var req *http.Request
  7406. if miConfig.MdtrtareaAdmvs == "320830" {
  7407. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7408. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7409. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7410. } else {
  7411. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7412. }
  7413. resp, _ := client.Do(req)
  7414. defer resp.Body.Close()
  7415. body, ioErr := ioutil.ReadAll(resp.Body)
  7416. if ioErr != nil {
  7417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7419. }
  7420. var respJSON map[string]interface{}
  7421. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7424. }
  7425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7426. fmt.Println(respJSON)
  7427. result, _ := json.Marshal(respJSON)
  7428. fmt.Println(result)
  7429. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7430. utils.ErrorLog("解析失败:%v", err)
  7431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7432. }
  7433. if result3263.Infcode != "0" {
  7434. c.ServeSuccessJSON(map[string]interface{}{
  7435. "failed_code": -10,
  7436. "msg": result3263.ErrMsg,
  7437. })
  7438. return
  7439. } else {
  7440. c.ServeSuccessJSON(map[string]interface{}{
  7441. "msg": "上传成功",
  7442. })
  7443. return
  7444. }
  7445. }
  7446. func (c *HisApiController) Get3270() {
  7447. admin_user_id, _ := c.GetInt64("admin_user_id")
  7448. startTime := c.GetString("start_time")
  7449. //endTime, _ := c.GetString("end_time")
  7450. times := strings.Split(startTime, "-")
  7451. setl_mon := times[0] + times[1]
  7452. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7454. var result3263 models.JSResult3263
  7455. data2 := make(map[string]interface{})
  7456. data2["org_name"] = miConfig.OrgName
  7457. data2["doctor"] = curRoles.UserName
  7458. data2["doctor_name"] = curRoles.UserName
  7459. data2["fixmedins_code"] = miConfig.Code
  7460. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7461. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7462. data2["secret_key"] = miConfig.SecretKey
  7463. data2["url"] = miConfig.Url
  7464. data2["ak"] = miConfig.AccessKey
  7465. data2["cainfo"] = miConfig.Cainfo
  7466. data2["setl_mon"] = setl_mon
  7467. data2["stmt_loc"] = "2"
  7468. client2 := &http.Client{}
  7469. bytesData2, _ := json.Marshal(data2)
  7470. var req3263 *http.Request
  7471. if miConfig.MdtrtareaAdmvs == "320830" {
  7472. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7473. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7474. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7475. } else {
  7476. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7477. }
  7478. resp2, _ := client2.Do(req3263)
  7479. defer resp2.Body.Close()
  7480. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7481. if ioErr2 != nil {
  7482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. }
  7485. var respJSON3263 map[string]interface{}
  7486. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7489. }
  7490. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7491. fmt.Println(respJSON3263)
  7492. result2, _ := json.Marshal(respJSON3263)
  7493. fmt.Println(result2)
  7494. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7495. utils.ErrorLog("解析失败:%v", err)
  7496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7497. }
  7498. var ids []string
  7499. for _, item := range result3263.Output {
  7500. ids = append(ids, item.SolidifyID)
  7501. }
  7502. var result3264 models.JSResult3264
  7503. data := make(map[string]interface{})
  7504. data["org_name"] = miConfig.OrgName
  7505. data["doctor"] = curRoles.UserName
  7506. data["doctor_name"] = curRoles.UserName
  7507. data["fixmedins_code"] = miConfig.Code
  7508. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7509. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7510. data["secret_key"] = miConfig.SecretKey
  7511. data["url"] = miConfig.Url
  7512. data["ak"] = miConfig.AccessKey
  7513. data["cainfo"] = miConfig.Cainfo
  7514. data["setl_mon"] = setl_mon
  7515. data["stmt_loc"] = "2"
  7516. data["solidify_id"] = ids
  7517. client := &http.Client{}
  7518. bytesData, _ := json.Marshal(data)
  7519. var req *http.Request
  7520. if miConfig.MdtrtareaAdmvs == "320830" {
  7521. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7522. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7523. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7524. } else {
  7525. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7526. }
  7527. resp, _ := client.Do(req)
  7528. defer resp.Body.Close()
  7529. body, ioErr := ioutil.ReadAll(resp.Body)
  7530. if ioErr != nil {
  7531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7533. }
  7534. var respJSON map[string]interface{}
  7535. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7538. }
  7539. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7540. fmt.Println(respJSON)
  7541. result, _ := json.Marshal(respJSON)
  7542. fmt.Println(result)
  7543. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7544. utils.ErrorLog("解析失败:%v", err)
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7546. }
  7547. if result3264.Infcode != "0" {
  7548. c.ServeSuccessJSON(map[string]interface{}{
  7549. "failed_code": -10,
  7550. "msg": result3264.ErrMsg,
  7551. })
  7552. return
  7553. } else {
  7554. c.ServeSuccessJSON(map[string]interface{}{
  7555. "info": result3264.Output,
  7556. })
  7557. return
  7558. }
  7559. }
  7560. func (c *HisApiController) Get3271() {
  7561. admin_user_id, _ := c.GetInt64("admin_user_id")
  7562. startTime := c.GetString("start_time")
  7563. //endTime, _ := c.GetString("end_time")
  7564. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7565. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7566. times := strings.Split(startTime, "-")
  7567. setl_mon := times[0] + times[1]
  7568. //var empty models.JSResultEmpty
  7569. var result3265 models.JSResult3264
  7570. var result3263 models.JSResult3263
  7571. data2 := make(map[string]interface{})
  7572. data2["org_name"] = miConfig.OrgName
  7573. data2["doctor"] = curRoles.UserName
  7574. data2["doctor_name"] = curRoles.UserName
  7575. data2["fixmedins_code"] = miConfig.Code
  7576. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7577. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7578. data2["secret_key"] = miConfig.SecretKey
  7579. data2["url"] = miConfig.Url
  7580. data2["ak"] = miConfig.AccessKey
  7581. data2["cainfo"] = miConfig.Cainfo
  7582. data2["setl_mon"] = setl_mon
  7583. data2["stmt_loc"] = "2"
  7584. client2 := &http.Client{}
  7585. bytesData2, _ := json.Marshal(data2)
  7586. var req3263 *http.Request
  7587. if miConfig.MdtrtareaAdmvs == "320830" {
  7588. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7589. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7590. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7591. } else {
  7592. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7593. }
  7594. resp2, _ := client2.Do(req3263)
  7595. defer resp2.Body.Close()
  7596. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7597. if ioErr2 != nil {
  7598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7600. }
  7601. var respJSON3263 map[string]interface{}
  7602. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7605. }
  7606. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7607. fmt.Println(respJSON3263)
  7608. result2, _ := json.Marshal(respJSON3263)
  7609. fmt.Println(result2)
  7610. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7611. utils.ErrorLog("解析失败:%v", err)
  7612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7613. }
  7614. var ids []string
  7615. for _, item := range result3263.Output {
  7616. ids = append(ids, item.SolidifyID)
  7617. }
  7618. data := make(map[string]interface{})
  7619. data["org_name"] = miConfig.OrgName
  7620. data["doctor"] = curRoles.UserName
  7621. data["doctor_name"] = curRoles.UserName
  7622. data["fixmedins_code"] = miConfig.Code
  7623. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7625. data["secret_key"] = miConfig.SecretKey
  7626. data["url"] = miConfig.Url
  7627. data["ak"] = miConfig.AccessKey
  7628. data["cainfo"] = miConfig.Cainfo
  7629. data["setl_mon"] = setl_mon
  7630. data["solidify_id"] = ids
  7631. month := time.Unix(1557042972, 0).Format("1")
  7632. year := time.Now().Format("2006")
  7633. month = time.Now().Format("01")
  7634. day := time.Now().Format("02")
  7635. hour := time.Now().Format("15")
  7636. min := time.Now().Format("04")
  7637. sec := time.Now().Format("05")
  7638. fix_fill_date := year + month + day + hour + min + sec
  7639. data["fix_fill_dept"] = miConfig.OrgName
  7640. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7641. data["fix_fill_psn"] = curRoles.UserName
  7642. data["fix_fill_date"] = fix_fill_date
  7643. data["stmt_loc"] = "2"
  7644. client := &http.Client{}
  7645. bytesData, _ := json.Marshal(data)
  7646. var req *http.Request
  7647. if miConfig.MdtrtareaAdmvs == "320830" {
  7648. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7649. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7650. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7651. } else {
  7652. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7653. }
  7654. resp, _ := client.Do(req)
  7655. defer resp.Body.Close()
  7656. body, ioErr := ioutil.ReadAll(resp.Body)
  7657. if ioErr != nil {
  7658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7660. }
  7661. var respJSON map[string]interface{}
  7662. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7665. }
  7666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7667. fmt.Println(respJSON)
  7668. result, _ := json.Marshal(respJSON)
  7669. fmt.Println(result)
  7670. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7671. utils.ErrorLog("解析失败:%v", err)
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. }
  7674. if result3265.Infcode != "0" {
  7675. c.ServeSuccessJSON(map[string]interface{}{
  7676. "failed_code": -10,
  7677. "msg": result3265.ErrMsg,
  7678. })
  7679. return
  7680. } else {
  7681. c.ServeSuccessJSON(map[string]interface{}{
  7682. "info": result3265.Output.Data,
  7683. })
  7684. return
  7685. }
  7686. }
  7687. func (c *HisApiController) Get3272() {
  7688. admin_user_id, _ := c.GetInt64("admin_user_id")
  7689. startTime := c.GetString("start_time")
  7690. //endTime, _ := c.GetString("end_time")
  7691. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7693. times := strings.Split(startTime, "-")
  7694. setl_mon := times[0] + times[1]
  7695. var upld_btch string
  7696. //var empty models.JSResultEmpty
  7697. var result3265 models.JSResult3264
  7698. data := make(map[string]interface{})
  7699. data["org_name"] = miConfig.OrgName
  7700. data["doctor"] = curRoles.UserName
  7701. data["doctor_name"] = curRoles.UserName
  7702. data["fixmedins_code"] = miConfig.Code
  7703. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7704. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7705. data["secret_key"] = miConfig.SecretKey
  7706. data["url"] = miConfig.Url
  7707. data["ak"] = miConfig.AccessKey
  7708. data["cainfo"] = miConfig.Cainfo
  7709. data["setl_mon"] = setl_mon
  7710. month := time.Unix(1557042972, 0).Format("1")
  7711. year := time.Now().Format("2006")
  7712. month = time.Now().Format("01")
  7713. day := time.Now().Format("02")
  7714. hour := time.Now().Format("15")
  7715. min := time.Now().Format("04")
  7716. sec := time.Now().Format("05")
  7717. fix_fill_date := year + month + day + hour + min + sec
  7718. data["fix_fill_dept"] = miConfig.OrgName
  7719. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7720. data["fix_fill_psn"] = curRoles.UserName
  7721. data["fix_fill_date"] = fix_fill_date
  7722. data["stmt_loc"] = "2"
  7723. data["upld_btch"] = upld_btch
  7724. client := &http.Client{}
  7725. bytesData, _ := json.Marshal(data)
  7726. var req *http.Request
  7727. if miConfig.MdtrtareaAdmvs == "320830" {
  7728. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7729. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7730. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7731. } else {
  7732. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7733. }
  7734. resp, _ := client.Do(req)
  7735. defer resp.Body.Close()
  7736. body, ioErr := ioutil.ReadAll(resp.Body)
  7737. if ioErr != nil {
  7738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7740. }
  7741. var respJSON map[string]interface{}
  7742. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7745. }
  7746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7747. fmt.Println(respJSON)
  7748. result, _ := json.Marshal(respJSON)
  7749. fmt.Println(result)
  7750. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7751. utils.ErrorLog("解析失败:%v", err)
  7752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7753. }
  7754. if result3265.Infcode != "0" {
  7755. c.ServeSuccessJSON(map[string]interface{}{
  7756. "failed_code": -10,
  7757. "msg": result3265.ErrMsg,
  7758. })
  7759. return
  7760. } else {
  7761. c.ServeSuccessJSON(map[string]interface{}{
  7762. "info": result3265.Output,
  7763. })
  7764. return
  7765. }
  7766. }
  7767. func (c *HisApiController) Get3273() {
  7768. admin_user_id, _ := c.GetInt64("admin_user_id")
  7769. startTime := c.GetString("start_time")
  7770. //endTime, _ := c.GetString("end_time")
  7771. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7772. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7773. times := strings.Split(startTime, "-")
  7774. setl_mon := times[0] + times[1]
  7775. var result3265 models.JSResult3264
  7776. data := make(map[string]interface{})
  7777. data["org_name"] = miConfig.OrgName
  7778. data["doctor"] = curRoles.UserName
  7779. data["doctor_name"] = curRoles.UserName
  7780. data["fixmedins_code"] = miConfig.Code
  7781. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7782. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7783. data["secret_key"] = miConfig.SecretKey
  7784. data["url"] = miConfig.Url
  7785. data["ak"] = miConfig.AccessKey
  7786. data["cainfo"] = miConfig.Cainfo
  7787. data["setl_mon"] = setl_mon
  7788. data["stmt_loc"] = "2"
  7789. client := &http.Client{}
  7790. bytesData, _ := json.Marshal(data)
  7791. var req *http.Request
  7792. if miConfig.MdtrtareaAdmvs == "320921" {
  7793. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7794. } else {
  7795. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7796. }
  7797. resp, _ := client.Do(req)
  7798. defer resp.Body.Close()
  7799. body, ioErr := ioutil.ReadAll(resp.Body)
  7800. if ioErr != nil {
  7801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. }
  7804. var respJSON map[string]interface{}
  7805. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7808. }
  7809. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7810. fmt.Println(respJSON)
  7811. result, _ := json.Marshal(respJSON)
  7812. fmt.Println(result)
  7813. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7814. utils.ErrorLog("解析失败:%v", err)
  7815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7816. }
  7817. if result3265.Infcode != "0" {
  7818. c.ServeSuccessJSON(map[string]interface{}{
  7819. "failed_code": -10,
  7820. "msg": result3265.ErrMsg,
  7821. })
  7822. return
  7823. } else {
  7824. c.ServeSuccessJSON(map[string]interface{}{
  7825. "info": result3265.Output.Data,
  7826. })
  7827. return
  7828. }
  7829. }
  7830. func (c *HisApiController) Get3274() {
  7831. //if miConfig.MdtrtareaAdmvs == "320921" {
  7832. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7833. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7834. // "&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
  7835. //
  7836. //} else {
  7837. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7838. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7839. // "&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
  7840. //
  7841. //}
  7842. }
  7843. func (c *HisApiController) Get3275() {
  7844. //if miConfig.MdtrtareaAdmvs == "320921" {
  7845. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7846. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7847. // "&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
  7848. //
  7849. //} else {
  7850. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7851. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7852. // "&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
  7853. //
  7854. //}
  7855. }
  7856. func (c *HisApiController) Get3276() {
  7857. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7858. //month := c.GetString("month")
  7859. //
  7860. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7861. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7862. //var api string
  7863. //var res Result5301
  7864. //
  7865. //if miConfig.MdtrtareaAdmvs == "320921" {
  7866. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7867. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7868. //} else {
  7869. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7870. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7871. //}
  7872. //
  7873. //resp, requestErr := http.Get(api)
  7874. //if requestErr != nil {
  7875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7876. // return
  7877. //}
  7878. //
  7879. //body, ioErr := ioutil.ReadAll(resp.Body)
  7880. //if ioErr != nil {
  7881. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7882. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7883. // return
  7884. //}
  7885. //var respJSON map[string]interface{}
  7886. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7887. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7889. // return
  7890. //}
  7891. //
  7892. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7893. //result, _ := json.Marshal(respJSON)
  7894. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7895. // utils.ErrorLog("解析失败:%v", err)
  7896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. // return
  7898. //}
  7899. }
  7900. func (c *HisApiController) Get3277() {
  7901. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7902. //month := c.GetString("month")
  7903. //
  7904. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7905. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7906. //var api string
  7907. //var res Result5301
  7908. //
  7909. //if miConfig.MdtrtareaAdmvs == "320921" {
  7910. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7911. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7912. //} else {
  7913. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7914. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7915. //}
  7916. //
  7917. //resp, requestErr := http.Get(api)
  7918. //if requestErr != nil {
  7919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7920. // return
  7921. //}
  7922. //
  7923. //body, ioErr := ioutil.ReadAll(resp.Body)
  7924. //if ioErr != nil {
  7925. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7927. // return
  7928. //}
  7929. //var respJSON map[string]interface{}
  7930. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7931. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7933. // return
  7934. //}
  7935. //
  7936. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7937. //result, _ := json.Marshal(respJSON)
  7938. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7939. // utils.ErrorLog("解析失败:%v", err)
  7940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7941. // return
  7942. //}
  7943. }
  7944. func (c *HisApiController) GetCFYLJG001() {
  7945. admin_user_id, _ := c.GetInt64("admin_user_id")
  7946. patient_id, _ := c.GetInt64("patient_id")
  7947. his_patient_id, _ := c.GetInt64("his_patient_id")
  7948. record_time := c.GetString("record_time")
  7949. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7950. psn, _ := service.GetPsnByPatientId(patient_id)
  7951. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7952. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7953. var cFYLJG001 models.CFYLJG001
  7954. timeLayout := "2006-01-02"
  7955. loc, _ := time.LoadLocation("Local")
  7956. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7957. if err != nil {
  7958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7959. return
  7960. }
  7961. recordDateTime := theTime.Unix()
  7962. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7963. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7964. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7965. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7966. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7967. for _, item := range prescriptions {
  7968. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7969. if his.IdCardType == 1 {
  7970. bas := strings.Split(psn.CardInfo, "|")
  7971. basNumber := bas[1]
  7972. fmt.Println(basNumber)
  7973. card_sn := bas[3]
  7974. card_no := bas[2]
  7975. cFYLJG001.MdtrtCertType = "03"
  7976. cFYLJG001.CardSn = card_sn
  7977. cFYLJG001.MdtrtCertNo = card_no
  7978. cFYLJG001.EcToken = ""
  7979. cFYLJG001.AuthNo = ""
  7980. } else if his.IdCardType == 2 {
  7981. cFYLJG001.MdtrtCertType = "02"
  7982. cFYLJG001.CardSn = ""
  7983. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7984. cFYLJG001.EcToken = ""
  7985. cFYLJG001.AuthNo = ""
  7986. } else if his.IdCardType == 4 {
  7987. cFYLJG001.MdtrtCertType = "01"
  7988. cFYLJG001.CardSn = ""
  7989. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7990. cFYLJG001.EcToken = psn.VerifyNumber
  7991. cFYLJG001.AuthNo = ""
  7992. }
  7993. cFYLJG001.BizTypeCode = "01"
  7994. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7995. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7996. cFYLJG001.RxTypeCode = "1"
  7997. tempTime := time.Unix(item.PreTime, 0)
  7998. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7999. cFYLJG001.PrscTime = timeFormatOne
  8000. var count float64
  8001. if item.Type == 1 {
  8002. for _, sumItem := range item.HisDoctorAdviceInfo {
  8003. count = count + sumItem.PrescribingNumber
  8004. }
  8005. }
  8006. cFYLJG001.RxDrugCnt = count
  8007. cFYLJG001.ValiDays = "2"
  8008. ts := time.Unix(item.PreTime, 0)
  8009. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  8010. tempTime3 := time.Unix(record_time2, 0)
  8011. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  8012. cFYLJG001.ValiEndTime = timeFormat3
  8013. cFYLJG001.RxCotnFlag = "0"
  8014. for _, subItem := range item.HisDoctorAdviceInfo {
  8015. var drug models.RxDrug
  8016. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  8017. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  8018. drug.RxItemTypeCode = "11"
  8019. drug.DrugDosform = "剂" //TODO
  8020. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  8021. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  8022. }
  8023. drug.MedcWayDscr = subItem.DeliveryWay
  8024. tempTime2 := time.Unix(subItem.StartTime, 0)
  8025. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8026. drug.MedcBegntime = timeFormatTwo
  8027. if subItem.Day > 0 {
  8028. ts := time.Unix(subItem.StartTime, 0)
  8029. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  8030. tempTime4 := time.Unix(record_time, 0)
  8031. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  8032. drug.MedcEndtime = timeFormat5
  8033. } else {
  8034. tempTime2 := time.Unix(subItem.StartTime, 0)
  8035. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8036. drug.MedcEndtime = timeFormatTwo
  8037. }
  8038. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  8039. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  8040. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  8041. drug.DrugCnt = subItem.PrescribingNumber
  8042. drug.DrugDosunt = subItem.PrescribingNumberUnit
  8043. drug.DrugGenname = subItem.AdviceName
  8044. drug.MedcWayCodg = subItem.DeliveryWay
  8045. //drug.DrugTotlcnt = subItem.PrescribingNumber
  8046. drug.SinDoscnt = subItem.SingleDose
  8047. drug.SinDosunt = subItem.SingleDoseUnit
  8048. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  8049. drug.UsedFrquName = subItem.ExecutionFrequency
  8050. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  8051. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  8052. drug.HospApprFlag = "1"
  8053. cFYLJG001.List = append(cFYLJG001.List, drug)
  8054. }
  8055. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  8056. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  8057. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  8058. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  8059. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  8060. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  8061. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  8062. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  8063. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  8064. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  8065. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  8066. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  8067. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  8068. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  8069. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  8070. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  8071. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  8072. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  8073. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  8074. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  8075. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  8076. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  8077. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  8078. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  8079. tempTime2 := time.Now().Unix()
  8080. tempTime6 := time.Unix(tempTime2, 0)
  8081. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  8082. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  8083. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  8084. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  8085. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  8086. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  8087. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  8088. var config []*models.HisXtDiagnoseConfig
  8089. for _, item := range diagnosis_ids {
  8090. id, _ := strconv.ParseInt(item, 10, 64)
  8091. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8092. config = append(config, &diagnosisConfig)
  8093. }
  8094. for index, subitem := range config {
  8095. if index == 0 {
  8096. var dia models.DiseInfo
  8097. dia.DiagType = "1"
  8098. dia.MaindiagFlag = "1"
  8099. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8100. dia.DiagCode = subitem.CountryCode
  8101. dia.DiagName = subitem.ClassName
  8102. dia.DiagDept = "肾内科"
  8103. dia.DiagDrNo = doctor.DoctorNumber
  8104. dia.DiagDrName = doctor.UserName
  8105. tempTime3 := time.Unix(item.PreTime, 0)
  8106. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8107. dia.DiagTime = timeFormatTwo
  8108. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8109. } else {
  8110. var dia models.DiseInfo
  8111. dia.DiagType = "1"
  8112. dia.MaindiagFlag = "0"
  8113. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8114. dia.DiagCode = subitem.CountryCode
  8115. dia.DiagName = subitem.ClassName
  8116. dia.DiagDept = "肾内科"
  8117. dia.DiagDrNo = doctor.DoctorNumber
  8118. dia.DiagDrName = doctor.UserName
  8119. tempTime3 := time.Unix(item.PreTime, 0)
  8120. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8121. dia.DiagTime = timeFormatTwo
  8122. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8123. }
  8124. }
  8125. if miConfig.MdtrtareaAdmvs == "340699" {
  8126. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  8127. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8128. var res ResultCFYLJG001AH
  8129. var respJSON2 map[string]interface{}
  8130. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. return
  8134. }
  8135. userJSONBytes2, _ := json.Marshal(respJSON2)
  8136. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8137. utils.ErrorLog("解析失败:%v", err)
  8138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8139. return
  8140. }
  8141. var flow models.HisPrescriptionFlow
  8142. flow.Ctime = time.Now().Unix()
  8143. flow.SignDigest = ""
  8144. flow.RxTraceCode = res.RxTraceCode
  8145. flow.HiRxno = res.HiRxno
  8146. flow.MID = his.Number
  8147. flow.Status = 1
  8148. flow.DCode = doctor_info.DoctorNumber
  8149. flow.OriginalRxFile = ""
  8150. flow.OriginalValue = ""
  8151. flow.SignCertDn = ""
  8152. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8153. flow.SignCertSn = ""
  8154. flow.Mtime = time.Now().Unix()
  8155. service.Createflow(&flow)
  8156. c.ServeSuccessJSON(map[string]interface{}{
  8157. "msg": "上传成功",
  8158. })
  8159. } else {
  8160. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8161. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8162. var res ResultCFYLJG001
  8163. var respJSON2 map[string]interface{}
  8164. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8167. return
  8168. }
  8169. userJSONBytes2, _ := json.Marshal(respJSON2)
  8170. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8171. utils.ErrorLog("解析失败:%v", err)
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. if res.Infcode == -1 {
  8176. c.ServeSuccessJSON(map[string]interface{}{
  8177. "failed_code": -10,
  8178. "msg": res.ErrMsg,
  8179. })
  8180. return
  8181. } else {
  8182. var flow models.HisPrescriptionFlow
  8183. flow.Ctime = time.Now().Unix()
  8184. flow.SignDigest = ""
  8185. flow.RxTraceCode = res.Output.RxTraceCode
  8186. flow.HiRxno = res.Output.HiRxno
  8187. flow.MID = his.Number
  8188. flow.Status = 1
  8189. flow.DCode = doctor_info.DoctorNumber
  8190. flow.OriginalRxFile = ""
  8191. flow.OriginalValue = ""
  8192. flow.SignCertDn = ""
  8193. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8194. flow.SignCertSn = ""
  8195. flow.Mtime = time.Now().Unix()
  8196. service.Createflow(&flow)
  8197. c.ServeSuccessJSON(map[string]interface{}{
  8198. "msg": "上传成功",
  8199. })
  8200. }
  8201. }
  8202. }
  8203. }
  8204. func (c *HisApiController) GetCFYLJG12() {
  8205. admin_user_id, _ := c.GetInt64("admin_user_id")
  8206. his_patient_id, _ := c.GetInt64("his_patient_id")
  8207. record_time := c.GetString("record_time")
  8208. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8209. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8210. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8211. flow, _ := service.Getflowtwo(his.Number)
  8212. patient_id, _ := c.GetInt64("patient_id")
  8213. timeLayout := "2006-01-02"
  8214. loc, _ := time.LoadLocation("Local")
  8215. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8216. if err != nil {
  8217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8218. return
  8219. }
  8220. recordDateTime := theTime.Unix()
  8221. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8222. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8223. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8224. dept, _ := service.GetDepartMentDetail(info.Departments)
  8225. inputData := make(map[string]interface{})
  8226. inputData["rxTraceCode"] = flow.RxTraceCode
  8227. inputData["hiRxno"] = flow.HiRxno
  8228. inputData["mdtrtId"] = flow.MID
  8229. inputData["patnName"] = his.PsnName
  8230. inputData["psnCertType"] = his.PsnCertType
  8231. inputData["certno"] = his.Certno
  8232. inputData["fixmedinsName"] = miConfig.OrgName
  8233. inputData["fixmedinsCode"] = miConfig.Code
  8234. inputData["drCode"] = doctor_info.DoctorNumber
  8235. inputData["prscDrName"] = doctor_info.UserName
  8236. inputData["pharDeptName"] = dept.Name
  8237. inputData["pharDeptCode"] = dept.Number
  8238. inputData["pharProfttlCodg"] = ""
  8239. inputData["pharProfttlName"] = ""
  8240. inputData["pharCode"] = "HY340621000425"
  8241. inputData["pharCertType"] = "01"
  8242. inputData["pharCertno"] = ""
  8243. inputData["pharName"] = "孙莉侠"
  8244. inputData["pharPracCertNo"] = ""
  8245. tempTime2 := time.Unix(info.Ctime, 0)
  8246. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8247. inputData["pharChkTime"] = timeFormatTwo
  8248. bytesData, _ := json.Marshal(inputData)
  8249. fmt.Println(string(bytesData))
  8250. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8251. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8252. if err != nil {
  8253. fmt.Println("Error reading PDF file:", err)
  8254. return
  8255. }
  8256. // 将 PDF 文件内容进行 Base64 编码
  8257. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8258. fmt.Println(err)
  8259. if miConfig.MdtrtareaAdmvs == "340699" {
  8260. data := make(map[string]interface{})
  8261. data["rx_encoded"] = rx_encoded
  8262. data["code"] = miConfig.Code
  8263. data["url"] = "http://10.66.149.64:8080/epc/api"
  8264. data["encoded"] = encoded
  8265. client := &http.Client{}
  8266. bytesData, _ := json.Marshal(data)
  8267. var req *http.Request
  8268. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8269. resp, _ := client.Do(req)
  8270. defer resp.Body.Close()
  8271. body, ioErr := ioutil.ReadAll(resp.Body)
  8272. if ioErr != nil {
  8273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8274. }
  8275. var respJSON map[string]interface{}
  8276. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8279. return
  8280. }
  8281. var resSix10265 ResultSix10265 //1101结果
  8282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8283. result, _ := json.Marshal(respJSON)
  8284. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8285. utils.ErrorLog("解析失败:%v", err)
  8286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8287. return
  8288. }
  8289. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8290. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8291. } else {
  8292. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8293. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8294. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8295. var res2 AhResult002
  8296. var respJSON2 map[string]interface{}
  8297. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8300. return
  8301. }
  8302. userJSONBytes2, _ := json.Marshal(respJSON2)
  8303. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8304. utils.ErrorLog("解析失败:%v", err)
  8305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8306. return
  8307. }
  8308. flow.Ctime = time.Now().Unix()
  8309. flow.SignDigest = res2.SignDigest
  8310. flow.RxFile = res2.RxFile
  8311. flow.MID = his.Number
  8312. flow.Status = 1
  8313. flow.DCode = doctor_info.DoctorNumber
  8314. flow.OriginalRxFile = rx_encoded
  8315. flow.OriginalValue = encoded
  8316. flow.SignCertDn = res2.SignCertDn
  8317. flow.SignCertSn = res2.SignCertSn
  8318. flow.Mtime = time.Now().Unix()
  8319. service.Saveflow(flow)
  8320. c.ServeSuccessJSON(map[string]interface{}{
  8321. "msg": "预签名成功",
  8322. })
  8323. }
  8324. }
  8325. func (c *HisApiController) GetCFYLJG13() {
  8326. admin_user_id, _ := c.GetInt64("admin_user_id")
  8327. his_patient_id, _ := c.GetInt64("his_patient_id")
  8328. record_time := c.GetString("record_time")
  8329. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8330. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8331. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8332. flow, _ := service.Getflowtwo(his.Number)
  8333. patient_id, _ := c.GetInt64("patient_id")
  8334. timeLayout := "2006-01-02"
  8335. loc, _ := time.LoadLocation("Local")
  8336. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8337. if err != nil {
  8338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8339. return
  8340. }
  8341. recordDateTime := theTime.Unix()
  8342. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8343. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8344. dept, _ := service.GetDepartMentDetail(info.Departments)
  8345. var cFYLJG003 models.CFYLJG003
  8346. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8347. cFYLJG003.HiRxno = flow.HiRxno
  8348. cFYLJG003.MdtrtID = flow.MID
  8349. cFYLJG003.PatnName = his.Name
  8350. cFYLJG003.Certno = his.Certno
  8351. cFYLJG003.FixmedinsName = miConfig.OrgName
  8352. cFYLJG003.FixmedinsCode = miConfig.Code
  8353. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8354. cFYLJG003.PrscDrName = doctor_info.UserName
  8355. cFYLJG003.PharDeptName = dept.Name
  8356. cFYLJG003.PharDeptCode = dept.Number
  8357. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8358. cFYLJG003.PharName = "孙莉侠"
  8359. cFYLJG003.PharPracCertNo = "060399"
  8360. cFYLJG003.PharCode = "HY340621000425"
  8361. cFYLJG003.PharCertType = "01"
  8362. cFYLJG003.PharCertno = ""
  8363. } else {
  8364. cFYLJG003.PharName = "彭斯遥"
  8365. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8366. cFYLJG003.PharCode = "HY440309002107"
  8367. cFYLJG003.PharCertType = "01"
  8368. cFYLJG003.PharCertno = "430482199408260023"
  8369. }
  8370. cFYLJG003.PsnCertType = "01"
  8371. cFYLJG003.RxFile = flow.RxFile
  8372. cFYLJG003.SignDigest = flow.SignDigest
  8373. cFYLJG003.FixmedinsCode = miConfig.Code
  8374. cFYLJG003.PsnCertType = "01"
  8375. cFYLJG003.PharProfttlCodg = dept.Name
  8376. tempTime2 := time.Unix(info.Ctime, 0)
  8377. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8378. cFYLJG003.PharChkTime = timeFormatTwo
  8379. if miConfig.MdtrtareaAdmvs == "340699" {
  8380. data := make(map[string]interface{})
  8381. data["url"] = "http://10.66.149.64:8080/epc/api"
  8382. data["13"] = cFYLJG003
  8383. client := &http.Client{}
  8384. bytesData, _ := json.Marshal(data)
  8385. var req *http.Request
  8386. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8387. resp, _ := client.Do(req)
  8388. defer resp.Body.Close()
  8389. body, ioErr := ioutil.ReadAll(resp.Body)
  8390. if ioErr != nil {
  8391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8392. }
  8393. var respJSON map[string]interface{}
  8394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. return
  8398. }
  8399. var resSix10265 ResultSix10265 //1101结果
  8400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8401. result, _ := json.Marshal(respJSON)
  8402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8403. utils.ErrorLog("解析失败:%v", err)
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8405. return
  8406. }
  8407. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8408. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8409. } else {
  8410. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8411. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8412. var res ResultCFYLJG003
  8413. var respJSON2 map[string]interface{}
  8414. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8417. return
  8418. }
  8419. userJSONBytes2, _ := json.Marshal(respJSON2)
  8420. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8421. utils.ErrorLog("解析失败:%v", err)
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. if res.Infcode == -1 {
  8426. c.ServeSuccessJSON(map[string]interface{}{
  8427. "failed_code": -10,
  8428. "msg": res.ErrMsg,
  8429. })
  8430. return
  8431. } else {
  8432. c.ServeSuccessJSON(map[string]interface{}{
  8433. "info": res.Output,
  8434. })
  8435. }
  8436. }
  8437. }
  8438. func (c *HisApiController) GetCFYLJG002() {
  8439. admin_user_id, _ := c.GetInt64("admin_user_id")
  8440. his_patient_id, _ := c.GetInt64("his_patient_id")
  8441. record_time := c.GetString("record_time")
  8442. admin_user_id = 3626
  8443. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8444. //id, _ := c.GetInt64("id")
  8445. admin_user_id = 3626
  8446. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8447. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8448. flow, _ := service.Getflowtwo(his.Number)
  8449. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8450. //record_time := c.GetString("record_time")
  8451. patient_id, _ := c.GetInt64("patient_id")
  8452. //patient_id = 23834
  8453. //record_time = "2023-09-18"
  8454. timeLayout := "2006-01-02"
  8455. loc, _ := time.LoadLocation("Local")
  8456. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8457. if err != nil {
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8459. return
  8460. }
  8461. recordDateTime := theTime.Unix()
  8462. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8463. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8464. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8465. dept, _ := service.GetDepartMentDetail(info.Departments)
  8466. inputData := make(map[string]interface{})
  8467. inputData["rxTraceCode"] = flow.RxTraceCode
  8468. inputData["hiRxno"] = flow.HiRxno
  8469. inputData["mdtrtId"] = flow.MID
  8470. inputData["patnName"] = his.PsnName
  8471. inputData["psnCertType"] = his.PsnCertType
  8472. inputData["certno"] = his.Certno
  8473. inputData["fixmedinsName"] = miConfig.OrgName
  8474. inputData["fixmedinsCode"] = miConfig.Code
  8475. inputData["drCode"] = doctor_info.DoctorNumber
  8476. inputData["prscDrName"] = doctor_info.UserName
  8477. inputData["pharDeptName"] = dept.Name
  8478. inputData["pharDeptCode"] = dept.Number
  8479. inputData["pharProfttlCodg"] = ""
  8480. inputData["pharProfttlName"] = ""
  8481. inputData["pharCode"] = "HY340621000425"
  8482. inputData["pharCertType"] = "01"
  8483. inputData["pharCertno"] = ""
  8484. inputData["pharName"] = "孙莉侠"
  8485. inputData["pharPracCertNo"] = "060399"
  8486. tempTime2 := time.Unix(info.Ctime, 0)
  8487. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8488. inputData["pharChkTime"] = timeFormatTwo
  8489. bytesData, _ := json.Marshal(inputData)
  8490. fmt.Println(string(bytesData))
  8491. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8492. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8493. if err != nil {
  8494. fmt.Println("Error reading PDF file:", err)
  8495. return
  8496. }
  8497. // 将 PDF 文件内容进行 Base64 编码
  8498. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8499. fmt.Println(err)
  8500. if miConfig.MdtrtareaAdmvs == "340699" {
  8501. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8502. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8503. var res2 AhResult002
  8504. var respJSON2 map[string]interface{}
  8505. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8508. return
  8509. }
  8510. userJSONBytes2, _ := json.Marshal(respJSON2)
  8511. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8512. utils.ErrorLog("解析失败:%v", err)
  8513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8514. return
  8515. }
  8516. flow.Ctime = time.Now().Unix()
  8517. flow.SignDigest = res2.SignDigest
  8518. flow.RxFile = res2.RxFile
  8519. flow.MID = his.Number
  8520. flow.Status = 1
  8521. flow.DCode = doctor_info.DoctorNumber
  8522. flow.OriginalRxFile = rx_encoded
  8523. flow.OriginalValue = encoded
  8524. flow.SignCertDn = res2.SignCertDn
  8525. flow.SignCertSn = res2.SignCertSn
  8526. flow.Mtime = time.Now().Unix()
  8527. service.Saveflow(flow)
  8528. c.ServeSuccessJSON(map[string]interface{}{
  8529. "msg": "预签名成功",
  8530. })
  8531. } else {
  8532. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8533. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8534. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8535. var res2 Result002
  8536. var respJSON2 map[string]interface{}
  8537. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8540. return
  8541. }
  8542. userJSONBytes2, _ := json.Marshal(respJSON2)
  8543. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8544. utils.ErrorLog("解析失败:%v", err)
  8545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8546. return
  8547. }
  8548. if res2.Infcode == 0 {
  8549. flow.Ctime = time.Now().Unix()
  8550. flow.SignDigest = res2.Output.SignDigest
  8551. flow.RxFile = res2.Output.RxFile
  8552. flow.MID = his.Number
  8553. flow.Status = 1
  8554. flow.DCode = doctor_info.DoctorNumber
  8555. flow.OriginalRxFile = rx_encoded
  8556. flow.OriginalValue = encoded
  8557. flow.SignCertDn = res2.Output.SignCertDn
  8558. flow.SignCertSn = res2.Output.SignCertSn
  8559. flow.Mtime = time.Now().Unix()
  8560. service.Saveflow(flow)
  8561. c.ServeSuccessJSON(map[string]interface{}{
  8562. "msg": "预签名成功",
  8563. })
  8564. } else {
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. }
  8569. }
  8570. func (c *HisApiController) GetCFYLJG003() {
  8571. admin_user_id, _ := c.GetInt64("admin_user_id")
  8572. his_patient_id, _ := c.GetInt64("his_patient_id")
  8573. record_time := c.GetString("record_time")
  8574. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8575. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8577. flow, _ := service.Getflowtwo(his.Number)
  8578. patient_id, _ := c.GetInt64("patient_id")
  8579. timeLayout := "2006-01-02"
  8580. loc, _ := time.LoadLocation("Local")
  8581. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8582. if err != nil {
  8583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8584. return
  8585. }
  8586. recordDateTime := theTime.Unix()
  8587. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8588. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8589. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8590. dept, _ := service.GetDepartMentDetail(info.Departments)
  8591. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8592. var cFYLJG003 models.CFYLJG003
  8593. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8594. cFYLJG003.HiRxno = flow.HiRxno
  8595. cFYLJG003.MdtrtID = flow.MID
  8596. cFYLJG003.PatnName = his.PsnName
  8597. cFYLJG003.Certno = his.Certno
  8598. cFYLJG003.FixmedinsName = miConfig.OrgName
  8599. cFYLJG003.FixmedinsCode = miConfig.Code
  8600. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8601. cFYLJG003.PrscDrName = doctor_info.UserName
  8602. cFYLJG003.PharDeptName = dept.Name
  8603. cFYLJG003.PharDeptCode = dept.Number
  8604. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8605. cFYLJG003.PharName = "孙莉侠"
  8606. cFYLJG003.PharPracCertNo = "060399"
  8607. cFYLJG003.PharCode = "HY340621000425"
  8608. cFYLJG003.PharCertType = "01"
  8609. cFYLJG003.PharCertno = ""
  8610. } else {
  8611. cFYLJG003.PharName = "彭斯遥"
  8612. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8613. cFYLJG003.PharCode = "HY440309002107"
  8614. cFYLJG003.PharCertType = "01"
  8615. cFYLJG003.PharCertno = "430482199408260023"
  8616. }
  8617. cFYLJG003.RxFile = flow.RxFile
  8618. cFYLJG003.SignDigest = flow.SignDigest
  8619. cFYLJG003.FixmedinsCode = miConfig.Code
  8620. cFYLJG003.PsnCertType = his.PsnCertType
  8621. tempTime2 := time.Unix(info.Ctime, 0)
  8622. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8623. cFYLJG003.PharChkTime = timeFormatTwo
  8624. if miConfig.MdtrtareaAdmvs == "340699" {
  8625. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8626. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8627. var res AHResult003
  8628. var respJSON2 map[string]interface{}
  8629. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8632. return
  8633. }
  8634. userJSONBytes2, _ := json.Marshal(respJSON2)
  8635. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8636. utils.ErrorLog("解析失败:%v", err)
  8637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8638. return
  8639. }
  8640. {
  8641. c.ServeSuccessJSON(map[string]interface{}{
  8642. "info": res,
  8643. })
  8644. }
  8645. } else {
  8646. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8647. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8648. var res ResultCFYLJG003
  8649. var respJSON2 map[string]interface{}
  8650. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8653. return
  8654. }
  8655. userJSONBytes2, _ := json.Marshal(respJSON2)
  8656. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8657. utils.ErrorLog("解析失败:%v", err)
  8658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8659. return
  8660. }
  8661. if res.Infcode == -1 {
  8662. c.ServeSuccessJSON(map[string]interface{}{
  8663. "failed_code": -10,
  8664. "msg": res.ErrMsg,
  8665. })
  8666. return
  8667. } else {
  8668. c.ServeSuccessJSON(map[string]interface{}{
  8669. "info": res.Output,
  8670. })
  8671. }
  8672. }
  8673. }
  8674. func (c *HisApiController) GetCFYLJG004() {
  8675. admin_user_id, _ := c.GetInt64("admin_user_id")
  8676. his_patient_id, _ := c.GetInt64("his_patient_id")
  8677. record_time := c.GetString("record_time")
  8678. admin_user_id = 3626
  8679. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8680. //id, _ := c.GetInt64("id")
  8681. admin_user_id = 3626
  8682. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8683. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8684. flow, _ := service.Getflowtwo(his.Number)
  8685. //id = 3
  8686. patient_id, _ := c.GetInt64("patient_id")
  8687. //patient_id = 23834
  8688. //record_time = "2023-09-18"
  8689. timeLayout := "2006-01-02"
  8690. loc, _ := time.LoadLocation("Local")
  8691. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8692. if err != nil {
  8693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8694. return
  8695. }
  8696. recordDateTime := theTime.Unix()
  8697. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8698. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8699. var cFYLJG004 models.CFYLJG004
  8700. cFYLJG004.HiRxno = flow.HiRxno
  8701. cFYLJG004.FixmedinsCode = miConfig.Code
  8702. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8703. cFYLJG004.UndoDrCertType = "01"
  8704. cFYLJG004.UndoRea = "撤销处方"
  8705. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8706. cFYLJG004.UndoDrName = doctor_info.UserName
  8707. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8708. if miConfig.MdtrtareaAdmvs == "340699" {
  8709. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8710. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8711. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8712. } else {
  8713. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8714. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8715. var res ResultCFYLJG004
  8716. var respJSON2 map[string]interface{}
  8717. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8720. return
  8721. }
  8722. userJSONBytes2, _ := json.Marshal(respJSON2)
  8723. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8724. utils.ErrorLog("解析失败:%v", err)
  8725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8726. return
  8727. }
  8728. if res.Infcode == -1 {
  8729. c.ServeSuccessJSON(map[string]interface{}{
  8730. "failed_code": -10,
  8731. "msg": res.ErrMsg,
  8732. })
  8733. return
  8734. } else {
  8735. flow.Status = 0
  8736. service.Saveflow(flow)
  8737. c.ServeSuccessJSON(map[string]interface{}{
  8738. "msg": "撤销成功",
  8739. })
  8740. return
  8741. }
  8742. }
  8743. }
  8744. func (c *HisApiController) GetCFYLJG005() {
  8745. admin_user_id, _ := c.GetInt64("admin_user_id")
  8746. his_patient_id, _ := c.GetInt64("his_patient_id")
  8747. //record_time := c.GetString("record_time")
  8748. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8749. //id, _ := c.GetInt64("id")
  8750. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8751. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8752. flow, _ := service.Getflowtwo(his.Number)
  8753. //id = 3
  8754. var cFYLJG005 models.CFYLJG005
  8755. //patient_id, _ := c.GetInt64("patient_id")
  8756. cFYLJG005.HiRxno = flow.HiRxno
  8757. cFYLJG005.MdtrtID = flow.MID
  8758. cFYLJG005.EcToken = ""
  8759. cFYLJG005.PsnName = his.Name
  8760. cFYLJG005.PsnCertType = "01"
  8761. cFYLJG005.Certno = his.IdCardNo
  8762. if miConfig.MdtrtareaAdmvs == "340699" {
  8763. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8764. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8765. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8766. } else {
  8767. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8768. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8769. var res ResultCFYLJG005
  8770. var respJSON2 map[string]interface{}
  8771. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8774. return
  8775. }
  8776. userJSONBytes2, _ := json.Marshal(respJSON2)
  8777. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8778. utils.ErrorLog("解析失败:%v", err)
  8779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8780. return
  8781. }
  8782. if res.Infcode == -1 {
  8783. c.ServeSuccessJSON(map[string]interface{}{
  8784. "failed_code": -10,
  8785. "msg": res.ErrMsg,
  8786. })
  8787. return
  8788. } else {
  8789. c.ServeSuccessJSON(map[string]interface{}{
  8790. "info": res.Output,
  8791. })
  8792. return
  8793. }
  8794. }
  8795. }
  8796. func (c *HisApiController) GetCFYLJG006() {
  8797. admin_user_id, _ := c.GetInt64("admin_user_id")
  8798. his_patient_id, _ := c.GetInt64("his_patient_id")
  8799. admin_user_id = 3626
  8800. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8801. //id, _ := c.GetInt64("id")
  8802. admin_user_id = 3626
  8803. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8804. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8805. flow, _ := service.Getflowtwo(his.Number)
  8806. //id = 3
  8807. patient_id, _ := c.GetInt64("patient_id")
  8808. var cFYLJG006 models.CFYLJG006
  8809. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8810. cFYLJG006.HiRxno = flow.HiRxno
  8811. cFYLJG006.MdtrtID = flow.MID
  8812. cFYLJG006.PsnName = patient.Name
  8813. cFYLJG006.PsnCertType = "01"
  8814. cFYLJG006.Certno = patient.IdCardNo
  8815. if miConfig.MdtrtareaAdmvs == "340699" {
  8816. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8817. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8818. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8819. } else {
  8820. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8821. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8822. var res ResultCFYLJG006
  8823. var respJSON2 map[string]interface{}
  8824. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8827. return
  8828. }
  8829. userJSONBytes2, _ := json.Marshal(respJSON2)
  8830. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8831. utils.ErrorLog("解析失败:%v", err)
  8832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8833. return
  8834. }
  8835. if res.Infcode == -1 {
  8836. c.ServeSuccessJSON(map[string]interface{}{
  8837. "failed_code": -10,
  8838. "msg": res.ErrMsg,
  8839. })
  8840. return
  8841. } else {
  8842. c.ServeSuccessJSON(map[string]interface{}{
  8843. "info": res.Output,
  8844. })
  8845. return
  8846. }
  8847. }
  8848. }
  8849. func (c *HisApiController) GetCFYLJG007() {
  8850. admin_user_id, _ := c.GetInt64("admin_user_id")
  8851. his_patient_id, _ := c.GetInt64("his_patient_id")
  8852. admin_user_id = 3626
  8853. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8854. //id, _ := c.GetInt64("id")
  8855. admin_user_id = 3626
  8856. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8857. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8858. flow, _ := service.Getflowtwo(his.Number)
  8859. //id = 3
  8860. patient_id, _ := c.GetInt64("patient_id")
  8861. var cFYLJG007 models.CFYLJG007
  8862. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8863. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8864. cFYLJG007.HiRxno = flow.HiRxno
  8865. cFYLJG007.MdtrtID = flow.MID
  8866. cFYLJG007.PsnNo = his.PsnNo
  8867. cFYLJG007.PsnCertType = "01"
  8868. cFYLJG007.Certno = patient.IdCardNo
  8869. cFYLJG007.PsnName = patient.Name
  8870. if miConfig.MdtrtareaAdmvs == "340699" {
  8871. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8872. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8873. } else {
  8874. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8875. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8876. var res ResultCFYLJG007
  8877. var respJSON2 map[string]interface{}
  8878. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8881. return
  8882. }
  8883. userJSONBytes2, _ := json.Marshal(respJSON2)
  8884. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8885. utils.ErrorLog("解析失败:%v", err)
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. if res.Infcode == -1 {
  8890. c.ServeSuccessJSON(map[string]interface{}{
  8891. "failed_code": -10,
  8892. "msg": res.ErrMsg,
  8893. })
  8894. return
  8895. } else {
  8896. c.ServeSuccessJSON(map[string]interface{}{
  8897. "info": res,
  8898. })
  8899. return
  8900. }
  8901. }
  8902. }
  8903. func (c *HisApiController) GetCFYLJG008() {
  8904. admin_user_id, _ := c.GetInt64("admin_user_id")
  8905. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8906. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8907. var cFYLJG008 models.CFYLJG008
  8908. //id, _ := c.GetInt64("id")
  8909. patient_id, _ := c.GetInt64("patient_id")
  8910. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8911. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8912. //id = 3
  8913. //flow, _ := service.Getflow(id)
  8914. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8915. //
  8916. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8917. //patient_id, _ := c.GetInt64("patient_id")
  8918. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8919. record_time := c.GetString("record_time")
  8920. admin_user_id = 3626
  8921. patient_id = 19424
  8922. //his_patient_id = 263947
  8923. record_time = "2023-08-29"
  8924. timeLayout := "2006-01-02"
  8925. loc, _ := time.LoadLocation("Local")
  8926. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8927. if err != nil {
  8928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8929. return
  8930. }
  8931. recordDateTime := theTime.Unix()
  8932. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8933. cFYLJG008.FixmedinsName = ""
  8934. cFYLJG008.Lat = ""
  8935. cFYLJG008.Lng = ""
  8936. cFYLJG008.OrderType = "1"
  8937. cFYLJG008.PoolareaNo = ""
  8938. cFYLJG008.Lng = ""
  8939. cFYLJG008.PageNum = 1
  8940. cFYLJG008.PageSize = 10
  8941. var MPI models.MedinsProdInvChgDDTO
  8942. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8943. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8944. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8945. if miConfig.MdtrtareaAdmvs == "340699" {
  8946. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8947. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8948. } else {
  8949. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8950. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8951. var res ResultCFYLJG008
  8952. var respJSON2 map[string]interface{}
  8953. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8956. return
  8957. }
  8958. userJSONBytes2, _ := json.Marshal(respJSON2)
  8959. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8960. utils.ErrorLog("解析失败:%v", err)
  8961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8962. return
  8963. }
  8964. if res.Infcode == -1 {
  8965. c.ServeSuccessJSON(map[string]interface{}{
  8966. "failed_code": -10,
  8967. "msg": res.ErrMsg,
  8968. })
  8969. return
  8970. } else {
  8971. c.ServeSuccessJSON(map[string]interface{}{
  8972. "info": res.Output,
  8973. })
  8974. return
  8975. }
  8976. }
  8977. }
  8978. func (c *HisApiController) GetBL4201A() {
  8979. order_id, _ := c.GetInt64("order_id")
  8980. admin_user_id, _ := c.GetInt64("admin_user_id")
  8981. order, _ := service.GetHisOrderByIDTwo(order_id)
  8982. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8983. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8984. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8985. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8986. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8987. department, _ := service.GetDepartMentDetail(his.Departments)
  8988. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8989. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8990. if order.ID == 0 {
  8991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8992. return
  8993. }
  8994. var struct4201A models.Struct4201A
  8995. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8996. for _, items := range order_info {
  8997. memo := make(map[string]interface{})
  8998. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8999. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9000. fsiOPFLD.MedType = "14"
  9001. fsiOPFLD.BkkpSn = items.FeedetlSn
  9002. fsiOPFLD.FixmedinsCode = miConfig.Code
  9003. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9004. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9005. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9006. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9007. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9008. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9009. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9010. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9011. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9012. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9013. fsiOPFLD.BilgDeptName = department.Name
  9014. fsiOPFLD.BilgDeptCodg = department.Number
  9015. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9016. fsiOPFLD.BilgDrName = doctor.UserName
  9017. fsiOPFLD.MedChrgitmType = "09"
  9018. memo["hosp_appr_flag"] = "1"
  9019. memo["invoice_no"] = order.MdtrtId
  9020. memo["memo"] = "自费"
  9021. bytesData, _ := json.Marshal(memo)
  9022. fsiOPFLD.Memo = string(bytesData)
  9023. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9024. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9025. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9026. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9027. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9028. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9029. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9030. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9031. fsiOPFLD.BilgDeptName = department.Name
  9032. fsiOPFLD.BilgDeptCodg = department.Number
  9033. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9034. fsiOPFLD.BilgDrName = doctor.UserName
  9035. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9036. case 0:
  9037. break
  9038. case 1:
  9039. fsiOPFLD.MedChrgitmType = "14"
  9040. break
  9041. case 2:
  9042. fsiOPFLD.MedChrgitmType = "05"
  9043. break
  9044. case 3:
  9045. fsiOPFLD.MedChrgitmType = "03"
  9046. break
  9047. case 4:
  9048. fsiOPFLD.MedChrgitmType = "03"
  9049. break
  9050. case 5:
  9051. fsiOPFLD.MedChrgitmType = "08"
  9052. break
  9053. case 6:
  9054. fsiOPFLD.MedChrgitmType = "14"
  9055. break
  9056. case 7:
  9057. fsiOPFLD.MedChrgitmType = "14"
  9058. break
  9059. case 8:
  9060. fsiOPFLD.MedChrgitmType = "03"
  9061. break
  9062. case 9:
  9063. fsiOPFLD.MedChrgitmType = "14"
  9064. break
  9065. case 10:
  9066. fsiOPFLD.MedChrgitmType = "14"
  9067. break
  9068. case 11:
  9069. fsiOPFLD.MedChrgitmType = "06"
  9070. break
  9071. case 12:
  9072. fsiOPFLD.MedChrgitmType = "12"
  9073. break
  9074. case 13:
  9075. fsiOPFLD.MedChrgitmType = "01"
  9076. break
  9077. case 14:
  9078. fsiOPFLD.MedChrgitmType = "04"
  9079. break
  9080. case 15:
  9081. fsiOPFLD.MedChrgitmType = "14"
  9082. break
  9083. }
  9084. memo["hosp_appr_flag"] = "1"
  9085. memo["invoice_no"] = order.MdtrtId
  9086. memo["memo"] = "自费"
  9087. bytesData, _ := json.Marshal(memo)
  9088. fsiOPFLD.Memo = string(bytesData)
  9089. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9090. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9091. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9092. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9093. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9094. fsiOPFLD.BilgDeptName = department.Name
  9095. fsiOPFLD.BilgDeptCodg = department.Number
  9096. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9097. fsiOPFLD.BilgDrName = doctor.UserName
  9098. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9099. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9100. fsiOPFLD.MedChrgitmType = "08"
  9101. memo["hosp_appr_flag"] = "1"
  9102. memo["invoice_no"] = order.MdtrtId
  9103. memo["memo"] = "自费"
  9104. bytesData, _ := json.Marshal(memo)
  9105. fsiOPFLD.Memo = string(bytesData)
  9106. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9107. }
  9108. }
  9109. }
  9110. for _, items := range order_info_two {
  9111. memo := make(map[string]interface{})
  9112. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9113. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9114. fsiOPFLD.MedType = "14"
  9115. fsiOPFLD.BkkpSn = items.FeedetlSn
  9116. fsiOPFLD.FixmedinsCode = miConfig.Code
  9117. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9118. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9119. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9120. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9121. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9122. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9123. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9124. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9125. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9126. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9127. fsiOPFLD.BilgDeptName = department.Name
  9128. fsiOPFLD.BilgDeptCodg = department.Number
  9129. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9130. fsiOPFLD.BilgDrName = doctor.UserName
  9131. fsiOPFLD.MedChrgitmType = "09"
  9132. memo["hosp_appr_flag"] = "1"
  9133. memo["invoice_no"] = order.MdtrtId
  9134. memo["memo"] = "自费"
  9135. bytesData, _ := json.Marshal(memo)
  9136. fsiOPFLD.Memo = string(bytesData)
  9137. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9138. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9139. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9140. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9141. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9142. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9143. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9144. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9145. fsiOPFLD.BilgDeptName = department.Name
  9146. fsiOPFLD.BilgDeptCodg = department.Number
  9147. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9148. fsiOPFLD.BilgDrName = doctor.UserName
  9149. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9150. case 0:
  9151. break
  9152. case 1:
  9153. fsiOPFLD.MedChrgitmType = "14"
  9154. break
  9155. case 2:
  9156. fsiOPFLD.MedChrgitmType = "05"
  9157. break
  9158. case 3:
  9159. fsiOPFLD.MedChrgitmType = "03"
  9160. break
  9161. case 4:
  9162. fsiOPFLD.MedChrgitmType = "03"
  9163. break
  9164. case 5:
  9165. fsiOPFLD.MedChrgitmType = "08"
  9166. break
  9167. case 6:
  9168. fsiOPFLD.MedChrgitmType = "14"
  9169. break
  9170. case 7:
  9171. fsiOPFLD.MedChrgitmType = "14"
  9172. break
  9173. case 8:
  9174. fsiOPFLD.MedChrgitmType = "03"
  9175. break
  9176. case 9:
  9177. fsiOPFLD.MedChrgitmType = "14"
  9178. break
  9179. case 10:
  9180. fsiOPFLD.MedChrgitmType = "14"
  9181. break
  9182. case 11:
  9183. fsiOPFLD.MedChrgitmType = "06"
  9184. break
  9185. case 12:
  9186. fsiOPFLD.MedChrgitmType = "12"
  9187. break
  9188. case 13:
  9189. fsiOPFLD.MedChrgitmType = "01"
  9190. break
  9191. case 14:
  9192. fsiOPFLD.MedChrgitmType = "04"
  9193. break
  9194. case 15:
  9195. fsiOPFLD.MedChrgitmType = "14"
  9196. break
  9197. }
  9198. memo["hosp_appr_flag"] = "1"
  9199. memo["invoice_no"] = order.MdtrtId
  9200. memo["memo"] = "自费"
  9201. bytesData, _ := json.Marshal(memo)
  9202. fsiOPFLD.Memo = string(bytesData)
  9203. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9204. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9205. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9206. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9207. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9208. fsiOPFLD.BilgDeptName = department.Name
  9209. fsiOPFLD.BilgDeptCodg = department.Number
  9210. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9211. fsiOPFLD.BilgDrName = doctor.UserName
  9212. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9213. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9214. fsiOPFLD.MedChrgitmType = "08"
  9215. memo["hosp_appr_flag"] = "1"
  9216. memo["invoice_no"] = order.MdtrtId
  9217. memo["memo"] = "自费"
  9218. bytesData, _ := json.Marshal(memo)
  9219. fsiOPFLD.Memo = string(bytesData)
  9220. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9221. }
  9222. }
  9223. }
  9224. fmt.Println(fsiOPFLDs)
  9225. struct4201A.Fopfd = fsiOPFLDs
  9226. fmt.Println(struct4201A.Fopfd)
  9227. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9228. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9229. var res2 ResultSix
  9230. var respJSON2 map[string]interface{}
  9231. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9234. return
  9235. }
  9236. userJSONBytes2, _ := json.Marshal(respJSON2)
  9237. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9238. utils.ErrorLog("解析失败:%v", err)
  9239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9240. return
  9241. }
  9242. if res2.Infcode != 0 {
  9243. c.ServeSuccessJSON(map[string]interface{}{
  9244. "failed_code": -10,
  9245. "msg": res2.ErrMsg,
  9246. })
  9247. return
  9248. } else {
  9249. order.IsUploadOrderInfo = 1
  9250. service.UpdateOrder(order)
  9251. c.ServeSuccessJSON(map[string]interface{}{
  9252. "msg": "上传成功",
  9253. })
  9254. }
  9255. }
  9256. func (c *HisApiController) Get3103() {
  9257. admin_user_id, _ := c.GetInt64("admin_user_id")
  9258. warm_type, _ := c.GetInt64("warm_type")
  9259. fk_state, _ := c.GetInt64("fk_state")
  9260. warm_ids := c.GetString("warm_ids")
  9261. desc := c.GetString("desc")
  9262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9263. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9264. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9265. saveLog(result, requestLog, "3103", "反馈")
  9266. var res2 ResultSix3103
  9267. var respJSON2 map[string]interface{}
  9268. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9271. return
  9272. }
  9273. userJSONBytes2, _ := json.Marshal(respJSON2)
  9274. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9275. utils.ErrorLog("解析失败:%v", err)
  9276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9277. return
  9278. }
  9279. if res2.Infcode != 0 {
  9280. c.ServeSuccessJSON(map[string]interface{}{
  9281. "failed_code": -10,
  9282. "msg": res2.ErrMsg,
  9283. })
  9284. return
  9285. } else {
  9286. c.ServeSuccessJSON(map[string]interface{}{
  9287. "msg": "反馈成功",
  9288. })
  9289. return
  9290. }
  9291. }
  9292. func (c *HisApiController) Get4201A() {
  9293. order_id, _ := c.GetInt64("order_id")
  9294. admin_user_id, _ := c.GetInt64("admin_user_id")
  9295. order, _ := service.GetHisOrderByIDTwo(order_id)
  9296. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9297. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9298. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9299. //order_info = append(order_info, order_info_two...)
  9300. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9302. department, _ := service.GetDepartMentDetail(his.Departments)
  9303. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9304. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9305. if order.ID == 0 {
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9307. return
  9308. }
  9309. var struct4201A models.Struct4201A
  9310. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9311. for _, items := range order_info {
  9312. memo := make(map[string]interface{})
  9313. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9314. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9315. fsiOPFLD.MedType = "14"
  9316. fsiOPFLD.BkkpSn = items.FeedetlSn
  9317. fsiOPFLD.FixmedinsCode = miConfig.Code
  9318. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9319. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9320. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9321. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9322. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9323. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9324. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9325. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9326. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9327. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9328. fsiOPFLD.BilgDeptName = department.Name
  9329. fsiOPFLD.BilgDeptCodg = department.Number
  9330. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9331. fsiOPFLD.BilgDrName = doctor.UserName
  9332. fsiOPFLD.MedChrgitmType = "09"
  9333. memo["hosp_appr_flag"] = "1"
  9334. memo["invoice_no"] = order.MdtrtId
  9335. memo["memo"] = "自费"
  9336. bytesData, _ := json.Marshal(memo)
  9337. fsiOPFLD.Memo = string(bytesData)
  9338. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9339. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9340. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9341. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9342. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9343. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9344. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9345. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9346. fsiOPFLD.BilgDeptName = department.Name
  9347. fsiOPFLD.BilgDeptCodg = department.Number
  9348. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9349. fsiOPFLD.BilgDrName = doctor.UserName
  9350. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9351. case 0:
  9352. break
  9353. case 1:
  9354. fsiOPFLD.MedChrgitmType = "14"
  9355. break
  9356. case 2:
  9357. fsiOPFLD.MedChrgitmType = "05"
  9358. break
  9359. case 3:
  9360. fsiOPFLD.MedChrgitmType = "03"
  9361. break
  9362. case 4:
  9363. fsiOPFLD.MedChrgitmType = "03"
  9364. break
  9365. case 5:
  9366. fsiOPFLD.MedChrgitmType = "08"
  9367. break
  9368. case 6:
  9369. fsiOPFLD.MedChrgitmType = "14"
  9370. break
  9371. case 7:
  9372. fsiOPFLD.MedChrgitmType = "14"
  9373. break
  9374. case 8:
  9375. fsiOPFLD.MedChrgitmType = "03"
  9376. break
  9377. case 9:
  9378. fsiOPFLD.MedChrgitmType = "14"
  9379. break
  9380. case 10:
  9381. fsiOPFLD.MedChrgitmType = "14"
  9382. break
  9383. case 11:
  9384. fsiOPFLD.MedChrgitmType = "06"
  9385. break
  9386. case 12:
  9387. fsiOPFLD.MedChrgitmType = "12"
  9388. break
  9389. case 13:
  9390. fsiOPFLD.MedChrgitmType = "01"
  9391. break
  9392. case 14:
  9393. fsiOPFLD.MedChrgitmType = "04"
  9394. break
  9395. case 15:
  9396. fsiOPFLD.MedChrgitmType = "14"
  9397. break
  9398. }
  9399. memo["hosp_appr_flag"] = "1"
  9400. memo["invoice_no"] = order.MdtrtId
  9401. memo["memo"] = "自费"
  9402. bytesData, _ := json.Marshal(memo)
  9403. fsiOPFLD.Memo = string(bytesData)
  9404. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9405. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9406. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9407. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9408. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9409. fsiOPFLD.BilgDeptName = department.Name
  9410. fsiOPFLD.BilgDeptCodg = department.Number
  9411. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9412. fsiOPFLD.BilgDrName = doctor.UserName
  9413. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9414. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9415. fsiOPFLD.MedChrgitmType = "08"
  9416. memo["hosp_appr_flag"] = "1"
  9417. memo["invoice_no"] = order.MdtrtId
  9418. memo["memo"] = "自费"
  9419. bytesData, _ := json.Marshal(memo)
  9420. fsiOPFLD.Memo = string(bytesData)
  9421. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9422. }
  9423. }
  9424. }
  9425. for _, items := range order_info_two {
  9426. memo := make(map[string]interface{})
  9427. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9428. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9429. fsiOPFLD.MedType = "14"
  9430. fsiOPFLD.BkkpSn = items.FeedetlSn
  9431. fsiOPFLD.FixmedinsCode = miConfig.Code
  9432. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9433. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9434. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9435. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9436. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9437. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9438. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9439. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9440. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9441. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9442. fsiOPFLD.BilgDeptName = department.Name
  9443. fsiOPFLD.BilgDeptCodg = department.Number
  9444. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9445. fsiOPFLD.BilgDrName = doctor.UserName
  9446. fsiOPFLD.MedChrgitmType = "09"
  9447. memo["hosp_appr_flag"] = "1"
  9448. memo["invoice_no"] = order.MdtrtId
  9449. memo["memo"] = "自费"
  9450. bytesData, _ := json.Marshal(memo)
  9451. fsiOPFLD.Memo = string(bytesData)
  9452. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9453. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9454. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9455. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9456. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9457. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9458. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9459. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9460. fsiOPFLD.BilgDeptName = department.Name
  9461. fsiOPFLD.BilgDeptCodg = department.Number
  9462. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9463. fsiOPFLD.BilgDrName = doctor.UserName
  9464. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9465. case 0:
  9466. break
  9467. case 1:
  9468. fsiOPFLD.MedChrgitmType = "14"
  9469. break
  9470. case 2:
  9471. fsiOPFLD.MedChrgitmType = "05"
  9472. break
  9473. case 3:
  9474. fsiOPFLD.MedChrgitmType = "03"
  9475. break
  9476. case 4:
  9477. fsiOPFLD.MedChrgitmType = "03"
  9478. break
  9479. case 5:
  9480. fsiOPFLD.MedChrgitmType = "08"
  9481. break
  9482. case 6:
  9483. fsiOPFLD.MedChrgitmType = "14"
  9484. break
  9485. case 7:
  9486. fsiOPFLD.MedChrgitmType = "14"
  9487. break
  9488. case 8:
  9489. fsiOPFLD.MedChrgitmType = "03"
  9490. break
  9491. case 9:
  9492. fsiOPFLD.MedChrgitmType = "14"
  9493. break
  9494. case 10:
  9495. fsiOPFLD.MedChrgitmType = "14"
  9496. break
  9497. case 11:
  9498. fsiOPFLD.MedChrgitmType = "06"
  9499. break
  9500. case 12:
  9501. fsiOPFLD.MedChrgitmType = "12"
  9502. break
  9503. case 13:
  9504. fsiOPFLD.MedChrgitmType = "01"
  9505. break
  9506. case 14:
  9507. fsiOPFLD.MedChrgitmType = "04"
  9508. break
  9509. case 15:
  9510. fsiOPFLD.MedChrgitmType = "14"
  9511. break
  9512. }
  9513. memo["hosp_appr_flag"] = "1"
  9514. memo["invoice_no"] = order.MdtrtId
  9515. memo["memo"] = "自费"
  9516. bytesData, _ := json.Marshal(memo)
  9517. fsiOPFLD.Memo = string(bytesData)
  9518. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9519. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9520. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9521. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9522. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9523. fsiOPFLD.BilgDeptName = department.Name
  9524. fsiOPFLD.BilgDeptCodg = department.Number
  9525. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9526. fsiOPFLD.BilgDrName = doctor.UserName
  9527. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9528. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9529. fsiOPFLD.MedChrgitmType = "08"
  9530. memo["hosp_appr_flag"] = "1"
  9531. memo["invoice_no"] = order.MdtrtId
  9532. memo["memo"] = "自费"
  9533. bytesData, _ := json.Marshal(memo)
  9534. fsiOPFLD.Memo = string(bytesData)
  9535. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9536. }
  9537. }
  9538. }
  9539. fmt.Println(fsiOPFLDs)
  9540. struct4201A.Fopfd = fsiOPFLDs
  9541. fmt.Println(struct4201A.Fopfd)
  9542. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9543. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9544. var res2 ResultSix
  9545. var respJSON2 map[string]interface{}
  9546. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9549. return
  9550. }
  9551. userJSONBytes2, _ := json.Marshal(respJSON2)
  9552. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9553. utils.ErrorLog("解析失败:%v", err)
  9554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9555. return
  9556. }
  9557. if res2.Infcode != 0 {
  9558. c.ServeSuccessJSON(map[string]interface{}{
  9559. "failed_code": -10,
  9560. "msg": res2.ErrMsg,
  9561. })
  9562. return
  9563. } else {
  9564. order.IsUploadOrderInfo = 1
  9565. service.UpdateOrder(order)
  9566. c.ServeSuccessJSON(map[string]interface{}{
  9567. "msg": "上传成功",
  9568. })
  9569. }
  9570. }
  9571. func (c *HisApiController) Get4202() {
  9572. order_id, _ := c.GetInt64("order_id")
  9573. admin_user_id, _ := c.GetInt64("admin_user_id")
  9574. order, _ := service.GetHisOrderByIDTwo(order_id)
  9575. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9576. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9577. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9578. if order.ID == 0 {
  9579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9580. return
  9581. }
  9582. var struct4202 models.Struct4202
  9583. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9584. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9585. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9586. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9587. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9588. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9589. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9590. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9591. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9592. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9593. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9594. var config []*models.HisXtDiagnoseConfig
  9595. for _, item := range diagnosis_ids {
  9596. id, _ := strconv.ParseInt(item, 10, 64)
  9597. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9598. config = append(config, &diagnosisConfig)
  9599. }
  9600. var tempDiaginfos []models.OwnPayPatnDiagListD
  9601. for index, item := range config {
  9602. if index == 0 {
  9603. var tempDiaginfo models.OwnPayPatnDiagListD
  9604. tempDiaginfo.InoutDiagType = "1"
  9605. tempDiaginfo.DiagCode = item.CountryCode
  9606. tempDiaginfo.DiagName = item.CountryContentName
  9607. tempDiaginfo.DiagType = "1"
  9608. tempDiaginfo.DiagSrtNo = "1"
  9609. tempDiaginfo.MaindiagFlag = "1"
  9610. tempDiaginfo.ValiFlag = "1"
  9611. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9612. } else {
  9613. var tempDiaginfo models.OwnPayPatnDiagListD
  9614. tempDiaginfo.DiagCode = item.CountryCode
  9615. tempDiaginfo.DiagName = item.CountryContentName
  9616. tempDiaginfo.DiagType = "2"
  9617. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9618. tempDiaginfo.MaindiagFlag = "0"
  9619. tempDiaginfo.ValiFlag = "1"
  9620. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9621. }
  9622. }
  9623. struct4202.ODiagListD = tempDiaginfos
  9624. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9625. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9626. var res2 ResultSix
  9627. var respJSON2 map[string]interface{}
  9628. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9631. return
  9632. }
  9633. userJSONBytes2, _ := json.Marshal(respJSON2)
  9634. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9635. utils.ErrorLog("解析失败:%v", err)
  9636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9637. return
  9638. }
  9639. if res2.Infcode != 0 {
  9640. c.ServeSuccessJSON(map[string]interface{}{
  9641. "failed_code": -10,
  9642. "msg": res2.ErrMsg,
  9643. })
  9644. return
  9645. } else {
  9646. order.IsUploadDiagnose = 1
  9647. service.UpdateOrder(order)
  9648. c.ServeSuccessJSON(map[string]interface{}{
  9649. "msg": "上传成功",
  9650. })
  9651. }
  9652. }
  9653. func (c *HisApiController) Get4203() {
  9654. admin_user_id, _ := c.GetInt64("admin_user_id")
  9655. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9656. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9657. order_id, _ := c.GetInt64("order_id")
  9658. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9659. number := ""
  9660. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9661. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9662. if his.ID == 0 {
  9663. number = hospital.Number
  9664. } else {
  9665. number = his.Number
  9666. }
  9667. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9668. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9669. var res2 ResultSix
  9670. var respJSON2 map[string]interface{}
  9671. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9674. return
  9675. }
  9676. userJSONBytes2, _ := json.Marshal(respJSON2)
  9677. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9678. utils.ErrorLog("解析失败:%v", err)
  9679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9680. return
  9681. }
  9682. if res2.Infcode != 0 {
  9683. c.ServeSuccessJSON(map[string]interface{}{
  9684. "failed_code": -10,
  9685. "msg": res2.ErrMsg,
  9686. })
  9687. return
  9688. } else {
  9689. order.IsUploadSuccess = 1
  9690. service.UpdateOrderTwo(order)
  9691. c.ServeSuccessJSON(map[string]interface{}{
  9692. "msg": "上传成功",
  9693. })
  9694. }
  9695. }
  9696. func (c *HisApiController) Get4205() {
  9697. order_id, _ := c.GetInt64("order_id")
  9698. admin_user_id, _ := c.GetInt64("admin_user_id")
  9699. fapiao_code := c.GetString("fapiao_code")
  9700. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9701. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9702. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9703. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9704. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9705. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9706. //order_info = append(order_info, order_info_two...)
  9707. department, _ := service.GetDepartMentDetail(his.Departments)
  9708. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9709. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9710. if order.ID == 0 {
  9711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9712. return
  9713. }
  9714. var struct4201A models.Struct4201A
  9715. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9716. for _, items := range order_info {
  9717. memo := make(map[string]interface{})
  9718. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9719. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9720. fsiOPFLD.MedType = pre.MedType
  9721. fsiOPFLD.FixmedinsCode = miConfig.Code
  9722. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9723. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9724. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9725. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.Cnt*items.Pric)
  9726. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9727. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9728. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9729. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9730. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9731. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9732. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9733. fsiOPFLD.BilgDeptName = department.Name
  9734. fsiOPFLD.BilgDeptCodg = department.Number
  9735. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9736. fsiOPFLD.BilgDrName = doctor.UserName
  9737. fsiOPFLD.MedChrgitmType = "09"
  9738. memo["hosp_appr_flag"] = "1"
  9739. memo["invoice_no"] = fapiao_code
  9740. memo["memo"] = "自费"
  9741. bytesData, _ := json.Marshal(memo)
  9742. fsiOPFLD.Memo = string(bytesData)
  9743. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9744. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9745. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9746. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9747. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9748. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9749. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9750. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9751. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9752. fsiOPFLD.BilgDeptName = department.Name
  9753. fsiOPFLD.BilgDeptCodg = department.Number
  9754. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9755. fsiOPFLD.BilgDrName = doctor.UserName
  9756. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9757. case 0:
  9758. break
  9759. case 1:
  9760. fsiOPFLD.MedChrgitmType = "14"
  9761. break
  9762. case 2:
  9763. fsiOPFLD.MedChrgitmType = "05"
  9764. break
  9765. case 3:
  9766. fsiOPFLD.MedChrgitmType = "03"
  9767. break
  9768. case 4:
  9769. fsiOPFLD.MedChrgitmType = "03"
  9770. break
  9771. case 5:
  9772. fsiOPFLD.MedChrgitmType = "08"
  9773. break
  9774. case 6:
  9775. fsiOPFLD.MedChrgitmType = "14"
  9776. break
  9777. case 7:
  9778. fsiOPFLD.MedChrgitmType = "14"
  9779. break
  9780. case 8:
  9781. fsiOPFLD.MedChrgitmType = "03"
  9782. break
  9783. case 9:
  9784. fsiOPFLD.MedChrgitmType = "14"
  9785. break
  9786. case 10:
  9787. fsiOPFLD.MedChrgitmType = "14"
  9788. break
  9789. case 11:
  9790. fsiOPFLD.MedChrgitmType = "06"
  9791. break
  9792. case 12:
  9793. fsiOPFLD.MedChrgitmType = "12"
  9794. break
  9795. case 13:
  9796. fsiOPFLD.MedChrgitmType = "01"
  9797. break
  9798. case 14:
  9799. fsiOPFLD.MedChrgitmType = "04"
  9800. break
  9801. case 15:
  9802. fsiOPFLD.MedChrgitmType = "14"
  9803. break
  9804. }
  9805. memo["hosp_appr_flag"] = "1"
  9806. memo["invoice_no"] = fapiao_code
  9807. memo["memo"] = "自费"
  9808. bytesData, _ := json.Marshal(memo)
  9809. fsiOPFLD.Memo = string(bytesData)
  9810. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9811. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9812. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9813. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9814. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9815. fsiOPFLD.BilgDeptName = department.Name
  9816. fsiOPFLD.BilgDeptCodg = department.Number
  9817. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9818. fsiOPFLD.BilgDrName = doctor.UserName
  9819. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9820. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9821. fsiOPFLD.MedChrgitmType = "08"
  9822. memo["hosp_appr_flag"] = "1"
  9823. memo["invoice_no"] = fapiao_code
  9824. memo["memo"] = "自费"
  9825. bytesData, _ := json.Marshal(memo)
  9826. fsiOPFLD.Memo = string(bytesData)
  9827. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9828. }
  9829. }
  9830. }
  9831. for _, items := range order_info_two {
  9832. memo := make(map[string]interface{})
  9833. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9834. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9835. fsiOPFLD.MedType = pre.MedType
  9836. fsiOPFLD.BkkpSn = items.FeedetlSn
  9837. fsiOPFLD.FixmedinsCode = miConfig.Code
  9838. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9839. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9840. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9841. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.Cnt*items.Pric)
  9842. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9843. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9844. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9845. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9846. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9847. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9848. fsiOPFLD.BilgDeptName = department.Name
  9849. fsiOPFLD.BilgDeptCodg = department.Number
  9850. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9851. fsiOPFLD.BilgDrName = doctor.UserName
  9852. fsiOPFLD.MedChrgitmType = "09"
  9853. memo["hosp_appr_flag"] = "1"
  9854. memo["invoice_no"] = fapiao_code
  9855. memo["memo"] = "自费"
  9856. bytesData, _ := json.Marshal(memo)
  9857. fsiOPFLD.Memo = string(bytesData)
  9858. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9859. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9860. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9861. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9862. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9863. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9864. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9865. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9866. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9867. fsiOPFLD.BilgDeptName = department.Name
  9868. fsiOPFLD.BilgDeptCodg = department.Number
  9869. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9870. fsiOPFLD.BilgDrName = doctor.UserName
  9871. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9872. case 0:
  9873. break
  9874. case 1:
  9875. fsiOPFLD.MedChrgitmType = "14"
  9876. break
  9877. case 2:
  9878. fsiOPFLD.MedChrgitmType = "05"
  9879. break
  9880. case 3:
  9881. fsiOPFLD.MedChrgitmType = "03"
  9882. break
  9883. case 4:
  9884. fsiOPFLD.MedChrgitmType = "03"
  9885. break
  9886. case 5:
  9887. fsiOPFLD.MedChrgitmType = "08"
  9888. break
  9889. case 6:
  9890. fsiOPFLD.MedChrgitmType = "14"
  9891. break
  9892. case 7:
  9893. fsiOPFLD.MedChrgitmType = "14"
  9894. break
  9895. case 8:
  9896. fsiOPFLD.MedChrgitmType = "03"
  9897. break
  9898. case 9:
  9899. fsiOPFLD.MedChrgitmType = "14"
  9900. break
  9901. case 10:
  9902. fsiOPFLD.MedChrgitmType = "14"
  9903. break
  9904. case 11:
  9905. fsiOPFLD.MedChrgitmType = "06"
  9906. break
  9907. case 12:
  9908. fsiOPFLD.MedChrgitmType = "12"
  9909. break
  9910. case 13:
  9911. fsiOPFLD.MedChrgitmType = "01"
  9912. break
  9913. case 14:
  9914. fsiOPFLD.MedChrgitmType = "04"
  9915. break
  9916. case 15:
  9917. fsiOPFLD.MedChrgitmType = "14"
  9918. break
  9919. }
  9920. memo["hosp_appr_flag"] = "1"
  9921. memo["invoice_no"] = fapiao_code
  9922. memo["memo"] = "自费"
  9923. bytesData, _ := json.Marshal(memo)
  9924. fsiOPFLD.Memo = string(bytesData)
  9925. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9926. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9927. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9928. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9929. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9930. fsiOPFLD.BilgDeptName = department.Name
  9931. fsiOPFLD.BilgDeptCodg = department.Number
  9932. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9933. fsiOPFLD.BilgDrName = doctor.UserName
  9934. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9935. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9936. fsiOPFLD.MedChrgitmType = "08"
  9937. memo["hosp_appr_flag"] = "1"
  9938. memo["invoice_no"] = fapiao_code
  9939. memo["memo"] = "自费"
  9940. bytesData, _ := json.Marshal(memo)
  9941. fsiOPFLD.Memo = string(bytesData)
  9942. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9943. }
  9944. }
  9945. }
  9946. fmt.Println(fsiOPFLDs)
  9947. struct4201A.Fopfd = fsiOPFLDs
  9948. fmt.Println(struct4201A.Fopfd)
  9949. var struct4202 models.Struct4202
  9950. timeLayout := "2006-01-02 15:04:05"
  9951. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9952. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9953. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9954. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9955. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9956. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9957. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9958. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9959. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9960. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9961. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9962. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9963. var config []*models.HisXtDiagnoseConfig
  9964. for _, item := range diagnosis_ids {
  9965. id, _ := strconv.ParseInt(item, 10, 64)
  9966. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9967. config = append(config, &diagnosisConfig)
  9968. }
  9969. var tempDiaginfos []models.OwnPayPatnDiagListD
  9970. for index, item := range config {
  9971. if index == 0 {
  9972. var tempDiaginfo models.OwnPayPatnDiagListD
  9973. tempDiaginfo.InoutDiagType = "1"
  9974. tempDiaginfo.DiagCode = item.CountryCode
  9975. tempDiaginfo.DiagName = item.CountryContentName
  9976. tempDiaginfo.DiagType = "1"
  9977. tempDiaginfo.DiagSrtNo = "1"
  9978. tempDiaginfo.MaindiagFlag = "1"
  9979. tempDiaginfo.ValiFlag = "1"
  9980. tempDiaginfo.DiagDrName = doctor.UserName
  9981. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9982. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9983. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9984. } else {
  9985. var tempDiaginfo models.OwnPayPatnDiagListD
  9986. tempDiaginfo.DiagCode = item.CountryCode
  9987. tempDiaginfo.DiagName = item.CountryContentName
  9988. tempDiaginfo.DiagType = "2"
  9989. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9990. tempDiaginfo.MaindiagFlag = "0"
  9991. tempDiaginfo.ValiFlag = "1"
  9992. tempDiaginfo.DiagDrName = doctor.UserName
  9993. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9994. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9995. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9996. }
  9997. }
  9998. struct4202.ODiagListD = tempDiaginfos
  9999. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  10000. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  10001. var res2 ResultSix
  10002. var respJSON2 map[string]interface{}
  10003. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10006. return
  10007. }
  10008. userJSONBytes2, _ := json.Marshal(respJSON2)
  10009. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10010. utils.ErrorLog("解析失败:%v", err)
  10011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10012. return
  10013. }
  10014. if res2.Infcode != 0 {
  10015. c.ServeSuccessJSON(map[string]interface{}{
  10016. "failed_code": -10,
  10017. "msg": res2.ErrMsg,
  10018. })
  10019. return
  10020. } else {
  10021. order.IsUploadDiagnose = 1
  10022. order.IsUploadOrderInfo = 1
  10023. service.UpdateOrderTwo(order)
  10024. c.ServeSuccessJSON(map[string]interface{}{
  10025. "msg": "上传成功",
  10026. })
  10027. }
  10028. }
  10029. func (c *HisApiController) Get4207() {
  10030. admin_user_id, _ := c.GetInt64("admin_user_id")
  10031. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10032. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10033. order_id, _ := c.GetInt64("order_id")
  10034. order, _ := service.GetHisOrderByIDTwo(order_id)
  10035. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10036. var struct4207 models.Struct4207
  10037. struct4207.PageNum = "1"
  10038. struct4207.PageSize = "1000"
  10039. struct4207.FixmedinsCode = miConfig.Code
  10040. struct4207.FixmedinsMdtrtID = order.Number
  10041. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  10042. saveLog(result, requestLog, "4207", "查询")
  10043. var res2 ResultSix
  10044. var respJSON2 map[string]interface{}
  10045. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10048. return
  10049. }
  10050. userJSONBytes2, _ := json.Marshal(respJSON2)
  10051. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10052. utils.ErrorLog("解析失败:%v", err)
  10053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10054. return
  10055. }
  10056. if res2.Infcode != 0 {
  10057. c.ServeSuccessJSON(map[string]interface{}{
  10058. "failed_code": -10,
  10059. "msg": res2.ErrMsg,
  10060. })
  10061. return
  10062. } else {
  10063. c.ServeSuccessJSON(map[string]interface{}{
  10064. "msg": "查询成功",
  10065. })
  10066. }
  10067. }
  10068. func (c *HisApiController) Get4208() {
  10069. admin_user_id, _ := c.GetInt64("admin_user_id")
  10070. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10072. order_id, _ := c.GetInt64("order_id")
  10073. order, _ := service.GetHisOrderByIDTwo(order_id)
  10074. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10075. var struct4208 models.Struct4208
  10076. struct4208.PageNum = "1"
  10077. struct4208.PageSize = "1000"
  10078. struct4208.PsnCertType = "01"
  10079. struct4208.Certno = his.Certno
  10080. struct4208.MedType = order.MedType
  10081. struct4208.PsnName = his.Name
  10082. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  10083. saveLog(result, requestLog, "4208", "查询")
  10084. var res2 ResultSix
  10085. var respJSON2 map[string]interface{}
  10086. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10089. return
  10090. }
  10091. userJSONBytes2, _ := json.Marshal(respJSON2)
  10092. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10093. utils.ErrorLog("解析失败:%v", err)
  10094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10095. return
  10096. }
  10097. if res2.Infcode != 0 {
  10098. c.ServeSuccessJSON(map[string]interface{}{
  10099. "failed_code": -10,
  10100. "msg": res2.ErrMsg,
  10101. })
  10102. return
  10103. } else {
  10104. c.ServeSuccessJSON(map[string]interface{}{
  10105. "msg": "查询成功",
  10106. })
  10107. }
  10108. }
  10109. func (c *HisApiController) Get4209() {
  10110. admin_user_id, _ := c.GetInt64("admin_user_id")
  10111. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10112. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10113. order_id, _ := c.GetInt64("order_id")
  10114. order, _ := service.GetHisOrderByIDTwo(order_id)
  10115. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10116. var struct4209 models.Struct4209
  10117. struct4209.FixmedinsMdtrtID = order.Number
  10118. struct4209.FixmedinsCode = miConfig.Code
  10119. struct4209.PageSize = "1000"
  10120. struct4209.PageNum = "1"
  10121. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  10122. saveLog(result, requestLog, "4209", "查询")
  10123. var res2 ResultSix
  10124. var respJSON2 map[string]interface{}
  10125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10128. return
  10129. }
  10130. userJSONBytes2, _ := json.Marshal(respJSON2)
  10131. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10132. utils.ErrorLog("解析失败:%v", err)
  10133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10134. return
  10135. }
  10136. if res2.Infcode != 0 {
  10137. c.ServeSuccessJSON(map[string]interface{}{
  10138. "failed_code": -10,
  10139. "msg": res2.ErrMsg,
  10140. })
  10141. return
  10142. } else {
  10143. c.ServeSuccessJSON(map[string]interface{}{
  10144. "msg": "查询成功",
  10145. })
  10146. }
  10147. }
  10148. type Result3101 struct {
  10149. Infcode string `json:"infcode"`
  10150. InfRefmsgid string `json:"inf_refmsgid"`
  10151. RefmsgTime string `json:"refmsg_time"`
  10152. RespondTime string `json:"respond_time"`
  10153. Enctype string `json:"enctype"`
  10154. Signtype string `json:"signtype"`
  10155. ErrMsg string `json:"err_msg"`
  10156. Output struct {
  10157. Result []struct {
  10158. JudgeResultDetailDtos []struct {
  10159. VolaItemType string `json:"vola_item_type"`
  10160. MdtrtID string `json:"mdtrt_id"`
  10161. JrdID string `json:"jrd_id"`
  10162. PatnID string `json:"patn_id"`
  10163. RxID string `json:"rx_id"`
  10164. VolaAmt interface{} `json:"vola_amt"`
  10165. } `json:"judge_result_detail_dtos"`
  10166. RuleID string `json:"rule_id"`
  10167. VolaEvid string `json:"vola_evid"`
  10168. MdtrtID string `json:"mdtrt_id"`
  10169. RuleName string `json:"rule_name"`
  10170. VolaAmtStas string `json:"vola_amt_stas"`
  10171. JrID string `json:"jr_id"`
  10172. PatnID string `json:"patn_id"`
  10173. SevDeg string `json:"sev_deg"`
  10174. VolaAmt float64 `json:"vola_amt"`
  10175. VolaBhvrType string `json:"vola_bhvr_type"`
  10176. VolaCont string `json:"vola_cont"`
  10177. } `json:"result"`
  10178. } `json:"output"`
  10179. }
  10180. type Resultgd3101 struct {
  10181. Infcode int64 `json:"infcode"`
  10182. InfRefmsgid string `json:"inf_refmsgid"`
  10183. RefmsgTime string `json:"refmsg_time"`
  10184. RespondTime string `json:"respond_time"`
  10185. Enctype string `json:"enctype"`
  10186. Signtype string `json:"signtype"`
  10187. ErrMsg string `json:"err_msg"`
  10188. Output struct {
  10189. Result []struct {
  10190. JudgeResultDetailDtos []struct {
  10191. VolaItemType string `json:"vola_item_type"`
  10192. MdtrtID string `json:"mdtrt_id"`
  10193. JrdID string `json:"jrd_id"`
  10194. PatnID string `json:"patn_id"`
  10195. RxID string `json:"rx_id"`
  10196. VolaAmt interface{} `json:"vola_amt"`
  10197. } `json:"judge_result_detail_dtos"`
  10198. RuleID string `json:"rule_id"`
  10199. VolaEvid string `json:"vola_evid"`
  10200. MdtrtID string `json:"mdtrt_id"`
  10201. RuleName string `json:"rule_name"`
  10202. VolaAmtStas string `json:"vola_amt_stas"`
  10203. JrID string `json:"jr_id"`
  10204. PatnID string `json:"patn_id"`
  10205. SevDeg string `json:"sev_deg"`
  10206. VolaAmt float64 `json:"vola_amt"`
  10207. VolaBhvrType string `json:"vola_bhvr_type"`
  10208. VolaCont string `json:"vola_cont"`
  10209. } `json:"result"`
  10210. } `json:"output"`
  10211. }
  10212. func (c *HisApiController) ReadEleToken() {
  10213. admin_user_id, _ := c.GetInt64("admin_user_id")
  10214. his_patient_id, _ := c.GetInt64("his_patient_id")
  10215. adminUser := c.GetAdminUserInfo()
  10216. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10217. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10218. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10219. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10220. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10221. if len(tokens) > 0 {
  10222. c.ServeSuccessJSON(map[string]interface{}{
  10223. "msg": "读取成功",
  10224. })
  10225. } else {
  10226. c.ServeSuccessJSON(map[string]interface{}{
  10227. "failed_code": -10,
  10228. "msg": "读取失败",
  10229. })
  10230. }
  10231. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10232. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10233. if len(tokens) > 0 {
  10234. c.ServeSuccessJSON(map[string]interface{}{
  10235. "msg": "读取成功",
  10236. })
  10237. } else {
  10238. c.ServeSuccessJSON(map[string]interface{}{
  10239. "failed_code": -10,
  10240. "msg": "读取失败",
  10241. })
  10242. }
  10243. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10244. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10245. if len(tokens) > 0 {
  10246. c.ServeSuccessJSON(map[string]interface{}{
  10247. "msg": "读取成功",
  10248. })
  10249. } else {
  10250. c.ServeSuccessJSON(map[string]interface{}{
  10251. "failed_code": -10,
  10252. "msg": "读取失败",
  10253. })
  10254. }
  10255. } else if miConfig.MdtrtareaAdmvs == "150404" {
  10256. var api string
  10257. 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 +
  10258. "&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"
  10259. resp, requestErr := http.Get(api)
  10260. if requestErr != nil {
  10261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10262. }
  10263. body, ioErr := ioutil.ReadAll(resp.Body)
  10264. if ioErr != nil {
  10265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10267. }
  10268. var respJSON map[string]interface{}
  10269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10272. return
  10273. }
  10274. var status string
  10275. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10276. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10277. var token string
  10278. var res ResultTwo //1101结果
  10279. var res10265 ResultTwo10265 //1101结果
  10280. if status == "0" { //读卡成功
  10281. var card_info string //卡信息
  10282. var busi_card_info string
  10283. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10284. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10285. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10286. fmt.Println(card_info)
  10287. fmt.Println(busi_card_info)
  10288. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10289. result, _ := json.Marshal(respJSON)
  10290. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10291. utils.ErrorLog("解析失败:%v", err)
  10292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10293. return
  10294. }
  10295. res.ErrMsg = res10265.ErrMsg
  10296. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10297. res.Infcode = infocode
  10298. res.Output = res10265.Output
  10299. res.InfRefmsgid = res10265.InfRefmsgid
  10300. if res.Infcode == 0 {
  10301. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10302. if err == gorm.ErrRecordNotFound {
  10303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10304. return
  10305. } else if err != nil {
  10306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10307. return
  10308. } else {
  10309. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10310. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10311. infoStr := string(Iinfos)
  10312. idetinfoStr := string(Idetinfos)
  10313. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10314. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10315. psn := &models.HisPsn{
  10316. PsnNo: res.Output.Baseinfo.PsnNo,
  10317. PatientId: patient.ID,
  10318. Certno: res.Output.Baseinfo.Certno,
  10319. Gend: res.Output.Baseinfo.Gend,
  10320. Naty: res.Output.Baseinfo.Naty,
  10321. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10322. PsnName: res.Output.Baseinfo.PsnName,
  10323. Age: float64(age),
  10324. Brdy: b,
  10325. Idetinfo: idetinfoStr,
  10326. Insuinfo: infoStr,
  10327. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10328. CardInfo: card_info,
  10329. VerifyNumber: token,
  10330. IdCardType: 4,
  10331. }
  10332. var rf []*ResultFive
  10333. json.Unmarshal([]byte(infoStr), &rf)
  10334. var insutypes []*ResultFive
  10335. var insutype string
  10336. var is390 int = 0
  10337. var is310 int = 0
  10338. for _, item := range rf {
  10339. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10340. insutypes = append(insutypes, item)
  10341. }
  10342. }
  10343. if len(insutypes) == 1 {
  10344. insutype = insutypes[0].Insutype
  10345. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10346. } else {
  10347. for _, i := range insutypes {
  10348. if i.Insutype == "390" {
  10349. is390 = 1
  10350. }
  10351. if i.Insutype == "310" {
  10352. is310 = 1
  10353. }
  10354. }
  10355. }
  10356. if is390 == 1 {
  10357. insutype = "390"
  10358. }
  10359. if is310 == 1 {
  10360. insutype = "310"
  10361. }
  10362. if len(insutypes) == 0 {
  10363. insutype = "310"
  10364. }
  10365. service.CreateHisPsn(psn)
  10366. c.ServeSuccessJSON(map[string]interface{}{
  10367. "patient": patient,
  10368. "number": token,
  10369. "insutype": insutype,
  10370. })
  10371. }
  10372. } else {
  10373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10374. return
  10375. }
  10376. } else { //读卡失败
  10377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10378. return
  10379. }
  10380. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10381. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10382. if len(errMsg) == 0 {
  10383. type ELeData struct {
  10384. Data struct {
  10385. IdNo string `json:"idNo"`
  10386. IdType string `json:"idType"`
  10387. UserName string `json:"userName"`
  10388. EcToken string `json:"ecToken"`
  10389. InsuOrg string `json:"insuOrg"`
  10390. Gender string `json:"gender"`
  10391. Birthday string `json:"birthday"`
  10392. Nationality string `json:"nationality"`
  10393. Email string `json:"email"`
  10394. Extra string `json:"extra"`
  10395. } `json:"data"`
  10396. Code int `json:"code"`
  10397. Message string `json:"message"`
  10398. }
  10399. var ele ELeData
  10400. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10401. if err != nil {
  10402. utils.ErrorLog("解析失败:%v", err)
  10403. }
  10404. token := ele.Data.EcToken
  10405. if len(token) > 0 {
  10406. psn := &models.HisPsn{
  10407. PsnNo: his.PsnNo,
  10408. Age: 0,
  10409. PatientId: his.PatientId,
  10410. Certno: his.Certno,
  10411. Brdy: his.Brdy,
  10412. Gend: his.Gend,
  10413. Naty: his.Naty,
  10414. PsnCertType: his.PsnCertType,
  10415. PsnName: his.PsnName,
  10416. Idetinfo: his.Idetinfo,
  10417. Insuinfo: his.Iinfo,
  10418. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10419. CardInfo: outPutInfo,
  10420. VerifyNumber: token,
  10421. }
  10422. service.CreateHisPsn(psn)
  10423. }
  10424. if len(token) > 0 {
  10425. c.ServeSuccessJSON(map[string]interface{}{
  10426. "msg": "读取成功",
  10427. })
  10428. } else {
  10429. c.ServeSuccessJSON(map[string]interface{}{
  10430. "failed_code": -10,
  10431. "msg": "读取失败",
  10432. })
  10433. }
  10434. }
  10435. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10436. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10437. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10438. type ELeData struct {
  10439. Data struct {
  10440. IdNo string `json:"idNo"`
  10441. IdType string `json:"idType"`
  10442. UserName string `json:"userName"`
  10443. EcToken string `json:"ecToken"`
  10444. InsuOrg string `json:"insuOrg"`
  10445. Gender string `json:"gender"`
  10446. Birthday string `json:"birthday"`
  10447. Nationality string `json:"nationality"`
  10448. Email string `json:"email"`
  10449. Extra string `json:"extra"`
  10450. } `json:"data"`
  10451. Code int `json:"code"`
  10452. Message string `json:"message"`
  10453. }
  10454. var ele ELeData
  10455. err := json.Unmarshal([]byte(result), &ele)
  10456. if err != nil {
  10457. utils.ErrorLog("解析失败:%v", err)
  10458. }
  10459. token := ele.Data.EcToken
  10460. token = Remove0000(token)
  10461. fmt.Println(ele.Data.UserName)
  10462. 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)
  10463. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10464. var res ResultTwo
  10465. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10466. utils.ErrorLog("解析失败:%v", err)
  10467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10468. return
  10469. }
  10470. if res.Infcode == 0 {
  10471. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10472. if err == gorm.ErrRecordNotFound {
  10473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10474. return
  10475. } else if err != nil {
  10476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10477. return
  10478. } else {
  10479. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10480. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10481. infoStr := string(Iinfos)
  10482. idetinfoStr := string(Idetinfos)
  10483. psn := &models.HisPsn{
  10484. PsnNo: res.Output.Baseinfo.PsnNo,
  10485. PatientId: patient.ID,
  10486. Certno: res.Output.Baseinfo.Certno,
  10487. Gend: res.Output.Baseinfo.Gend,
  10488. Naty: res.Output.Baseinfo.Naty,
  10489. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10490. PsnName: res.Output.Baseinfo.PsnName,
  10491. Idetinfo: idetinfoStr,
  10492. Insuinfo: infoStr,
  10493. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10494. CardInfo: "",
  10495. VerifyNumber: token,
  10496. }
  10497. service.CreateHisPsn(psn)
  10498. c.ServeSuccessJSON(map[string]interface{}{
  10499. "patient": patient,
  10500. "number": token,
  10501. })
  10502. }
  10503. } else {
  10504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10505. return
  10506. }
  10507. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10508. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10509. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10510. type ELeData struct {
  10511. Data struct {
  10512. IdNo string `json:"idNo"`
  10513. IdType string `json:"idType"`
  10514. UserName string `json:"userName"`
  10515. EcToken string `json:"ecToken"`
  10516. InsuOrg string `json:"insuOrg"`
  10517. Gender string `json:"gender"`
  10518. Birthday string `json:"birthday"`
  10519. Nationality string `json:"nationality"`
  10520. Email string `json:"email"`
  10521. Extra string `json:"extra"`
  10522. } `json:"data"`
  10523. Code int `json:"code"`
  10524. Message string `json:"message"`
  10525. }
  10526. var ele ELeData
  10527. err := json.Unmarshal([]byte(result), &ele)
  10528. if err != nil {
  10529. utils.ErrorLog("解析失败:%v", err)
  10530. }
  10531. token := ele.Data.EcToken
  10532. token = Remove0000(token)
  10533. fmt.Println(ele.Data.UserName)
  10534. 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)
  10535. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10536. var res ResultTwo
  10537. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10538. utils.ErrorLog("解析失败:%v", err)
  10539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10540. return
  10541. }
  10542. if res.Infcode == 0 {
  10543. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10544. if err == gorm.ErrRecordNotFound {
  10545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10546. return
  10547. } else if err != nil {
  10548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10549. return
  10550. } else {
  10551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10553. infoStr := string(Iinfos)
  10554. idetinfoStr := string(Idetinfos)
  10555. psn := &models.HisPsn{
  10556. PsnNo: res.Output.Baseinfo.PsnNo,
  10557. PatientId: patient.ID,
  10558. Certno: res.Output.Baseinfo.Certno,
  10559. Gend: res.Output.Baseinfo.Gend,
  10560. Naty: res.Output.Baseinfo.Naty,
  10561. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10562. PsnName: res.Output.Baseinfo.PsnName,
  10563. Idetinfo: idetinfoStr,
  10564. Insuinfo: infoStr,
  10565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10566. CardInfo: "",
  10567. VerifyNumber: token,
  10568. }
  10569. service.CreateHisPsn(psn)
  10570. c.ServeSuccessJSON(map[string]interface{}{
  10571. "patient": patient,
  10572. "number": token,
  10573. })
  10574. }
  10575. } else {
  10576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10577. return
  10578. }
  10579. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10580. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10581. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10582. type ELeData struct {
  10583. Data struct {
  10584. IdNo string `json:"idNo"`
  10585. IdType string `json:"idType"`
  10586. UserName string `json:"userName"`
  10587. EcToken string `json:"ecToken"`
  10588. InsuOrg string `json:"insuOrg"`
  10589. Gender string `json:"gender"`
  10590. Birthday string `json:"birthday"`
  10591. Nationality string `json:"nationality"`
  10592. Email string `json:"email"`
  10593. Extra string `json:"extra"`
  10594. } `json:"data"`
  10595. Code int `json:"code"`
  10596. Message string `json:"message"`
  10597. }
  10598. var ele ELeData
  10599. err := json.Unmarshal([]byte(result), &ele)
  10600. if err != nil {
  10601. utils.ErrorLog("解析失败:%v", err)
  10602. }
  10603. token := ele.Data.EcToken
  10604. token = Remove0000(token)
  10605. fmt.Println(ele.Data.UserName)
  10606. 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)
  10607. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10608. var res ResultTwo
  10609. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10610. utils.ErrorLog("解析失败:%v", err)
  10611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10612. return
  10613. }
  10614. if res.Infcode == 0 {
  10615. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10616. if err == gorm.ErrRecordNotFound {
  10617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10618. return
  10619. } else if err != nil {
  10620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10621. return
  10622. } else {
  10623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10625. infoStr := string(Iinfos)
  10626. idetinfoStr := string(Idetinfos)
  10627. psn := &models.HisPsn{
  10628. PsnNo: res.Output.Baseinfo.PsnNo,
  10629. PatientId: patient.ID,
  10630. Certno: res.Output.Baseinfo.Certno,
  10631. Gend: res.Output.Baseinfo.Gend,
  10632. Naty: res.Output.Baseinfo.Naty,
  10633. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10634. PsnName: res.Output.Baseinfo.PsnName,
  10635. Idetinfo: idetinfoStr,
  10636. Insuinfo: infoStr,
  10637. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10638. CardInfo: "",
  10639. VerifyNumber: token,
  10640. }
  10641. service.CreateHisPsn(psn)
  10642. c.ServeSuccessJSON(map[string]interface{}{
  10643. "patient": patient,
  10644. "number": token,
  10645. })
  10646. }
  10647. } else {
  10648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10649. return
  10650. }
  10651. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10652. //if initFlag == 0 {
  10653. //c.TestGetJiangXiBasBaseInit()
  10654. //}
  10655. //if initEleFlag == 0 {
  10656. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10657. //}
  10658. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10659. utils.ErrorLog("解析失败:%v", json_result)
  10660. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10661. type ELeData struct {
  10662. Data struct {
  10663. IdNo string `json:"idNo"`
  10664. IdType string `json:"idType"`
  10665. UserName string `json:"userName"`
  10666. EcToken string `json:"ecToken"`
  10667. InsuOrg string `json:"insuOrg"`
  10668. Gender string `json:"gender"`
  10669. Birthday string `json:"birthday"`
  10670. Nationality string `json:"nationality"`
  10671. Email string `json:"email"`
  10672. Extra string `json:"extra"`
  10673. } `json:"data"`
  10674. Code int `json:"code"`
  10675. Message string `json:"message"`
  10676. }
  10677. var ele ELeData
  10678. err := json.Unmarshal([]byte(json_result), &ele)
  10679. if err != nil {
  10680. utils.ErrorLog("解析失败:%v", err)
  10681. }
  10682. token := ele.Data.EcToken
  10683. token = Remove0000(token)
  10684. //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)
  10685. 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)
  10686. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10687. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10688. var res ResultTwo
  10689. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10690. utils.ErrorLog("解析失败:%v", err)
  10691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10692. return
  10693. }
  10694. if res.Infcode == 0 {
  10695. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10696. if err == gorm.ErrRecordNotFound {
  10697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10698. return
  10699. } else if err != nil {
  10700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10701. return
  10702. } else {
  10703. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10704. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10705. infoStr := string(Iinfos)
  10706. idetinfoStr := string(Idetinfos)
  10707. psn := &models.HisPsn{
  10708. PsnNo: res.Output.Baseinfo.PsnNo,
  10709. PatientId: patient.ID,
  10710. Certno: res.Output.Baseinfo.Certno,
  10711. Gend: res.Output.Baseinfo.Gend,
  10712. Naty: res.Output.Baseinfo.Naty,
  10713. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10714. PsnName: res.Output.Baseinfo.PsnName,
  10715. Idetinfo: idetinfoStr,
  10716. Insuinfo: infoStr,
  10717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10718. CardInfo: "",
  10719. VerifyNumber: token,
  10720. InsuplcAdmdvs: ele.Data.InsuOrg,
  10721. }
  10722. service.CreateHisPsn(psn)
  10723. c.ServeSuccessJSON(map[string]interface{}{
  10724. "patient": patient,
  10725. "number": token,
  10726. })
  10727. }
  10728. } else {
  10729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10730. return
  10731. }
  10732. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10733. res := c.GetoleInfo()
  10734. if res.Infcode == 0 {
  10735. var result string
  10736. if res.Output.MdtrtCertType == "01" {
  10737. 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)
  10738. } else if res.Output.MdtrtCertType == "02" {
  10739. 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)
  10740. } else if res.Output.MdtrtCertType == "03" {
  10741. 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)
  10742. }
  10743. var dat map[string]interface{}
  10744. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10745. fmt.Println(dat)
  10746. } else {
  10747. fmt.Println(err)
  10748. }
  10749. userJSONBytes, _ := json.Marshal(dat)
  10750. var res2 ResultTwo
  10751. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10752. utils.ErrorLog("解析失败:%v", err)
  10753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10754. return
  10755. }
  10756. if res2.Infcode == 0 {
  10757. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10758. if err == gorm.ErrRecordNotFound {
  10759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10760. return
  10761. } else if err != nil {
  10762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10763. return
  10764. } else {
  10765. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10766. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10767. infoStr := string(Iinfos)
  10768. idetinfoStr := string(Idetinfos)
  10769. var rf []*ResultFive
  10770. json.Unmarshal([]byte(infoStr), &rf)
  10771. var insutypes []*ResultFive
  10772. var insutype string
  10773. var is390 int = 0
  10774. var is310 int = 0
  10775. //var insuplc_admdvs string
  10776. for _, item := range rf {
  10777. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10778. insutypes = append(insutypes, item)
  10779. }
  10780. }
  10781. if len(insutypes) == 1 {
  10782. insutype = insutypes[0].Insutype
  10783. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10784. } else {
  10785. for _, i := range insutypes {
  10786. if i.Insutype == "390" {
  10787. is390 = 1
  10788. }
  10789. if i.Insutype == "310" {
  10790. is310 = 1
  10791. }
  10792. }
  10793. }
  10794. if is390 == 1 {
  10795. insutype = "390"
  10796. }
  10797. if is310 == 1 {
  10798. insutype = "310"
  10799. }
  10800. if len(insutypes) == 0 {
  10801. insutype = "310"
  10802. }
  10803. psn := &models.HisPsn{
  10804. PsnNo: res2.Output.Baseinfo.PsnNo,
  10805. PatientId: patient.ID,
  10806. Certno: res2.Output.Baseinfo.Certno,
  10807. Gend: res2.Output.Baseinfo.Gend,
  10808. Naty: res2.Output.Baseinfo.Naty,
  10809. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10810. PsnName: res2.Output.Baseinfo.PsnName,
  10811. Idetinfo: idetinfoStr,
  10812. Insuinfo: infoStr,
  10813. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10814. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10815. VerifyNumber: res.Output.EcToken,
  10816. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10817. }
  10818. service.CreateHisPsn(psn)
  10819. c.ServeSuccessJSON(map[string]interface{}{
  10820. "patient": patient,
  10821. "number": res.Output.CardNo,
  10822. "insutype": insutype,
  10823. })
  10824. }
  10825. } else {
  10826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10827. return
  10828. }
  10829. } else {
  10830. c.ServeSuccessJSON(map[string]interface{}{
  10831. "failed_code": -10,
  10832. "msg": res.ErrMsg,
  10833. })
  10834. }
  10835. } else {
  10836. //if initFlag == 0 {
  10837. // c.TestGetBasBaseInit()
  10838. //}
  10839. //token := c.GetEleBaseInfo()
  10840. //token = Remove0000(token)
  10841. type ELeData struct {
  10842. Code string `json:"code"`
  10843. Data struct {
  10844. Aac002 string `json:"aac002"`
  10845. Aaz500 string `json:"aaz500"`
  10846. ActCardNo string `json:"actCardNo"`
  10847. Bab520 string `json:"bab520"`
  10848. Bkz543 string `json:"bkz543"`
  10849. BusinessType string `json:"businessType"`
  10850. CertfCodg string `json:"certfCodg"`
  10851. EcIndexNo string `json:"ecIndexNo"`
  10852. EcToken string `json:"ecToken"`
  10853. ID0000 string `json:"id0000"`
  10854. IDNo string `json:"idNo"`
  10855. IDType string `json:"idType"`
  10856. Idcode string `json:"idcode"`
  10857. IdentityToken string `json:"identity_token"`
  10858. InsuOrg string `json:"insuOrg"`
  10859. OfficeID string `json:"officeId"`
  10860. OfficeName string `json:"officeName"`
  10861. OperatorID string `json:"operatorId"`
  10862. OperatorName string `json:"operatorName"`
  10863. OrgID string `json:"orgId"`
  10864. UserName string `json:"userName"`
  10865. } `json:"data"`
  10866. Infno interface{} `json:"infno"`
  10867. Message string `json:"message"`
  10868. OrgID string `json:"orgId"`
  10869. TransType string `json:"transType"`
  10870. }
  10871. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10872. fmt.Println(result)
  10873. outPutInfo := Remove0000(result)
  10874. fmt.Println(outPutInfo)
  10875. var ele ELeData
  10876. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10877. if err != nil {
  10878. utils.ErrorLog("解析失败:%v", err)
  10879. }
  10880. token := ele.Data.EcToken
  10881. var result2 string
  10882. var requestLog2 string
  10883. if len(token) > 0 {
  10884. if strings.Contains(ele.Data.IDNo, "HKG") {
  10885. 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)
  10886. } else {
  10887. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10888. }
  10889. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10890. var res ResultTwo
  10891. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10892. utils.ErrorLog("解析失败:%v", err)
  10893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10894. return
  10895. }
  10896. if res.Infcode == 0 {
  10897. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10898. if err == gorm.ErrRecordNotFound {
  10899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10900. return
  10901. } else if err != nil {
  10902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10903. return
  10904. } else {
  10905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10907. infoStr := string(Iinfos)
  10908. idetinfoStr := string(Idetinfos)
  10909. psn := &models.HisPsn{
  10910. PsnNo: res.Output.Baseinfo.PsnNo,
  10911. PatientId: patient.ID,
  10912. Certno: res.Output.Baseinfo.Certno,
  10913. Gend: res.Output.Baseinfo.Gend,
  10914. Naty: res.Output.Baseinfo.Naty,
  10915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10916. PsnName: res.Output.Baseinfo.PsnName,
  10917. Idetinfo: idetinfoStr,
  10918. Insuinfo: infoStr,
  10919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10920. CardInfo: "",
  10921. VerifyNumber: token,
  10922. }
  10923. service.CreateHisPsn(psn)
  10924. c.ServeSuccessJSON(map[string]interface{}{
  10925. "msg": "读取成功",
  10926. })
  10927. }
  10928. } else {
  10929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10930. return
  10931. }
  10932. } else {
  10933. c.ServeSuccessJSON(map[string]interface{}{
  10934. "failed_code": -10,
  10935. "msg": "读取失败",
  10936. })
  10937. }
  10938. }
  10939. }
  10940. func (c *HisApiController) ReadEleFace() {
  10941. admin_user_id, _ := c.GetInt64("admin_user_id")
  10942. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10943. adminUser := c.GetAdminUserInfo()
  10944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10945. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10946. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10947. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10948. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10949. if len(tokens) > 0 {
  10950. c.ServeSuccessJSON(map[string]interface{}{
  10951. "msg": "读取成功",
  10952. })
  10953. } else {
  10954. c.ServeSuccessJSON(map[string]interface{}{
  10955. "failed_code": -10,
  10956. "msg": "读取失败",
  10957. })
  10958. }
  10959. }
  10960. }
  10961. func timestampToBirthdayString(timestamp int64) string {
  10962. // 将时间戳转换为 time.Time
  10963. t := time.Unix(timestamp, 0)
  10964. // 格式化时间为生日字符串,例如 "2006-01-02"
  10965. birthday := t.Format("2006-01-02")
  10966. return birthday
  10967. }
  10968. func (c *HisApiController) Get9001() {
  10969. adminUser := c.GetAdminUserInfo()
  10970. admin_user_id, _ := c.GetInt64("admin_user_id")
  10971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10972. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10973. if miConfig.MdtrtareaAdmvs == "350500" {
  10974. service.GetFjAuthorizationInfo(miConfig.Code)
  10975. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10976. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10977. var dat map[string]interface{}
  10978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10979. fmt.Println(dat)
  10980. } else {
  10981. fmt.Println(err)
  10982. }
  10983. userJSONBytes, _ := json.Marshal(dat)
  10984. var res models.Result9001
  10985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10986. utils.ErrorLog("解析失败:%v", err)
  10987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10988. return
  10989. }
  10990. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10991. fmt.Println(miConfig.SecretKey)
  10992. var res models.Result9001Two
  10993. 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 +
  10994. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10995. resp, requestErr := http.Get(api)
  10996. if requestErr != nil {
  10997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10998. return
  10999. }
  11000. body, ioErr := ioutil.ReadAll(resp.Body)
  11001. if ioErr != nil {
  11002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11004. return
  11005. }
  11006. var respJSON map[string]interface{}
  11007. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11010. return
  11011. }
  11012. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11013. if status == "0" {
  11014. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11015. c.ServeSuccessJSON(map[string]interface{}{
  11016. "failed_code": -10,
  11017. "msg": err_msg,
  11018. })
  11019. return
  11020. }
  11021. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11022. result, _ := json.Marshal(respJSON)
  11023. fmt.Println("log")
  11024. fmt.Println(string(result))
  11025. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11026. utils.ErrorLog("解析失败:%v", err)
  11027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11028. return
  11029. }
  11030. if res.Infcode == 0 {
  11031. sign := models.HisSignIn{
  11032. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11033. SignNo: res.Output.Signinoutb.SignNo,
  11034. SignTime: "",
  11035. Ctime: time.Now().Unix(),
  11036. Mtime: time.Now().Unix(),
  11037. Status: 1,
  11038. InputLog: "",
  11039. OutputLog: "",
  11040. FixmedinsCode: miConfig.Code,
  11041. }
  11042. err := service.CreateSignIn(&sign)
  11043. if err == nil {
  11044. c.ServeSuccessJSON(map[string]interface{}{
  11045. "msg": "签到成功",
  11046. })
  11047. }
  11048. } else {
  11049. c.ServeSuccessJSON(map[string]interface{}{
  11050. "failed_code": -10,
  11051. "msg": res.ErrMsg,
  11052. })
  11053. return
  11054. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11055. //return
  11056. }
  11057. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11058. fmt.Println(miConfig.SecretKey)
  11059. var res models.Result9001Two
  11060. 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 +
  11061. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  11062. resp, requestErr := http.Get(api)
  11063. if requestErr != nil {
  11064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11065. return
  11066. }
  11067. body, ioErr := ioutil.ReadAll(resp.Body)
  11068. if ioErr != nil {
  11069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11071. return
  11072. }
  11073. var respJSON map[string]interface{}
  11074. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11077. return
  11078. }
  11079. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11080. if status == "0" {
  11081. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11082. c.ServeSuccessJSON(map[string]interface{}{
  11083. "failed_code": -10,
  11084. "msg": err_msg,
  11085. })
  11086. return
  11087. }
  11088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11089. result, _ := json.Marshal(respJSON)
  11090. fmt.Println("log")
  11091. fmt.Println(string(result))
  11092. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11093. utils.ErrorLog("解析失败:%v", err)
  11094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11095. return
  11096. }
  11097. if res.Infcode == 0 {
  11098. sign := models.HisSignIn{
  11099. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11100. SignNo: res.Output.Signinoutb.SignNo,
  11101. SignTime: "",
  11102. Ctime: time.Now().Unix(),
  11103. Mtime: time.Now().Unix(),
  11104. Status: 1,
  11105. InputLog: "",
  11106. OutputLog: "",
  11107. FixmedinsCode: miConfig.Code,
  11108. }
  11109. err := service.CreateSignIn(&sign)
  11110. if err == nil {
  11111. c.ServeSuccessJSON(map[string]interface{}{
  11112. "msg": "签到成功",
  11113. })
  11114. }
  11115. } else {
  11116. c.ServeSuccessJSON(map[string]interface{}{
  11117. "failed_code": -10,
  11118. "msg": res.ErrMsg,
  11119. })
  11120. return
  11121. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11122. //return
  11123. }
  11124. } else {
  11125. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11126. var dat map[string]interface{}
  11127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11128. fmt.Println(dat)
  11129. } else {
  11130. fmt.Println(err)
  11131. }
  11132. userJSONBytes, _ := json.Marshal(dat)
  11133. var res models.Result9001
  11134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11135. utils.ErrorLog("解析失败:%v", err)
  11136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11137. return
  11138. }
  11139. if res.Infcode == 0 {
  11140. sign := models.HisSignIn{
  11141. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11142. SignNo: res.Output.Signinoutb.SignNo,
  11143. SignTime: res.Output.Signinoutb.SignTime,
  11144. Ctime: time.Now().Unix(),
  11145. Mtime: time.Now().Unix(),
  11146. Status: 1,
  11147. InputLog: "",
  11148. OutputLog: "",
  11149. FixmedinsCode: miConfig.Code,
  11150. }
  11151. err := service.CreateSignIn(&sign)
  11152. if err == nil {
  11153. c.ServeSuccessJSON(map[string]interface{}{
  11154. "msg": "签到成功",
  11155. })
  11156. }
  11157. }
  11158. }
  11159. }
  11160. 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) {
  11161. var res Result3101
  11162. adminUser := c.GetAdminUserInfo()
  11163. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11164. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11165. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11166. //record_time := c.GetString("record_time")
  11167. //trig_scen := c.GetString("trig_scen")
  11168. timeLayout := "2006-01-02"
  11169. loc, _ := time.LoadLocation("Local")
  11170. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11171. if err != nil {
  11172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11173. return res
  11174. }
  11175. recordDateTime := theTime.Unix()
  11176. var patientPrescription models.HisPrescriptionInfo
  11177. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11178. //if patientPrescription.ID == 0 {
  11179. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11180. //}
  11181. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11182. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11183. //
  11184. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11185. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11186. var pp models.PublicParams
  11187. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11188. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11189. pp.FixmedinsName = miConfig.OrgName
  11190. pp.FixmedinsCode = miConfig.Code
  11191. pp.RequestUrl = miConfig.Url
  11192. pp.Cainfo = miConfig.Cainfo
  11193. pp.SecretKey = miConfig.SecretKey
  11194. pp.AccessKey = miConfig.AccessKey
  11195. pp.OpterName = roles.UserName
  11196. var config []*models.HisXtDiagnoseConfig
  11197. for _, item := range diagnosis_ids {
  11198. id, _ := strconv.ParseInt(item, 10, 64)
  11199. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11200. config = append(config, &diagnosisConfig)
  11201. }
  11202. var pd models.PatientDtos
  11203. pd.PatnID = his.PsnNo
  11204. pd.PatnName = his.Name
  11205. pd.Gend = his.Gend
  11206. pd.Brdy = his.Brdy
  11207. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11208. pd.CurrMdtrtID = his.Number
  11209. var fed models.FsiEncounterDtos
  11210. fed.MdtrtID = his.Number
  11211. fed.MedinsID = miConfig.Code
  11212. fed.MedinsName = miConfig.OrgName
  11213. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11214. fed.MedMdtrtType = "1"
  11215. fed.MedinsType = "1"
  11216. fed.MedinsLv = "11"
  11217. tm := time.Unix(his.RecordDate, 0)
  11218. s_tm := tm.Format("2006-01-02 15:04:05")
  11219. fed.AdmDate = s_tm
  11220. fed.DscgDate = s_tm
  11221. fed.DscgMainDiseCodg = config[0].CountryCode
  11222. fed.DscgMainDiseName = config[0].CountryContentName
  11223. //诊断信息
  11224. var fdds []*models.FsiDiagnoseDtos
  11225. for index, item := range config {
  11226. if index == 0 {
  11227. var fdd models.FsiDiagnoseDtos
  11228. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11229. fdd.InoutDiseType = "1"
  11230. fdd.MaindiseFlag = "1"
  11231. fdd.DiseDate = s_tm
  11232. fdd.DiasSrtNo = "1"
  11233. fdd.DiseName = item.CountryContentName
  11234. fdd.DiseCodg = item.CountryCode
  11235. fdds = append(fdds, &fdd)
  11236. } else {
  11237. var fdd models.FsiDiagnoseDtos
  11238. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11239. fdd.InoutDiseType = "1"
  11240. fdd.MaindiseFlag = "1"
  11241. fdd.DiseDate = s_tm
  11242. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11243. fdd.DiseName = item.CountryContentName
  11244. fdd.DiseCodg = item.CountryCode
  11245. fdds = append(fdds, &fdd)
  11246. }
  11247. }
  11248. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11249. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11250. fed.AdmDeptName = de.Name
  11251. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11252. fed.DscgDeptName = de.Name
  11253. fed.MedMdtrtType = "1"
  11254. fed.MedType = "11"
  11255. //if his.Insutype == "390" {
  11256. // fed.MedType = "1402"
  11257. //} else {
  11258. // fed.MedType = "9933"
  11259. //}
  11260. var orders []*models.FsiOrderDtos
  11261. if trig_scen == "2" {
  11262. //处方医嘱信息
  11263. for _, item := range prescriptions {
  11264. for _, subItem := range item.HisDoctorAdviceInfo {
  11265. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11266. var order models.FsiOrderDtos
  11267. order.RxID = strconv.FormatInt(item.ID, 10)
  11268. order.Rxno = strconv.FormatInt(item.ID, 10)
  11269. order.LongDrordFlag = "0"
  11270. order.HilistType = "1"
  11271. order.ChrgType = "1"
  11272. order.DrordBhvr = "-"
  11273. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11274. order.HosplistName = subItem.BaseDrugLib.DrugName
  11275. order.HilistLv = "1"
  11276. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11277. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11278. order.HosplistName = subItem.BaseDrugLib.DrugName
  11279. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11280. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11281. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11282. order.OwnpayAmt = ""
  11283. order.SelfpayAmt = ""
  11284. order.Spec = ""
  11285. order.SpecUnt = ""
  11286. order.DrordBegnDate = s_tm
  11287. order.DrordStopDate = ""
  11288. order.DrordDrCodg = doctor_info.DoctorNumber
  11289. order.DrordDeptName = department.Name
  11290. order.DrordDeptCodg = department.Number
  11291. order.DrordDrName = doctor_info.UserName
  11292. order.DrordDrProfttl = "234"
  11293. order.CurrDrordFlag = "1"
  11294. orders = append(orders, &order)
  11295. }
  11296. }
  11297. for _, subItem := range item.HisPrescriptionProject {
  11298. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11299. var order models.FsiOrderDtos
  11300. order.RxID = strconv.FormatInt(item.ID, 10)
  11301. order.Rxno = strconv.FormatInt(item.ID, 10)
  11302. order.LongDrordFlag = "0"
  11303. order.HilistType = "1"
  11304. order.ChrgType = "1"
  11305. order.DrordBhvr = "-"
  11306. order.HilistCode = subItem.HisProject.MedicalCode
  11307. order.HosplistName = subItem.HisProject.ProjectName
  11308. order.HilistLv = "1"
  11309. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11310. order.HosplistCode = subItem.HisProject.MedicalCode
  11311. order.HosplistName = subItem.HisProject.ProjectName
  11312. order.Cnt = subItem.Count
  11313. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11314. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11315. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11316. order.OwnpayAmt = ""
  11317. order.SelfpayAmt = ""
  11318. order.Spec = ""
  11319. order.SpecUnt = ""
  11320. order.DrordBegnDate = s_tm
  11321. order.DrordStopDate = ""
  11322. order.DrordDrCodg = doctor_info.DoctorNumber
  11323. order.DrordDeptName = department.Name
  11324. order.DrordDeptCodg = department.Number
  11325. order.DrordDrName = doctor_info.UserName
  11326. order.DrordDrProfttl = "234"
  11327. order.CurrDrordFlag = "1"
  11328. orders = append(orders, &order)
  11329. }
  11330. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11331. var order models.FsiOrderDtos
  11332. order.RxID = strconv.FormatInt(item.ID, 10)
  11333. order.Rxno = strconv.FormatInt(item.ID, 10)
  11334. order.LongDrordFlag = "0"
  11335. order.HilistType = "1"
  11336. order.ChrgType = "1"
  11337. order.DrordBhvr = "-"
  11338. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11339. order.HosplistName = subItem.GoodInfo.GoodName
  11340. order.HilistLv = "1"
  11341. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11342. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11343. order.HosplistName = subItem.GoodInfo.GoodName
  11344. order.Cnt = subItem.Count
  11345. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11346. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11347. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11348. order.OwnpayAmt = ""
  11349. order.SelfpayAmt = ""
  11350. order.Spec = ""
  11351. order.SpecUnt = ""
  11352. order.DrordBegnDate = s_tm
  11353. order.DrordStopDate = ""
  11354. order.DrordDrCodg = doctor_info.DoctorNumber
  11355. order.DrordDeptName = department.Name
  11356. order.DrordDeptCodg = department.Number
  11357. order.DrordDrName = doctor_info.UserName
  11358. order.DrordDrProfttl = "234"
  11359. order.CurrDrordFlag = "1"
  11360. orders = append(orders, &order)
  11361. }
  11362. }
  11363. }
  11364. //处方医嘱信息
  11365. }
  11366. fed.MatnStas = "0"
  11367. fed.MedfeeSumamt = "0"
  11368. fed.OwnpayAmt = "0"
  11369. fed.SelfpayAmt = "0"
  11370. fed.AcctPayamt = "0"
  11371. fed.MaAmt = "0"
  11372. fed.HifpPayamt = "0"
  11373. fed.SetlTotlnum = "1"
  11374. fed.Insutype = his.Insutype
  11375. fed.ReimFlag = "0"
  11376. fed.OutSetlFlag = "0"
  11377. var fopd []*models.FsiOperationDtosData
  11378. data := make(map[string]interface{})
  11379. data["fed"] = fed
  11380. data["fdd"] = fdds
  11381. data["fod"] = orders
  11382. data["pd"] = pd
  11383. data["pp"] = pp
  11384. data["fopd"] = fopd
  11385. data["trig_scen"] = trig_scen
  11386. fmt.Println(data)
  11387. fmt.Println(fed)
  11388. fmt.Println(fdds)
  11389. fmt.Println(orders)
  11390. fmt.Println(pd)
  11391. fmt.Println(pp)
  11392. fmt.Println(fopd)
  11393. client := &http.Client{}
  11394. bytesData, _ := json.Marshal(data)
  11395. var req *http.Request
  11396. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11397. if miConfig.MdtrtareaAdmvs == "320830" {
  11398. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11399. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11400. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11401. } else {
  11402. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11403. }
  11404. resp, _ := client.Do(req)
  11405. defer resp.Body.Close()
  11406. body, ioErr := ioutil.ReadAll(resp.Body)
  11407. if ioErr != nil {
  11408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11410. return res
  11411. }
  11412. var respJSON map[string]interface{}
  11413. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11416. return res
  11417. }
  11418. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11419. fmt.Println(respJSON)
  11420. result, _ := json.Marshal(respJSON)
  11421. fmt.Println(result)
  11422. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11423. utils.ErrorLog("解析失败:%v", err)
  11424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11425. return res
  11426. }
  11427. return res
  11428. } else {
  11429. //if miConfig.MdtrtareaAdmvs == "441202" {
  11430. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11431. saveLog(output, input, "3101", "事前")
  11432. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11433. utils.ErrorLog("解析失败:%v", err)
  11434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11435. return
  11436. }
  11437. return res
  11438. //}
  11439. }
  11440. }
  11441. 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) {
  11442. adminUser := c.GetAdminUserInfo()
  11443. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11444. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11445. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11446. //record_time := c.GetString("record_time")
  11447. //trig_scen := c.GetString("trig_scen")
  11448. timeLayout := "2006-01-02"
  11449. loc, _ := time.LoadLocation("Local")
  11450. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11451. if err != nil {
  11452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11453. return res
  11454. }
  11455. recordDateTime := theTime.Unix()
  11456. var patientPrescription models.HisPrescriptionInfo
  11457. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11458. if patientPrescription.ID == 0 {
  11459. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11460. }
  11461. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11462. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11463. //
  11464. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11465. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11466. var pp models.PublicParams
  11467. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11468. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11469. pp.FixmedinsName = miConfig.OrgName
  11470. pp.FixmedinsCode = miConfig.Code
  11471. pp.RequestUrl = miConfig.Url
  11472. pp.Cainfo = miConfig.Cainfo
  11473. pp.SecretKey = miConfig.SecretKey
  11474. pp.AccessKey = miConfig.AccessKey
  11475. pp.OpterName = roles.UserName
  11476. var config []*models.HisXtDiagnoseConfig
  11477. for _, item := range diagnosis_ids {
  11478. id, _ := strconv.ParseInt(item, 10, 64)
  11479. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11480. config = append(config, &diagnosisConfig)
  11481. }
  11482. var pd models.PatientDtos
  11483. pd.PatnID = his.PsnNo
  11484. pd.PatnName = his.Name
  11485. pd.Gend = his.Gend
  11486. pd.Brdy = his.Brdy
  11487. pd.Poolarea = his.InsuplcAdmdvs
  11488. pd.CurrMdtrtID = his.Number
  11489. var fed models.FsiEncounterDtos
  11490. fed.MdtrtID = his.Number
  11491. fed.MedinsID = miConfig.Code
  11492. fed.MedinsName = miConfig.OrgName
  11493. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11494. fed.MedMdtrtType = "1"
  11495. fed.MedinsType = "1"
  11496. fed.MedinsLv = "11"
  11497. tm := time.Unix(his.RecordDate, 0)
  11498. s_tm := tm.Format("2006-01-02 15:04:05")
  11499. fed.AdmDate = s_tm
  11500. fed.DscgDate = s_tm
  11501. fed.DscgMainDiseCodg = config[0].CountryCode
  11502. fed.DscgMainDiseName = config[0].CountryContentName
  11503. //诊断信息
  11504. var fdds []*models.FsiDiagnoseDtos
  11505. for index, item := range config {
  11506. if index == 0 {
  11507. var fdd models.FsiDiagnoseDtos
  11508. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11509. fdd.InoutDiseType = "1"
  11510. fdd.MaindiseFlag = "1"
  11511. fdd.DiseDate = s_tm
  11512. fdd.DiasSrtNo = "1"
  11513. fdd.DiseName = item.CountryContentName
  11514. fdd.DiseCodg = item.CountryCode
  11515. fdds = append(fdds, &fdd)
  11516. } else {
  11517. var fdd models.FsiDiagnoseDtos
  11518. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11519. fdd.InoutDiseType = "1"
  11520. fdd.MaindiseFlag = "1"
  11521. fdd.DiseDate = s_tm
  11522. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11523. fdd.DiseName = item.CountryContentName
  11524. fdd.DiseCodg = item.CountryCode
  11525. fdds = append(fdds, &fdd)
  11526. }
  11527. }
  11528. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11529. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11530. fed.AdmDeptName = department.Name
  11531. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11532. fed.DscgDeptName = department.Name
  11533. fed.MedMdtrtType = "1"
  11534. fed.MedType = "11"
  11535. //if his.Insutype == "390" {
  11536. // fed.MedType = "1402"
  11537. //} else {
  11538. // fed.MedType = "9933"
  11539. //}
  11540. var orders []*models.FsiOrderDtos
  11541. if trig_scen == "2" {
  11542. //处方医嘱信息
  11543. for _, item := range prescriptions {
  11544. for _, subItem := range item.HisDoctorAdviceInfo {
  11545. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11546. var order models.FsiOrderDtos
  11547. order.RxID = strconv.FormatInt(item.ID, 10)
  11548. order.Rxno = strconv.FormatInt(item.ID, 10)
  11549. order.LongDrordFlag = "0"
  11550. order.HilistType = "1"
  11551. order.ChrgType = "1"
  11552. order.DrordBhvr = "-"
  11553. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11554. order.HosplistName = subItem.BaseDrugLib.DrugName
  11555. order.HilistLv = "1"
  11556. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11557. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11558. order.HosplistName = subItem.BaseDrugLib.DrugName
  11559. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11560. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11561. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11562. order.OwnpayAmt = ""
  11563. order.SelfpayAmt = ""
  11564. order.Spec = ""
  11565. order.SpecUnt = ""
  11566. order.DrordBegnDate = s_tm
  11567. order.DrordStopDate = ""
  11568. order.DrordDrCodg = doctor_info.DoctorNumber
  11569. order.DrordDeptName = department.Name
  11570. order.DrordDeptCodg = department.Number
  11571. order.DrordDrName = doctor_info.UserName
  11572. order.DrordDrProfttl = "234"
  11573. order.CurrDrordFlag = "1"
  11574. orders = append(orders, &order)
  11575. }
  11576. }
  11577. for _, subItem := range item.HisPrescriptionProject {
  11578. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11579. var order models.FsiOrderDtos
  11580. order.RxID = strconv.FormatInt(item.ID, 10)
  11581. order.Rxno = strconv.FormatInt(item.ID, 10)
  11582. order.LongDrordFlag = "0"
  11583. order.HilistType = "1"
  11584. order.ChrgType = "1"
  11585. order.DrordBhvr = "-"
  11586. order.HilistCode = subItem.HisProject.MedicalCode
  11587. order.HosplistName = subItem.HisProject.ProjectName
  11588. order.HilistLv = "1"
  11589. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11590. order.HosplistCode = subItem.HisProject.MedicalCode
  11591. order.HosplistName = subItem.HisProject.ProjectName
  11592. order.Cnt = subItem.Count
  11593. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11594. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11595. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11596. order.OwnpayAmt = ""
  11597. order.SelfpayAmt = ""
  11598. order.Spec = ""
  11599. order.SpecUnt = ""
  11600. order.DrordBegnDate = s_tm
  11601. order.DrordStopDate = ""
  11602. order.DrordDrCodg = doctor_info.DoctorNumber
  11603. order.DrordDeptName = department.Name
  11604. order.DrordDeptCodg = department.Number
  11605. order.DrordDrName = doctor_info.UserName
  11606. order.DrordDrProfttl = "234"
  11607. order.CurrDrordFlag = "1"
  11608. orders = append(orders, &order)
  11609. }
  11610. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11611. var order models.FsiOrderDtos
  11612. order.RxID = strconv.FormatInt(item.ID, 10)
  11613. order.Rxno = strconv.FormatInt(item.ID, 10)
  11614. order.LongDrordFlag = "0"
  11615. order.HilistType = "1"
  11616. order.ChrgType = "1"
  11617. order.DrordBhvr = "-"
  11618. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11619. order.HosplistName = subItem.GoodInfo.GoodName
  11620. order.HilistLv = "1"
  11621. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11622. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11623. order.HosplistName = subItem.GoodInfo.GoodName
  11624. order.Cnt = subItem.Count
  11625. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11626. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11627. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11628. order.OwnpayAmt = ""
  11629. order.SelfpayAmt = ""
  11630. order.Spec = ""
  11631. order.SpecUnt = ""
  11632. order.DrordBegnDate = s_tm
  11633. order.DrordStopDate = ""
  11634. order.DrordDrCodg = doctor_info.DoctorNumber
  11635. order.DrordDeptName = department.Name
  11636. order.DrordDeptCodg = department.Number
  11637. order.DrordDrName = doctor_info.UserName
  11638. order.DrordDrProfttl = "234"
  11639. order.CurrDrordFlag = "1"
  11640. orders = append(orders, &order)
  11641. }
  11642. }
  11643. }
  11644. //处方医嘱信息
  11645. }
  11646. fed.MatnStas = "0"
  11647. fed.MedfeeSumamt = "0"
  11648. fed.OwnpayAmt = "0"
  11649. fed.SelfpayAmt = "0"
  11650. fed.AcctPayamt = "0"
  11651. fed.MaAmt = "0"
  11652. fed.HifpPayamt = "0"
  11653. fed.SetlTotlnum = "1"
  11654. fed.Insutype = his.Insutype
  11655. fed.ReimFlag = "0"
  11656. fed.OutSetlFlag = "0"
  11657. var fopd []*models.FsiOperationDtosData
  11658. data := make(map[string]interface{})
  11659. data["fed"] = fed
  11660. data["fdd"] = fdds
  11661. data["fod"] = orders
  11662. data["pd"] = pd
  11663. data["pp"] = pp
  11664. data["fopd"] = fopd
  11665. data["trig_scen"] = trig_scen
  11666. fmt.Println(data)
  11667. fmt.Println(fed)
  11668. fmt.Println(fdds)
  11669. fmt.Println(orders)
  11670. fmt.Println(pd)
  11671. fmt.Println(pp)
  11672. fmt.Println(fopd)
  11673. client := &http.Client{}
  11674. bytesData, _ := json.Marshal(data)
  11675. var req *http.Request
  11676. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11677. if miConfig.MdtrtareaAdmvs == "320830" {
  11678. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11679. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11680. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11681. } else {
  11682. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11683. }
  11684. resp, _ := client.Do(req)
  11685. defer resp.Body.Close()
  11686. body, ioErr := ioutil.ReadAll(resp.Body)
  11687. if ioErr != nil {
  11688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11690. return res
  11691. }
  11692. var respJSON map[string]interface{}
  11693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11696. return res
  11697. }
  11698. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11699. fmt.Println(respJSON)
  11700. result, _ := json.Marshal(respJSON)
  11701. fmt.Println(result)
  11702. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11703. utils.ErrorLog("解析失败:%v", err)
  11704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11705. return res
  11706. }
  11707. return res
  11708. } else {
  11709. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11710. saveLog(output, input, "3101", "事前")
  11711. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11712. utils.ErrorLog("解析失败:%v", err)
  11713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11714. return
  11715. }
  11716. return res
  11717. }
  11718. return res
  11719. }
  11720. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11721. ////patient_id, _ := c.GetInt64("patient_id")
  11722. //order_id, _ := c.GetInt64("order_id")
  11723. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11724. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11725. //trig_scen := c.GetString("trig_scen")
  11726. adminUser := c.GetAdminUserInfo()
  11727. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11728. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11729. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11730. record_time := c.GetString("record_time")
  11731. order, _ := service.GetHisOrderByID(order_id)
  11732. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11733. timeLayout := "2006-01-02"
  11734. loc, _ := time.LoadLocation("Local")
  11735. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11736. if err != nil {
  11737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11738. return
  11739. }
  11740. recordDateTime := theTime.Unix()
  11741. var patientPrescription models.HisPrescriptionInfo
  11742. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11743. if patientPrescription.ID == 0 {
  11744. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11745. }
  11746. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11747. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11748. //
  11749. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11750. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11751. var pp models.PublicParams
  11752. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11753. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11754. pp.FixmedinsName = miConfig.OrgName
  11755. pp.FixmedinsCode = miConfig.Code
  11756. pp.RequestUrl = miConfig.Url
  11757. pp.Cainfo = miConfig.Cainfo
  11758. pp.SecretKey = miConfig.SecretKey
  11759. pp.AccessKey = miConfig.AccessKey
  11760. pp.OpterName = roles.UserName
  11761. var config []*models.HisXtDiagnoseConfig
  11762. for _, item := range diagnosis_ids {
  11763. id, _ := strconv.ParseInt(item, 10, 64)
  11764. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11765. config = append(config, &diagnosisConfig)
  11766. }
  11767. var pd models.PatientDtos
  11768. pd.PatnID = his.PsnNo
  11769. pd.PatnName = his.Name
  11770. pd.Gend = his.Gend
  11771. pd.Brdy = psn_info.Brdy
  11772. pd.Poolarea = his.InsuplcAdmdvs
  11773. pd.CurrMdtrtID = his.Number
  11774. var fed models.FsiEncounterDtos
  11775. fed.MdtrtID = his.Number
  11776. fed.MedinsID = miConfig.Code
  11777. fed.MedinsName = miConfig.OrgName
  11778. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11779. fed.MedMdtrtType = "1"
  11780. fed.MedinsType = "1"
  11781. fed.MedinsLv = "11"
  11782. tm := time.Unix(his.RecordDate, 0)
  11783. s_tm := tm.Format("2006-01-02 15:04:05")
  11784. fed.AdmDate = s_tm
  11785. fed.DscgDate = s_tm
  11786. fed.DscgMainDiseCodg = config[0].CountryCode
  11787. fed.DscgMainDiseName = config[0].CountryContentName
  11788. //诊断信息
  11789. var fdds []*models.FsiDiagnoseDtos
  11790. for index, item := range config {
  11791. if index == 0 {
  11792. var fdd models.FsiDiagnoseDtos
  11793. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11794. fdd.InoutDiseType = "1"
  11795. fdd.MaindiseFlag = "1"
  11796. fdd.DiseDate = s_tm
  11797. fdd.DiasSrtNo = "1"
  11798. fdd.DiseName = item.CountryContentName
  11799. fdd.DiseCodg = item.CountryCode
  11800. fdds = append(fdds, &fdd)
  11801. } else {
  11802. var fdd models.FsiDiagnoseDtos
  11803. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11804. fdd.InoutDiseType = "1"
  11805. fdd.MaindiseFlag = "1"
  11806. fdd.DiseDate = s_tm
  11807. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11808. fdd.DiseName = item.CountryContentName
  11809. fdd.DiseCodg = item.CountryCode
  11810. fdds = append(fdds, &fdd)
  11811. }
  11812. }
  11813. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11814. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11815. fed.AdmDeptName = department.Name
  11816. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11817. fed.DscgDeptName = department.Name
  11818. fed.MedType = order.MedType
  11819. //处方医嘱信息
  11820. var orders []*models.FsiOrderDtos
  11821. //for _, item := range prescriptions {
  11822. // for _, subItem := range item.HisDoctorAdviceInfo {
  11823. // var order models.FsiOrderDtos
  11824. // order.RxID = strconv.FormatInt(item.ID, 10)
  11825. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11826. // order.LongDrordFlag = "0"
  11827. // order.HilistType = "1"
  11828. // order.ChrgType = "1"
  11829. // order.DrordBhvr = "-"
  11830. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11831. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11832. // order.HilistLv = "1"
  11833. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11834. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11835. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11836. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11837. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11838. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11839. // order.OwnpayAmt = ""
  11840. // order.SelfpayAmt = ""
  11841. // order.Spec = ""
  11842. // order.SpecUnt = ""
  11843. // order.DrordBegnDate = s_tm
  11844. // order.DrordStopDate = ""
  11845. // order.DrordDrCodg = "1"
  11846. // order.DrordDeptName = department.Name
  11847. // order.DrordDrCodg = "1"
  11848. // order.DrordDrName = doctor_info.UserName
  11849. // order.DrordDrProfttl = ""
  11850. // order.CurrDrordFlag = "1"
  11851. // orders = append(orders, &order)
  11852. // }
  11853. // for _, subItem := range item.HisPrescriptionProject {
  11854. // if subItem.Type == 2 {
  11855. // var order models.FsiOrderDtos
  11856. // order.RxID = strconv.FormatInt(item.ID, 10)
  11857. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11858. // order.LongDrordFlag = "0"
  11859. // order.HilistType = "1"
  11860. // order.ChrgType = "1"
  11861. // order.DrordBhvr = "-"
  11862. // order.HilistCode = subItem.HisProject.MedicalCode
  11863. // order.HosplistName = subItem.HisProject.ProjectName
  11864. // order.HilistLv = "1"
  11865. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11866. // order.HosplistCode = subItem.HisProject.MedicalCode
  11867. // order.HosplistName = subItem.HisProject.ProjectName
  11868. // order.Cnt = subItem.Count
  11869. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11870. //
  11871. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11872. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11873. // order.OwnpayAmt = ""
  11874. // order.SelfpayAmt = ""
  11875. // order.Spec = ""
  11876. // order.SpecUnt = ""
  11877. // order.DrordBegnDate = s_tm
  11878. // order.DrordStopDate = ""
  11879. // order.DrordDrCodg = "1"
  11880. // order.DrordDeptName = department.Name
  11881. // order.DrordDrCodg = "1"
  11882. // order.DrordDrName = doctor_info.UserName
  11883. // order.DrordDrProfttl = ""
  11884. // order.CurrDrordFlag = "1"
  11885. // orders = append(orders, &order)
  11886. //
  11887. // }
  11888. // if subItem.Type == 3 {
  11889. //
  11890. // var order models.FsiOrderDtos
  11891. // order.RxID = strconv.FormatInt(item.ID, 10)
  11892. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11893. // order.LongDrordFlag = "0"
  11894. // order.HilistType = "1"
  11895. // order.ChrgType = "1"
  11896. // order.DrordBhvr = "-"
  11897. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11898. // order.HosplistName = subItem.GoodInfo.GoodName
  11899. // order.HilistLv = "1"
  11900. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11901. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11902. // order.HosplistName = subItem.GoodInfo.GoodName
  11903. // order.Cnt = subItem.Count
  11904. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11905. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11906. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11907. // order.OwnpayAmt = ""
  11908. // order.SelfpayAmt = ""
  11909. // order.Spec = ""
  11910. // order.SpecUnt = ""
  11911. // order.DrordBegnDate = s_tm
  11912. // order.DrordStopDate = ""
  11913. // order.DrordDrCodg = "1"
  11914. // order.DrordDeptName = department.Name
  11915. // order.DrordDrCodg = "1"
  11916. // order.DrordDrName = doctor_info.UserName
  11917. // order.DrordDrProfttl = ""
  11918. // order.CurrDrordFlag = "1"
  11919. // orders = append(orders, &order)
  11920. //
  11921. // }
  11922. // }
  11923. //}
  11924. for _, item := range prescriptions {
  11925. for _, subItem := range item.HisDoctorAdviceInfo {
  11926. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11927. var order models.FsiOrderDtos
  11928. order.RxID = strconv.FormatInt(item.ID, 10)
  11929. order.Rxno = strconv.FormatInt(item.ID, 10)
  11930. order.LongDrordFlag = "0"
  11931. order.HilistType = "101"
  11932. order.ChrgType = "1"
  11933. order.DrordBhvr = "-"
  11934. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11935. order.HosplistName = subItem.BaseDrugLib.DrugName
  11936. order.HilistLv = "1"
  11937. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11938. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11939. order.HosplistName = subItem.BaseDrugLib.DrugName
  11940. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11941. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11942. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11943. order.OwnpayAmt = ""
  11944. order.SelfpayAmt = ""
  11945. order.Spec = ""
  11946. order.SpecUnt = ""
  11947. order.DrordBegnDate = s_tm
  11948. order.DrordStopDate = ""
  11949. order.DrordDrCodg = doctor_info.DoctorNumber
  11950. order.DrordDeptName = department.Name
  11951. order.DrordDeptCodg = department.Number
  11952. order.DrordDrName = doctor_info.UserName
  11953. order.DrordDrProfttl = "234"
  11954. order.CurrDrordFlag = "1"
  11955. orders = append(orders, &order)
  11956. }
  11957. }
  11958. for _, subItem := range item.HisPrescriptionProject {
  11959. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11960. var order models.FsiOrderDtos
  11961. order.RxID = strconv.FormatInt(item.ID, 10)
  11962. order.Rxno = strconv.FormatInt(item.ID, 10)
  11963. order.LongDrordFlag = "0"
  11964. order.HilistType = "201"
  11965. order.ChrgType = "1"
  11966. order.DrordBhvr = "-"
  11967. order.HilistCode = subItem.HisProject.MedicalCode
  11968. order.HosplistName = subItem.HisProject.ProjectName
  11969. order.HilistLv = "1"
  11970. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11971. order.HosplistCode = subItem.HisProject.MedicalCode
  11972. order.HosplistName = subItem.HisProject.ProjectName
  11973. order.Cnt = subItem.Count
  11974. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11975. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11976. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11977. order.OwnpayAmt = ""
  11978. order.SelfpayAmt = ""
  11979. order.Spec = ""
  11980. order.SpecUnt = ""
  11981. order.DrordBegnDate = s_tm
  11982. order.DrordStopDate = ""
  11983. order.DrordDrCodg = doctor_info.DoctorNumber
  11984. order.DrordDeptName = department.Name
  11985. order.DrordDeptCodg = department.Number
  11986. order.DrordDrName = doctor_info.UserName
  11987. order.DrordDrProfttl = "234"
  11988. order.CurrDrordFlag = "1"
  11989. orders = append(orders, &order)
  11990. }
  11991. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11992. var order models.FsiOrderDtos
  11993. order.RxID = strconv.FormatInt(item.ID, 10)
  11994. order.Rxno = strconv.FormatInt(item.ID, 10)
  11995. order.LongDrordFlag = "0"
  11996. order.HilistType = "301"
  11997. order.ChrgType = "1"
  11998. order.DrordBhvr = "0"
  11999. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12000. order.HosplistName = subItem.GoodInfo.GoodName
  12001. order.HilistLv = "1"
  12002. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12003. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12004. order.HosplistName = subItem.GoodInfo.GoodName
  12005. order.Cnt = subItem.Count
  12006. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12007. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12008. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12009. order.OwnpayAmt = ""
  12010. order.SelfpayAmt = ""
  12011. order.Spec = ""
  12012. order.SpecUnt = ""
  12013. order.DrordBegnDate = s_tm
  12014. order.DrordStopDate = ""
  12015. order.DrordDrCodg = doctor_info.DoctorNumber
  12016. order.DrordDeptName = department.Name
  12017. order.DrordDeptCodg = department.Number
  12018. order.DrordDrName = doctor_info.UserName
  12019. order.DrordDrProfttl = "234"
  12020. order.CurrDrordFlag = "1"
  12021. orders = append(orders, &order)
  12022. }
  12023. }
  12024. }
  12025. //处方医嘱信息
  12026. fed.MatnStas = "0"
  12027. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12028. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12029. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12030. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12031. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12032. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12033. fed.SetlTotlnum = "1"
  12034. fed.Insutype = his.Insutype
  12035. fed.ReimFlag = "0"
  12036. fed.OutSetlFlag = "0"
  12037. var fopd []*models.FsiOperationDtosData
  12038. data := make(map[string]interface{})
  12039. data["fed"] = fed
  12040. data["fdd"] = fdds
  12041. data["fod"] = orders
  12042. data["pd"] = pd
  12043. data["pp"] = pp
  12044. data["fopd"] = fopd
  12045. data["trig_scen"] = trig_scen
  12046. client := &http.Client{}
  12047. bytesData, _ := json.Marshal(data)
  12048. var req *http.Request
  12049. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12050. if miConfig.MdtrtareaAdmvs == "320830" {
  12051. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12052. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12053. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12054. } else {
  12055. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12056. }
  12057. resp, _ := client.Do(req)
  12058. defer resp.Body.Close()
  12059. body, ioErr := ioutil.ReadAll(resp.Body)
  12060. if ioErr != nil {
  12061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12063. return res
  12064. }
  12065. var respJSON map[string]interface{}
  12066. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12069. return res
  12070. }
  12071. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12072. result, _ := json.Marshal(respJSON)
  12073. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12074. utils.ErrorLog("解析失败:%v", err)
  12075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12076. return res
  12077. }
  12078. return res
  12079. } else {
  12080. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12081. saveLog(output, input, "3102", "事中")
  12082. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12083. utils.ErrorLog("解析失败:%v", err)
  12084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12085. return
  12086. }
  12087. return res
  12088. }
  12089. return res
  12090. }
  12091. 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) {
  12092. var res Resultgd3101
  12093. adminUser := c.GetAdminUserInfo()
  12094. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12095. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12097. //record_time := c.GetString("record_time")
  12098. //trig_scen := c.GetString("trig_scen")
  12099. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12100. //psn_info, _ := service.GetPatientId(patient_id)
  12101. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12102. timeLayout := "2006-01-02"
  12103. loc, _ := time.LoadLocation("Local")
  12104. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12105. if err != nil {
  12106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12107. return res
  12108. }
  12109. recordDateTime := theTime.Unix()
  12110. var patientPrescription models.HisPrescriptionInfo
  12111. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12112. //if patientPrescription.ID == 0 {
  12113. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12114. //}
  12115. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12116. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12117. //
  12118. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12119. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12120. var str string
  12121. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12122. str = timestampToBirthdayString(patient.Birthday)
  12123. } else {
  12124. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12125. }
  12126. var pp models.PublicParams
  12127. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12128. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12129. pp.FixmedinsName = miConfig.OrgName
  12130. pp.FixmedinsCode = miConfig.Code
  12131. pp.RequestUrl = miConfig.Url
  12132. pp.Cainfo = miConfig.Cainfo
  12133. pp.SecretKey = miConfig.SecretKey
  12134. pp.AccessKey = miConfig.AccessKey
  12135. pp.OpterName = roles.UserName
  12136. var config []*models.HisXtDiagnoseConfig
  12137. for _, item := range diagnosis_ids {
  12138. id, _ := strconv.ParseInt(item, 10, 64)
  12139. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12140. config = append(config, &diagnosisConfig)
  12141. }
  12142. if len(config) == 0 {
  12143. var config1 models.HisXtDiagnoseConfig
  12144. config1.CountryCode = "N18.500"
  12145. config1.CountryContentName = "慢性肾脏病5期"
  12146. config = append(config, &config1)
  12147. }
  12148. var pd models.PatientDtos
  12149. pd.PatnID = his.PsnNo
  12150. pd.PatnName = his.Name
  12151. pd.Gend = his.Gend
  12152. pd.Brdy = str
  12153. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12154. pd.CurrMdtrtID = his.Number
  12155. var fed models.FsiEncounterDtos
  12156. fed.MdtrtID = his.Number
  12157. fed.MedinsID = miConfig.Code
  12158. fed.MedinsName = miConfig.OrgName
  12159. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12160. fed.MedMdtrtType = "1"
  12161. fed.MedinsType = "1"
  12162. fed.MedinsLv = "11"
  12163. tm := time.Unix(his.RecordDate, 0)
  12164. s_tm := tm.Format("2006-01-02 15:04:05")
  12165. fed.AdmDate = s_tm
  12166. fed.DscgDate = s_tm
  12167. fed.DscgMainDiseCodg = config[0].CountryCode
  12168. fed.DscgMainDiseName = config[0].CountryContentName
  12169. //诊断信息
  12170. var fdds []*models.FsiDiagnoseDtos
  12171. for index, item := range config {
  12172. if index == 0 {
  12173. var fdd models.FsiDiagnoseDtos
  12174. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12175. fdd.InoutDiseType = "1"
  12176. fdd.MaindiseFlag = "1"
  12177. fdd.DiseDate = s_tm
  12178. fdd.DiasSrtNo = "1"
  12179. fdd.DiseName = item.CountryContentName
  12180. fdd.DiseCodg = item.CountryCode
  12181. fdds = append(fdds, &fdd)
  12182. } else {
  12183. var fdd models.FsiDiagnoseDtos
  12184. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12185. fdd.InoutDiseType = "1"
  12186. fdd.MaindiseFlag = "1"
  12187. fdd.DiseDate = s_tm
  12188. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12189. fdd.DiseName = item.CountryContentName
  12190. fdd.DiseCodg = item.CountryCode
  12191. fdds = append(fdds, &fdd)
  12192. }
  12193. }
  12194. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12195. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12196. fed.AdmDeptName = de.Name
  12197. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12198. fed.DscgDeptName = de.Name
  12199. fed.MedMdtrtType = "1"
  12200. fed.MedType = "11"
  12201. //if his.Insutype == "390" {
  12202. // fed.MedType = "1402"
  12203. //} else {
  12204. // fed.MedType = "9933"
  12205. //}
  12206. var orders []*models.FsiOrderDtos
  12207. if trig_scen == "2" {
  12208. //处方医嘱信息
  12209. for _, item := range prescriptions {
  12210. for _, subItem := range item.HisDoctorAdviceInfo {
  12211. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12212. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12213. var order models.FsiOrderDtos
  12214. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12215. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12216. order.LongDrordFlag = "0"
  12217. order.HilistType = "101"
  12218. order.ChrgType = "1"
  12219. order.DrordBhvr = "0"
  12220. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12221. order.HosplistName = subItem.BaseDrugLib.DrugName
  12222. order.HilistLv = "1"
  12223. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12224. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12225. order.HosplistName = subItem.BaseDrugLib.DrugName
  12226. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12227. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12228. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12229. order.OwnpayAmt = ""
  12230. order.SelfpayAmt = ""
  12231. order.Spec = spec
  12232. order.SpecUnt = subItem.PrescribingNumberUnit
  12233. order.DrordBegnDate = s_tm
  12234. order.DrordStopDate = ""
  12235. order.DrordDrCodg = doctor_info.DoctorNumber
  12236. order.DrordDeptName = department.Name
  12237. order.DrordDeptCodg = department.Number
  12238. order.DrordDrName = doctor_info.UserName
  12239. order.DrordDrProfttl = "234"
  12240. order.CurrDrordFlag = "1"
  12241. orders = append(orders, &order)
  12242. }
  12243. }
  12244. for _, subItem := range item.HisPrescriptionProject {
  12245. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12246. var order models.FsiOrderDtos
  12247. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12248. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12249. order.LongDrordFlag = "0"
  12250. order.HilistType = "201"
  12251. order.ChrgType = "1"
  12252. order.DrordBhvr = "0"
  12253. order.HilistCode = subItem.HisProject.MedicalCode
  12254. order.HosplistName = subItem.HisProject.ProjectName
  12255. order.HilistLv = "1"
  12256. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12257. order.HosplistCode = subItem.HisProject.MedicalCode
  12258. order.HosplistName = subItem.HisProject.ProjectName
  12259. order.Cnt = subItem.Count
  12260. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12261. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12262. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12263. order.OwnpayAmt = ""
  12264. order.SelfpayAmt = ""
  12265. if subItem.Unit == "" {
  12266. order.Spec = "次"
  12267. order.SpecUnt = "次"
  12268. } else {
  12269. order.Spec = subItem.Unit
  12270. order.SpecUnt = subItem.Unit
  12271. }
  12272. order.DrordBegnDate = s_tm
  12273. order.DrordStopDate = ""
  12274. order.DrordDrCodg = doctor_info.DoctorNumber
  12275. order.DrordDeptName = department.Name
  12276. order.DrordDeptCodg = department.Number
  12277. order.DrordDrName = doctor_info.UserName
  12278. order.DrordDrProfttl = "234"
  12279. order.CurrDrordFlag = "1"
  12280. orders = append(orders, &order)
  12281. }
  12282. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12283. var order models.FsiOrderDtos
  12284. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12285. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12286. order.LongDrordFlag = "0"
  12287. order.HilistType = "301"
  12288. order.ChrgType = "1"
  12289. order.DrordBhvr = "0"
  12290. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12291. order.HosplistName = subItem.GoodInfo.GoodName
  12292. order.HilistLv = "1"
  12293. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12294. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12295. order.HosplistName = subItem.GoodInfo.GoodName
  12296. order.Cnt = subItem.Count
  12297. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12298. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12299. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12300. order.OwnpayAmt = ""
  12301. order.SelfpayAmt = ""
  12302. order.Spec = subItem.GoodInfo.SpecificationName
  12303. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12304. order.DrordBegnDate = s_tm
  12305. order.DrordStopDate = ""
  12306. order.DrordDrCodg = doctor_info.DoctorNumber
  12307. order.DrordDeptName = department.Name
  12308. order.DrordDeptCodg = department.Number
  12309. order.DrordDrName = doctor_info.UserName
  12310. order.DrordDrProfttl = "234"
  12311. order.CurrDrordFlag = "1"
  12312. orders = append(orders, &order)
  12313. }
  12314. }
  12315. }
  12316. //处方医嘱信息
  12317. }
  12318. fed.MatnStas = "0"
  12319. fed.MedfeeSumamt = "0"
  12320. fed.OwnpayAmt = "0"
  12321. fed.SelfpayAmt = "0"
  12322. fed.AcctPayamt = "0"
  12323. fed.MaAmt = "0"
  12324. fed.HifpPayamt = "0"
  12325. fed.SetlTotlnum = "1"
  12326. fed.Insutype = his.Insutype
  12327. fed.ReimFlag = "0"
  12328. fed.OutSetlFlag = "0"
  12329. var fopd []*models.FsiOperationDtosData
  12330. data := make(map[string]interface{})
  12331. data["fed"] = fed
  12332. data["fdd"] = fdds
  12333. data["fod"] = orders
  12334. data["pd"] = pd
  12335. data["pp"] = pp
  12336. data["fopd"] = fopd
  12337. data["trig_scen"] = trig_scen
  12338. fmt.Println(data)
  12339. fmt.Println(fed)
  12340. fmt.Println(fdds)
  12341. fmt.Println(orders)
  12342. fmt.Println(pd)
  12343. fmt.Println(pp)
  12344. fmt.Println(fopd)
  12345. client := &http.Client{}
  12346. bytesData, _ := json.Marshal(data)
  12347. var req *http.Request
  12348. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12349. if miConfig.MdtrtareaAdmvs == "320830" {
  12350. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12351. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12352. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12353. } else {
  12354. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12355. }
  12356. resp, _ := client.Do(req)
  12357. defer resp.Body.Close()
  12358. body, ioErr := ioutil.ReadAll(resp.Body)
  12359. if ioErr != nil {
  12360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12362. return res
  12363. }
  12364. var respJSON map[string]interface{}
  12365. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12368. return res
  12369. }
  12370. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12371. fmt.Println(respJSON)
  12372. result, _ := json.Marshal(respJSON)
  12373. fmt.Println(result)
  12374. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12375. utils.ErrorLog("解析失败:%v", err)
  12376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12377. return res
  12378. }
  12379. return res
  12380. } else {
  12381. //if miConfig.MdtrtareaAdmvs == "441202" {
  12382. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12383. saveLog(output, input, "3101", "事前")
  12384. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12385. utils.ErrorLog("解析失败:%v", err)
  12386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. return
  12388. }
  12389. return res
  12390. //}
  12391. }
  12392. }
  12393. 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) {
  12394. adminUser := c.GetAdminUserInfo()
  12395. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12396. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12397. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12398. //record_time := c.GetString("record_time")
  12399. //trig_scen := c.GetString("trig_scen")
  12400. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12401. timeLayout := "2006-01-02"
  12402. loc, _ := time.LoadLocation("Local")
  12403. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12404. if err != nil {
  12405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12406. return res
  12407. }
  12408. recordDateTime := theTime.Unix()
  12409. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12410. var patientPrescription models.HisPrescriptionInfo
  12411. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12412. if patientPrescription.ID == 0 {
  12413. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12414. }
  12415. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12416. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12417. //
  12418. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12419. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12420. var pp models.PublicParams
  12421. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12422. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12423. pp.FixmedinsName = miConfig.OrgName
  12424. pp.FixmedinsCode = miConfig.Code
  12425. pp.RequestUrl = miConfig.Url
  12426. pp.Cainfo = miConfig.Cainfo
  12427. pp.SecretKey = miConfig.SecretKey
  12428. pp.AccessKey = miConfig.AccessKey
  12429. pp.OpterName = roles.UserName
  12430. var config []*models.HisXtDiagnoseConfig
  12431. for _, item := range diagnosis_ids {
  12432. id, _ := strconv.ParseInt(item, 10, 64)
  12433. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12434. config = append(config, &diagnosisConfig)
  12435. }
  12436. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12437. var str string
  12438. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12439. str = timestampToBirthdayString(patient.Birthday)
  12440. } else {
  12441. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12442. }
  12443. var pd models.PatientDtos
  12444. pd.PatnID = his.PsnNo
  12445. pd.PatnName = his.Name
  12446. pd.Gend = his.Gend
  12447. pd.Brdy = str
  12448. pd.Poolarea = his.InsuplcAdmdvs
  12449. pd.CurrMdtrtID = his.Number
  12450. var fed models.FsiEncounterDtos
  12451. fed.MdtrtID = his.Number
  12452. fed.MedinsID = miConfig.Code
  12453. fed.MedinsName = miConfig.OrgName
  12454. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12455. fed.MedMdtrtType = "1"
  12456. fed.MedinsType = "1"
  12457. fed.MedinsLv = "11"
  12458. tm := time.Unix(his.RecordDate, 0)
  12459. s_tm := tm.Format("2006-01-02 15:04:05")
  12460. fed.AdmDate = s_tm
  12461. fed.DscgDate = s_tm
  12462. fed.DscgMainDiseCodg = config[0].CountryCode
  12463. fed.DscgMainDiseName = config[0].CountryContentName
  12464. //诊断信息
  12465. var fdds []*models.FsiDiagnoseDtos
  12466. for index, item := range config {
  12467. if index == 0 {
  12468. var fdd models.FsiDiagnoseDtos
  12469. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12470. fdd.InoutDiseType = "1"
  12471. fdd.MaindiseFlag = "1"
  12472. fdd.DiseDate = s_tm
  12473. fdd.DiasSrtNo = "1"
  12474. fdd.DiseName = item.CountryContentName
  12475. fdd.DiseCodg = item.CountryCode
  12476. fdds = append(fdds, &fdd)
  12477. } else {
  12478. var fdd models.FsiDiagnoseDtos
  12479. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12480. fdd.InoutDiseType = "1"
  12481. fdd.MaindiseFlag = "1"
  12482. fdd.DiseDate = s_tm
  12483. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12484. fdd.DiseName = item.CountryContentName
  12485. fdd.DiseCodg = item.CountryCode
  12486. fdds = append(fdds, &fdd)
  12487. }
  12488. }
  12489. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12490. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12491. fed.AdmDeptName = department.Name
  12492. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12493. fed.DscgDeptName = department.Name
  12494. fed.MedMdtrtType = "1"
  12495. fed.MedType = "11"
  12496. //if his.Insutype == "390" {
  12497. // fed.MedType = "1402"
  12498. //} else {
  12499. // fed.MedType = "9933"
  12500. //}
  12501. var orders []*models.FsiOrderDtos
  12502. if trig_scen == "2" {
  12503. //处方医嘱信息
  12504. for _, item := range prescriptions {
  12505. for _, subItem := range item.HisDoctorAdviceInfo {
  12506. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12507. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "/" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit
  12508. var order models.FsiOrderDtos
  12509. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12510. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12511. order.LongDrordFlag = "0"
  12512. order.HilistType = "101"
  12513. order.ChrgType = "1"
  12514. order.DrordBhvr = "0"
  12515. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12516. order.HosplistName = subItem.BaseDrugLib.DrugName
  12517. order.HilistLv = "1"
  12518. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12519. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12520. order.HosplistName = subItem.BaseDrugLib.DrugName
  12521. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12522. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12523. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12524. order.OwnpayAmt = ""
  12525. order.SelfpayAmt = ""
  12526. order.Spec = spec
  12527. order.SpecUnt = subItem.PrescribingNumberUnit
  12528. order.DrordBegnDate = s_tm
  12529. order.DrordStopDate = ""
  12530. order.DrordDrCodg = doctor_info.DoctorNumber
  12531. order.DrordDeptName = department.Name
  12532. order.DrordDeptCodg = department.Number
  12533. order.DrordDrName = doctor_info.UserName
  12534. order.DrordDrProfttl = "234"
  12535. order.CurrDrordFlag = "1"
  12536. orders = append(orders, &order)
  12537. }
  12538. }
  12539. for _, subItem := range item.HisPrescriptionProject {
  12540. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12541. var order models.FsiOrderDtos
  12542. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12543. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12544. order.LongDrordFlag = "0"
  12545. order.HilistType = "201"
  12546. order.ChrgType = "1"
  12547. order.DrordBhvr = "0"
  12548. order.HilistCode = subItem.HisProject.MedicalCode
  12549. order.HosplistName = subItem.HisProject.ProjectName
  12550. order.HilistLv = "1"
  12551. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12552. order.HosplistCode = subItem.HisProject.MedicalCode
  12553. order.HosplistName = subItem.HisProject.ProjectName
  12554. order.Cnt = subItem.Count
  12555. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12556. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12557. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12558. order.OwnpayAmt = ""
  12559. order.SelfpayAmt = ""
  12560. if subItem.Unit == "" {
  12561. order.Spec = "次"
  12562. order.SpecUnt = "次"
  12563. } else {
  12564. order.Spec = subItem.Unit
  12565. order.SpecUnt = subItem.Unit
  12566. }
  12567. order.DrordBegnDate = s_tm
  12568. order.DrordStopDate = ""
  12569. order.DrordDrCodg = doctor_info.DoctorNumber
  12570. order.DrordDeptName = department.Name
  12571. order.DrordDeptCodg = department.Number
  12572. order.DrordDrName = doctor_info.UserName
  12573. order.DrordDrProfttl = "234"
  12574. order.CurrDrordFlag = "1"
  12575. orders = append(orders, &order)
  12576. }
  12577. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12578. var order models.FsiOrderDtos
  12579. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12580. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12581. order.LongDrordFlag = "0"
  12582. order.HilistType = "301"
  12583. order.ChrgType = "1"
  12584. order.DrordBhvr = "0"
  12585. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12586. order.HosplistName = subItem.GoodInfo.GoodName
  12587. order.HilistLv = "1"
  12588. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12589. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12590. order.HosplistName = subItem.GoodInfo.GoodName
  12591. order.Cnt = subItem.Count
  12592. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12593. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12594. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12595. order.OwnpayAmt = ""
  12596. order.SelfpayAmt = ""
  12597. order.Spec = subItem.GoodInfo.SpecificationName
  12598. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12599. order.DrordBegnDate = s_tm
  12600. order.DrordStopDate = ""
  12601. order.DrordDrCodg = doctor_info.DoctorNumber
  12602. order.DrordDeptName = department.Name
  12603. order.DrordDeptCodg = department.Number
  12604. order.DrordDrName = doctor_info.UserName
  12605. order.DrordDrProfttl = "234"
  12606. order.CurrDrordFlag = "1"
  12607. orders = append(orders, &order)
  12608. }
  12609. }
  12610. }
  12611. //处方医嘱信息
  12612. }
  12613. fed.MatnStas = "0"
  12614. fed.MedfeeSumamt = "0"
  12615. fed.OwnpayAmt = "0"
  12616. fed.SelfpayAmt = "0"
  12617. fed.AcctPayamt = "0"
  12618. fed.MaAmt = "0"
  12619. fed.HifpPayamt = "0"
  12620. fed.SetlTotlnum = "1"
  12621. fed.Insutype = his.Insutype
  12622. fed.ReimFlag = "0"
  12623. fed.OutSetlFlag = "0"
  12624. var fopd []*models.FsiOperationDtosData
  12625. data := make(map[string]interface{})
  12626. data["fed"] = fed
  12627. data["fdd"] = fdds
  12628. data["fod"] = orders
  12629. data["pd"] = pd
  12630. data["pp"] = pp
  12631. data["fopd"] = fopd
  12632. data["trig_scen"] = trig_scen
  12633. fmt.Println(data)
  12634. fmt.Println(fed)
  12635. fmt.Println(fdds)
  12636. fmt.Println(orders)
  12637. fmt.Println(pd)
  12638. fmt.Println(pp)
  12639. fmt.Println(fopd)
  12640. client := &http.Client{}
  12641. bytesData, _ := json.Marshal(data)
  12642. var req *http.Request
  12643. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12644. if miConfig.MdtrtareaAdmvs == "320830" {
  12645. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12646. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12647. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12648. } else {
  12649. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12650. }
  12651. resp, _ := client.Do(req)
  12652. defer resp.Body.Close()
  12653. body, ioErr := ioutil.ReadAll(resp.Body)
  12654. if ioErr != nil {
  12655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12657. return res
  12658. }
  12659. var respJSON map[string]interface{}
  12660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12663. return res
  12664. }
  12665. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12666. fmt.Println(respJSON)
  12667. result, _ := json.Marshal(respJSON)
  12668. fmt.Println(result)
  12669. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12670. utils.ErrorLog("解析失败:%v", err)
  12671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12672. return res
  12673. }
  12674. return res
  12675. } else {
  12676. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12677. saveLog(output, input, "3101", "事前")
  12678. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12679. utils.ErrorLog("解析失败:%v", err)
  12680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12681. return
  12682. }
  12683. return res
  12684. }
  12685. return res
  12686. }
  12687. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12688. adminUser := c.GetAdminUserInfo()
  12689. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12690. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12691. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12692. record_time := c.GetString("record_time")
  12693. order, _ := service.GetHisOrderByID(order_id)
  12694. timeLayout := "2006-01-02"
  12695. loc, _ := time.LoadLocation("Local")
  12696. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12697. if err != nil {
  12698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12699. return
  12700. }
  12701. recordDateTime := theTime.Unix()
  12702. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12703. var patientPrescription models.HisPrescriptionInfo
  12704. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12705. if patientPrescription.ID == 0 {
  12706. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12707. }
  12708. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12709. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12710. //
  12711. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12712. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12713. var pp models.PublicParams
  12714. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12715. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12716. pp.FixmedinsName = miConfig.OrgName
  12717. pp.FixmedinsCode = miConfig.Code
  12718. pp.RequestUrl = miConfig.Url
  12719. pp.Cainfo = miConfig.Cainfo
  12720. pp.SecretKey = miConfig.SecretKey
  12721. pp.AccessKey = miConfig.AccessKey
  12722. pp.OpterName = roles.UserName
  12723. var config []*models.HisXtDiagnoseConfig
  12724. for _, item := range diagnosis_ids {
  12725. id, _ := strconv.ParseInt(item, 10, 64)
  12726. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12727. config = append(config, &diagnosisConfig)
  12728. }
  12729. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12730. var str string
  12731. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12732. str = timestampToBirthdayString(patient.Birthday)
  12733. } else {
  12734. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12735. }
  12736. var pd models.PatientDtos
  12737. pd.PatnID = his.PsnNo
  12738. pd.PatnName = his.Name
  12739. pd.Gend = his.Gend
  12740. pd.Brdy = str
  12741. pd.Poolarea = his.InsuplcAdmdvs
  12742. pd.CurrMdtrtID = his.Number
  12743. var fed models.FsiEncounterDtos
  12744. fed.MdtrtID = his.Number
  12745. fed.MedinsID = miConfig.Code
  12746. fed.MedinsName = miConfig.OrgName
  12747. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12748. fed.MedMdtrtType = "1"
  12749. fed.MedinsType = "1"
  12750. fed.MedinsLv = "11"
  12751. tm := time.Unix(his.RecordDate, 0)
  12752. s_tm := tm.Format("2006-01-02 15:04:05")
  12753. fed.AdmDate = s_tm
  12754. fed.DscgDate = s_tm
  12755. fed.DscgMainDiseCodg = config[0].CountryCode
  12756. fed.DscgMainDiseName = config[0].CountryContentName
  12757. //诊断信息
  12758. var fdds []*models.FsiDiagnoseDtos
  12759. for index, item := range config {
  12760. if index == 0 {
  12761. var fdd models.FsiDiagnoseDtos
  12762. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12763. fdd.InoutDiseType = "1"
  12764. fdd.MaindiseFlag = "1"
  12765. fdd.DiseDate = s_tm
  12766. fdd.DiasSrtNo = "1"
  12767. fdd.DiseName = item.CountryContentName
  12768. fdd.DiseCodg = item.CountryCode
  12769. fdds = append(fdds, &fdd)
  12770. } else {
  12771. var fdd models.FsiDiagnoseDtos
  12772. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12773. fdd.InoutDiseType = "1"
  12774. fdd.MaindiseFlag = "1"
  12775. fdd.DiseDate = s_tm
  12776. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12777. fdd.DiseName = item.CountryContentName
  12778. fdd.DiseCodg = item.CountryCode
  12779. fdds = append(fdds, &fdd)
  12780. }
  12781. }
  12782. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12783. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12784. fed.AdmDeptName = department.Name
  12785. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12786. fed.DscgDeptName = department.Name
  12787. fed.MedType = order.MedType
  12788. //处方医嘱信息
  12789. var orders []*models.FsiOrderDtos
  12790. //for _, item := range prescriptions {
  12791. // for _, subItem := range item.HisDoctorAdviceInfo {
  12792. // var order models.FsiOrderDtos
  12793. // order.RxID = strconv.FormatInt(item.ID, 10)
  12794. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12795. // order.LongDrordFlag = "0"
  12796. // order.HilistType = "1"
  12797. // order.ChrgType = "1"
  12798. // order.DrordBhvr = "-"
  12799. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12800. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12801. // order.HilistLv = "1"
  12802. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12803. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12804. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12805. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12806. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12807. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12808. // order.OwnpayAmt = ""
  12809. // order.SelfpayAmt = ""
  12810. // order.Spec = ""
  12811. // order.SpecUnt = ""
  12812. // order.DrordBegnDate = s_tm
  12813. // order.DrordStopDate = ""
  12814. // order.DrordDrCodg = "1"
  12815. // order.DrordDeptName = department.Name
  12816. // order.DrordDrCodg = "1"
  12817. // order.DrordDrName = doctor_info.UserName
  12818. // order.DrordDrProfttl = ""
  12819. // order.CurrDrordFlag = "1"
  12820. // orders = append(orders, &order)
  12821. // }
  12822. // for _, subItem := range item.HisPrescriptionProject {
  12823. // if subItem.Type == 2 {
  12824. // var order models.FsiOrderDtos
  12825. // order.RxID = strconv.FormatInt(item.ID, 10)
  12826. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12827. // order.LongDrordFlag = "0"
  12828. // order.HilistType = "1"
  12829. // order.ChrgType = "1"
  12830. // order.DrordBhvr = "-"
  12831. // order.HilistCode = subItem.HisProject.MedicalCode
  12832. // order.HosplistName = subItem.HisProject.ProjectName
  12833. // order.HilistLv = "1"
  12834. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12835. // order.HosplistCode = subItem.HisProject.MedicalCode
  12836. // order.HosplistName = subItem.HisProject.ProjectName
  12837. // order.Cnt = subItem.Count
  12838. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12839. //
  12840. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12841. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12842. // order.OwnpayAmt = ""
  12843. // order.SelfpayAmt = ""
  12844. // order.Spec = ""
  12845. // order.SpecUnt = ""
  12846. // order.DrordBegnDate = s_tm
  12847. // order.DrordStopDate = ""
  12848. // order.DrordDrCodg = "1"
  12849. // order.DrordDeptName = department.Name
  12850. // order.DrordDrCodg = "1"
  12851. // order.DrordDrName = doctor_info.UserName
  12852. // order.DrordDrProfttl = ""
  12853. // order.CurrDrordFlag = "1"
  12854. // orders = append(orders, &order)
  12855. //
  12856. // }
  12857. // if subItem.Type == 3 {
  12858. //
  12859. // var order models.FsiOrderDtos
  12860. // order.RxID = strconv.FormatInt(item.ID, 10)
  12861. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12862. // order.LongDrordFlag = "0"
  12863. // order.HilistType = "1"
  12864. // order.ChrgType = "1"
  12865. // order.DrordBhvr = "-"
  12866. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12867. // order.HosplistName = subItem.GoodInfo.GoodName
  12868. // order.HilistLv = "1"
  12869. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12870. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12871. // order.HosplistName = subItem.GoodInfo.GoodName
  12872. // order.Cnt = subItem.Count
  12873. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12874. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12875. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12876. // order.OwnpayAmt = ""
  12877. // order.SelfpayAmt = ""
  12878. // order.Spec = ""
  12879. // order.SpecUnt = ""
  12880. // order.DrordBegnDate = s_tm
  12881. // order.DrordStopDate = ""
  12882. // order.DrordDrCodg = "1"
  12883. // order.DrordDeptName = department.Name
  12884. // order.DrordDrCodg = "1"
  12885. // order.DrordDrName = doctor_info.UserName
  12886. // order.DrordDrProfttl = ""
  12887. // order.CurrDrordFlag = "1"
  12888. // orders = append(orders, &order)
  12889. //
  12890. // }
  12891. // }
  12892. //}
  12893. for _, item := range prescriptions {
  12894. for _, subItem := range item.HisDoctorAdviceInfo {
  12895. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12896. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12897. var order models.FsiOrderDtos
  12898. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12899. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12900. order.LongDrordFlag = "0"
  12901. order.HilistType = "101"
  12902. order.ChrgType = "01"
  12903. order.DrordBhvr = "0"
  12904. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12905. order.HosplistName = subItem.BaseDrugLib.DrugName
  12906. order.HilistLv = "1"
  12907. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12908. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12909. order.HosplistName = subItem.BaseDrugLib.DrugName
  12910. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12911. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12912. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12913. order.OwnpayAmt = ""
  12914. order.SelfpayAmt = ""
  12915. order.Spec = spec
  12916. order.SpecUnt = subItem.PrescribingNumberUnit
  12917. order.DrordBegnDate = s_tm
  12918. order.DrordStopDate = ""
  12919. order.DrordDrCodg = doctor_info.DoctorNumber
  12920. order.DrordDeptName = department.Name
  12921. order.DrordDeptCodg = department.Number
  12922. order.DrordDrName = doctor_info.UserName
  12923. order.DrordDrProfttl = "234"
  12924. order.CurrDrordFlag = "1"
  12925. orders = append(orders, &order)
  12926. }
  12927. }
  12928. for _, subItem := range item.HisPrescriptionProject {
  12929. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12930. var order models.FsiOrderDtos
  12931. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12932. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12933. order.LongDrordFlag = "0"
  12934. order.HilistType = "201"
  12935. order.ChrgType = "05"
  12936. order.DrordBhvr = "0"
  12937. order.HilistCode = subItem.HisProject.MedicalCode
  12938. order.HosplistName = subItem.HisProject.ProjectName
  12939. order.HilistLv = "1"
  12940. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12941. order.HosplistCode = subItem.HisProject.MedicalCode
  12942. order.HosplistName = subItem.HisProject.ProjectName
  12943. order.Cnt = subItem.Count
  12944. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12945. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12946. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12947. order.OwnpayAmt = ""
  12948. order.SelfpayAmt = ""
  12949. if subItem.Unit == "" {
  12950. order.Spec = "次"
  12951. order.SpecUnt = "次"
  12952. } else {
  12953. order.Spec = subItem.Unit
  12954. order.SpecUnt = subItem.Unit
  12955. }
  12956. order.DrordBegnDate = s_tm
  12957. order.DrordStopDate = ""
  12958. order.DrordDrCodg = doctor_info.DoctorNumber
  12959. order.DrordDeptName = department.Name
  12960. order.DrordDeptCodg = department.Number
  12961. order.DrordDrName = doctor_info.UserName
  12962. order.DrordDrProfttl = "234"
  12963. order.CurrDrordFlag = "1"
  12964. orders = append(orders, &order)
  12965. }
  12966. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12967. var order models.FsiOrderDtos
  12968. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12969. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12970. order.LongDrordFlag = "0"
  12971. order.HilistType = "301"
  12972. order.ChrgType = "08"
  12973. order.DrordBhvr = "0"
  12974. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12975. order.HosplistName = subItem.GoodInfo.GoodName
  12976. order.HilistLv = "1"
  12977. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12978. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12979. order.HosplistName = subItem.GoodInfo.GoodName
  12980. order.Cnt = subItem.Count
  12981. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12982. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12983. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12984. order.OwnpayAmt = ""
  12985. order.SelfpayAmt = ""
  12986. order.Spec = subItem.GoodInfo.SpecificationName
  12987. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12988. order.DrordBegnDate = s_tm
  12989. order.DrordStopDate = ""
  12990. order.DrordDrCodg = doctor_info.DoctorNumber
  12991. order.DrordDeptName = department.Name
  12992. order.DrordDeptCodg = department.Number
  12993. order.DrordDrName = doctor_info.UserName
  12994. order.DrordDrProfttl = "234"
  12995. order.CurrDrordFlag = "1"
  12996. orders = append(orders, &order)
  12997. }
  12998. }
  12999. }
  13000. //处方医嘱信息
  13001. fed.MatnStas = "0"
  13002. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  13003. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  13004. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  13005. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  13006. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  13007. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  13008. fed.SetlTotlnum = "1"
  13009. fed.Insutype = his.Insutype
  13010. fed.ReimFlag = "0"
  13011. fed.OutSetlFlag = "0"
  13012. var fopd []*models.FsiOperationDtosData
  13013. data := make(map[string]interface{})
  13014. data["fed"] = fed
  13015. data["fdd"] = fdds
  13016. data["fod"] = orders
  13017. data["pd"] = pd
  13018. data["pp"] = pp
  13019. data["fopd"] = fopd
  13020. data["trig_scen"] = trig_scen
  13021. client := &http.Client{}
  13022. bytesData, _ := json.Marshal(data)
  13023. var req *http.Request
  13024. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13025. if miConfig.MdtrtareaAdmvs == "320830" {
  13026. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  13027. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13028. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  13029. } else {
  13030. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  13031. }
  13032. resp, _ := client.Do(req)
  13033. defer resp.Body.Close()
  13034. body, ioErr := ioutil.ReadAll(resp.Body)
  13035. if ioErr != nil {
  13036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13038. return res
  13039. }
  13040. var respJSON map[string]interface{}
  13041. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13044. return res
  13045. }
  13046. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13047. result, _ := json.Marshal(respJSON)
  13048. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13049. utils.ErrorLog("解析失败:%v", err)
  13050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13051. return res
  13052. }
  13053. return res
  13054. } else {
  13055. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  13056. saveLog(output, input, "3102", "事中")
  13057. if err := json.Unmarshal([]byte(output), &res); err != nil {
  13058. utils.ErrorLog("解析失败:%v", err)
  13059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13060. return
  13061. }
  13062. return res
  13063. }
  13064. return res
  13065. }
  13066. func (c *HisApiController) Check() {
  13067. psn_no := c.GetString("psn_no")
  13068. in := c.GetString("in")
  13069. mt := c.GetString("mt")
  13070. baseParams := models.BaseParams{
  13071. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  13072. FixmedinsCode: "H15049901371",
  13073. InsuplcAdmdvs: "150404",
  13074. MdtrtareaAdmvs: "150404",
  13075. OrgName: "赤峰费森血液透析中心",
  13076. Doctor: "1111",
  13077. }
  13078. service.Gdyb2001(baseParams, psn_no, in, mt)
  13079. }
  13080. func (c *HisApiController) GetPsnNcdsInfo() {
  13081. admin_user_id, _ := c.GetInt64("admin_user_id")
  13082. patient_id, _ := c.GetInt64("patient_id")
  13083. //id, _ := c.GetInt64("id")
  13084. adminUser := c.GetAdminUserInfo()
  13085. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13086. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13087. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13088. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13089. //psn_record, _ := service.GetP(id)
  13090. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13091. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  13092. //
  13093. //if psn_record.ID == 0 {
  13094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13095. // return
  13096. //}
  13097. var res Result5301
  13098. var res10265 Result5301For10265
  13099. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13100. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13101. var api string
  13102. if miConfig.MdtrtareaAdmvs == "320830" {
  13103. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13104. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13105. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13106. 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 +
  13107. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13108. } else {
  13109. 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 +
  13110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13111. }
  13112. resp, requestErr := http.Get(api)
  13113. if requestErr != nil {
  13114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13115. return
  13116. }
  13117. body, ioErr := ioutil.ReadAll(resp.Body)
  13118. if ioErr != nil {
  13119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13121. return
  13122. }
  13123. var respJSON map[string]interface{}
  13124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13127. return
  13128. }
  13129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13130. result, _ := json.Marshal(respJSON)
  13131. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13132. utils.ErrorLog("解析失败:%v", err)
  13133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13134. return
  13135. }
  13136. res.ErrMsg = res10265.ErrMsg
  13137. res.Output = res10265.Output
  13138. res.InfRefmsgid = res10265.InfRefmsgid
  13139. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13140. res.Infcode = infocode
  13141. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13142. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13143. var api string
  13144. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13145. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13146. resp, requestErr := http.Get(api)
  13147. if requestErr != nil {
  13148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13149. return
  13150. }
  13151. body, ioErr := ioutil.ReadAll(resp.Body)
  13152. if ioErr != nil {
  13153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13155. return
  13156. }
  13157. var respJSON map[string]interface{}
  13158. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13161. return
  13162. }
  13163. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13164. if status == "0" {
  13165. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13166. c.ServeSuccessJSON(map[string]interface{}{
  13167. "failed_code": -10,
  13168. "msg": err_msg,
  13169. })
  13170. return
  13171. }
  13172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13173. result, _ := json.Marshal(respJSON)
  13174. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13175. utils.ErrorLog("解析失败:%v", err)
  13176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13177. return
  13178. }
  13179. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13180. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13181. var api string
  13182. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13183. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13184. resp, requestErr := http.Get(api)
  13185. if requestErr != nil {
  13186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13187. return
  13188. }
  13189. body, ioErr := ioutil.ReadAll(resp.Body)
  13190. if ioErr != nil {
  13191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. return
  13194. }
  13195. var respJSON map[string]interface{}
  13196. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13199. return
  13200. }
  13201. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13202. if status == "0" {
  13203. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13204. c.ServeSuccessJSON(map[string]interface{}{
  13205. "failed_code": -10,
  13206. "msg": err_msg,
  13207. })
  13208. return
  13209. }
  13210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13211. result, _ := json.Marshal(respJSON)
  13212. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13213. utils.ErrorLog("解析失败:%v", err)
  13214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13215. return
  13216. }
  13217. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13218. p, _ := service.GetHisPatientById(patient_id)
  13219. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13220. var dat map[string]interface{}
  13221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13222. fmt.Println(dat)
  13223. } else {
  13224. fmt.Println(err)
  13225. }
  13226. userJSONBytes, _ := json.Marshal(dat)
  13227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13228. utils.ErrorLog("解析失败:%v", err)
  13229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13230. return
  13231. }
  13232. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13233. p, _ := service.GetHisPatientById(patient_id)
  13234. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13235. var dat map[string]interface{}
  13236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13237. fmt.Println(dat)
  13238. } else {
  13239. fmt.Println(err)
  13240. }
  13241. userJSONBytes, _ := json.Marshal(dat)
  13242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13243. utils.ErrorLog("解析失败:%v", err)
  13244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13245. return
  13246. }
  13247. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13248. p, _ := service.GetHisPatientById(patient_id)
  13249. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13250. var dat map[string]interface{}
  13251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13252. fmt.Println(dat)
  13253. } else {
  13254. fmt.Println(err)
  13255. }
  13256. userJSONBytes, _ := json.Marshal(dat)
  13257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13258. utils.ErrorLog("解析失败:%v", err)
  13259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13260. return
  13261. }
  13262. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13263. p, _ := service.GetHisPatientById(patient_id)
  13264. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13265. var dat map[string]interface{}
  13266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13267. fmt.Println(dat)
  13268. } else {
  13269. fmt.Println(err)
  13270. }
  13271. userJSONBytes, _ := json.Marshal(dat)
  13272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13273. utils.ErrorLog("解析失败:%v", err)
  13274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13275. return
  13276. }
  13277. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13278. p, _ := service.GetHisPatientById(patient_id)
  13279. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13280. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13281. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13282. resp, requestErr := http.Get(api)
  13283. if requestErr != nil {
  13284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13285. return
  13286. }
  13287. body, ioErr := ioutil.ReadAll(resp.Body)
  13288. if ioErr != nil {
  13289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13291. return
  13292. }
  13293. var respJSON map[string]interface{}
  13294. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13297. return
  13298. }
  13299. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13300. result, _ := json.Marshal(respJSON)
  13301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13302. utils.ErrorLog("解析失败:%v", err)
  13303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13304. return
  13305. }
  13306. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13307. p, _ := service.GetHisPatientById(patient_id)
  13308. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13309. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13310. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13311. resp, requestErr := http.Get(api)
  13312. if requestErr != nil {
  13313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13314. return
  13315. }
  13316. body, ioErr := ioutil.ReadAll(resp.Body)
  13317. if ioErr != nil {
  13318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13320. return
  13321. }
  13322. var respJSON map[string]interface{}
  13323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13326. return
  13327. }
  13328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13329. result, _ := json.Marshal(respJSON)
  13330. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13331. utils.ErrorLog("解析失败:%v", err)
  13332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13333. return
  13334. }
  13335. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13336. p, _ := service.GetHisPatientById(patient_id)
  13337. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13338. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13339. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13340. resp, requestErr := http.Get(api)
  13341. if requestErr != nil {
  13342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13343. return
  13344. }
  13345. body, ioErr := ioutil.ReadAll(resp.Body)
  13346. if ioErr != nil {
  13347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13349. return
  13350. }
  13351. var respJSON map[string]interface{}
  13352. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13355. return
  13356. }
  13357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13358. result, _ := json.Marshal(respJSON)
  13359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13360. utils.ErrorLog("解析失败:%v", err)
  13361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13362. return
  13363. }
  13364. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13365. p, _ := service.GetHisPatientById(patient_id)
  13366. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13367. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13368. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13369. resp, requestErr := http.Get(api)
  13370. if requestErr != nil {
  13371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13372. return
  13373. }
  13374. body, ioErr := ioutil.ReadAll(resp.Body)
  13375. if ioErr != nil {
  13376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13378. return
  13379. }
  13380. var respJSON map[string]interface{}
  13381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13384. return
  13385. }
  13386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13387. result, _ := json.Marshal(respJSON)
  13388. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13389. utils.ErrorLog("解析失败:%v", err)
  13390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13391. return
  13392. }
  13393. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13394. p, _ := service.GetHisPatientById(patient_id)
  13395. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13396. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13397. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13398. resp, requestErr := http.Get(api)
  13399. if requestErr != nil {
  13400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13401. return
  13402. }
  13403. body, ioErr := ioutil.ReadAll(resp.Body)
  13404. if ioErr != nil {
  13405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13407. return
  13408. }
  13409. var respJSON map[string]interface{}
  13410. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13413. return
  13414. }
  13415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13416. result, _ := json.Marshal(respJSON)
  13417. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13418. utils.ErrorLog("解析失败:%v", err)
  13419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13420. return
  13421. }
  13422. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13423. p, _ := service.GetHisPatientById(patient_id)
  13424. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13425. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13426. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13427. resp, requestErr := http.Get(api)
  13428. if requestErr != nil {
  13429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13430. return
  13431. }
  13432. body, ioErr := ioutil.ReadAll(resp.Body)
  13433. if ioErr != nil {
  13434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13436. return
  13437. }
  13438. var respJSON map[string]interface{}
  13439. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13442. return
  13443. }
  13444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13445. result, _ := json.Marshal(respJSON)
  13446. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13447. utils.ErrorLog("解析失败:%v", err)
  13448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13449. return
  13450. }
  13451. } else {
  13452. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13453. var dat map[string]interface{}
  13454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13455. fmt.Println(dat)
  13456. } else {
  13457. fmt.Println(err)
  13458. }
  13459. userJSONBytes, _ := json.Marshal(dat)
  13460. if miConfig.Code == "H15049901371" {
  13461. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13462. utils.ErrorLog("解析失败:%v", err)
  13463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13464. return
  13465. }
  13466. res.InfRefmsgid = res10265.InfRefmsgid
  13467. res.Output = res10265.Output
  13468. res.ErrMsg = res10265.ErrMsg
  13469. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13470. res.Infcode = infocode
  13471. } else {
  13472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13473. utils.ErrorLog("解析失败:%v", err)
  13474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13475. return
  13476. }
  13477. }
  13478. }
  13479. if res.Infcode == 0 {
  13480. c.ServeSuccessJSON(map[string]interface{}{
  13481. "result": res.Output.Result,
  13482. })
  13483. }
  13484. }
  13485. func (c *HisApiController) CheckInsutype() {
  13486. his_patient_id, _ := c.GetInt64("his_patient_id")
  13487. admin_user_id, _ := c.GetInt64("admin_user_id")
  13488. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13489. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13490. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13491. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13492. var dat map[string]interface{}
  13493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13494. fmt.Println(dat)
  13495. } else {
  13496. fmt.Println(err)
  13497. }
  13498. userJSONBytes, _ := json.Marshal(dat)
  13499. var res Result90100
  13500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13501. utils.ErrorLog("解析失败:%v", err)
  13502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13503. return
  13504. }
  13505. if res.Infcode != 0 {
  13506. c.ServeSuccessJSON(map[string]interface{}{
  13507. "failed_code": -10,
  13508. "msg": res.ErrMsg,
  13509. })
  13510. return
  13511. } else {
  13512. fmt.Println(res)
  13513. }
  13514. }
  13515. func (c *HisApiController) CheckCardPWD() {
  13516. card_pwd := c.GetString("card_pwd")
  13517. his_patient_id, _ := c.GetInt64("his_patient_id")
  13518. admin_user_id, _ := c.GetInt64("admin_user_id")
  13519. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13520. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13521. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13522. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13523. bas := strings.Split(psn.CardInfo, "|")
  13524. basNumber := bas[2]
  13525. if psn.InsuplcAdmdvs[:4] == "4403" {
  13526. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13527. var dat map[string]interface{}
  13528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13529. fmt.Println(dat)
  13530. } else {
  13531. fmt.Println(err)
  13532. }
  13533. userJSONBytes, _ := json.Marshal(dat)
  13534. var res Result90991
  13535. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13536. utils.ErrorLog("解析失败:%v", err)
  13537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13538. return
  13539. }
  13540. if res.Infcode != 0 {
  13541. c.ServeSuccessJSON(map[string]interface{}{
  13542. "failed_code": -10,
  13543. "msg": res.ErrMsg,
  13544. })
  13545. return
  13546. } else {
  13547. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13548. var msg string
  13549. switch res.Output.Result.CardStat {
  13550. case "00":
  13551. msg = "未激活"
  13552. break
  13553. case "10":
  13554. msg = "激活"
  13555. break
  13556. case "20":
  13557. msg = "窗口挂失"
  13558. break
  13559. case "21":
  13560. msg = "电话挂失"
  13561. break
  13562. case "22":
  13563. msg = "单位网上申报挂失"
  13564. break
  13565. case "23":
  13566. msg = "保健办挂失"
  13567. break
  13568. case "24":
  13569. msg = "个人网上挂失"
  13570. break
  13571. case "25":
  13572. msg = "网上服务大厅挂失"
  13573. break
  13574. case "30":
  13575. msg = "注销"
  13576. break
  13577. case "40":
  13578. msg = "回收"
  13579. break
  13580. case "99":
  13581. msg = "制卡中(无效卡)"
  13582. break
  13583. }
  13584. c.ServeSuccessJSON(map[string]interface{}{
  13585. "failed_code": -10,
  13586. "msg": msg,
  13587. })
  13588. return
  13589. } else {
  13590. c.ServeSuccessJSON(map[string]interface{}{
  13591. "msg": "校验成功",
  13592. })
  13593. return
  13594. }
  13595. }
  13596. } else {
  13597. c.ServeSuccessJSON(map[string]interface{}{
  13598. "msg": "校验成功",
  13599. })
  13600. return
  13601. }
  13602. }
  13603. func (c *HisApiController) CheckCardPWDTwo() {
  13604. //card_pwd := c.GetString("card_pwd")
  13605. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13606. admin_user_id, _ := c.GetInt64("admin_user_id")
  13607. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13608. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13609. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13610. var dat map[string]interface{}
  13611. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13612. fmt.Println(dat)
  13613. } else {
  13614. fmt.Println(err)
  13615. }
  13616. userJSONBytes, _ := json.Marshal(dat)
  13617. var res Result90991
  13618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13619. utils.ErrorLog("解析失败:%v", err)
  13620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13621. return
  13622. }
  13623. if res.Infcode != 0 {
  13624. c.ServeSuccessJSON(map[string]interface{}{
  13625. "failed_code": -10,
  13626. "msg": res.ErrMsg,
  13627. })
  13628. return
  13629. } else {
  13630. if res.Output.Result.SscnoCheckStat == "0" {
  13631. var msg string
  13632. switch res.Output.Result.CardStat {
  13633. case "00":
  13634. msg = "未激活"
  13635. break
  13636. case "10":
  13637. msg = "激活"
  13638. break
  13639. case "20":
  13640. msg = "窗口挂失"
  13641. break
  13642. case "21":
  13643. msg = "电话挂失"
  13644. break
  13645. case "22":
  13646. msg = "单位网上申报挂失"
  13647. break
  13648. case "23":
  13649. msg = "保健办挂失"
  13650. break
  13651. case "24":
  13652. msg = "个人网上挂失"
  13653. break
  13654. case "25":
  13655. msg = "网上服务大厅挂失"
  13656. break
  13657. case "30":
  13658. msg = "注销"
  13659. break
  13660. case "40":
  13661. msg = "回收"
  13662. break
  13663. case "99":
  13664. msg = "制卡中(无效卡)"
  13665. break
  13666. }
  13667. c.ServeSuccessJSON(map[string]interface{}{
  13668. "failed_code": -10,
  13669. "msg": msg,
  13670. })
  13671. return
  13672. } else {
  13673. c.ServeSuccessJSON(map[string]interface{}{
  13674. "msg": "校验成功",
  13675. })
  13676. return
  13677. }
  13678. }
  13679. }
  13680. type ELeCertData struct {
  13681. Data struct {
  13682. Extra string `json:"extra"`
  13683. IDNo string `json:"idNo"`
  13684. IDType string `json:"idType"`
  13685. EcToken string `json:"ecToken"`
  13686. InsuOrg string `json:"insuOrg"`
  13687. UserName string `json:"userName"`
  13688. EcIndexNo string `json:"ecIndexNo"`
  13689. Gender string `json:"gender"`
  13690. Birthday string `json:"birthday"`
  13691. Nationality string `json:"nationality"`
  13692. Email string `json:"email"`
  13693. } `json:"OutData"`
  13694. }
  13695. func (c *HisApiController) ReadCard() {
  13696. id_card_type, _ := c.GetInt64("id_card_type")
  13697. admin_user_id, _ := c.GetInt64("admin_user_id")
  13698. certificates, _ := c.GetInt64("certificates")
  13699. //
  13700. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13701. id_card_no := c.GetString("id_card_no")
  13702. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13703. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13704. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13705. switch id_card_type {
  13706. case 1:
  13707. if miConfig.MdtrtareaAdmvs == "421300" {
  13708. var res ResultTwo
  13709. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13710. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13711. "&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)
  13712. resp, requestErr := http.Get(api)
  13713. if requestErr != nil {
  13714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13715. return
  13716. }
  13717. body, ioErr := ioutil.ReadAll(resp.Body)
  13718. if ioErr != nil {
  13719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13721. return
  13722. }
  13723. var respJSON map[string]interface{}
  13724. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13727. return
  13728. }
  13729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13730. result, _ := json.Marshal(respJSON)
  13731. fmt.Println("log")
  13732. fmt.Println(string(result))
  13733. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13734. utils.ErrorLog("解析失败:%v", err)
  13735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13736. return
  13737. }
  13738. if res.Infcode == 0 {
  13739. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13740. if err == gorm.ErrRecordNotFound {
  13741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13742. return
  13743. } else if err != nil {
  13744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13745. return
  13746. } else {
  13747. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13748. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13749. infoStr := string(Iinfos)
  13750. idetinfoStr := string(Idetinfos)
  13751. var rf []*ResultFive
  13752. json.Unmarshal([]byte(infoStr), &rf)
  13753. var insutypes []*ResultFive
  13754. var insutype string
  13755. var is390 int = 0
  13756. var is310 int = 0
  13757. for _, item := range rf {
  13758. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13759. insutypes = append(insutypes, item)
  13760. }
  13761. }
  13762. if len(insutypes) == 1 {
  13763. insutype = insutypes[0].Insutype
  13764. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13765. } else {
  13766. for _, i := range insutypes {
  13767. if i.Insutype == "390" {
  13768. is390 = 1
  13769. }
  13770. if i.Insutype == "310" {
  13771. is310 = 1
  13772. }
  13773. }
  13774. }
  13775. if is390 == 1 {
  13776. insutype = "390"
  13777. }
  13778. if is310 == 1 {
  13779. insutype = "310"
  13780. }
  13781. if len(insutypes) == 0 {
  13782. insutype = "390"
  13783. }
  13784. var insuplc_admdvs string
  13785. for _, item := range rf {
  13786. if item.Insutype == insutype {
  13787. insuplc_admdvs = item.InsuplcAdmdvs
  13788. }
  13789. }
  13790. if strings.Contains(insuplc_admdvs, "4213") {
  13791. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13792. }
  13793. psn := &models.HisPsn{
  13794. PsnNo: res.Output.Baseinfo.PsnNo,
  13795. PatientId: patient.ID,
  13796. Certno: res.Output.Baseinfo.Certno,
  13797. Gend: res.Output.Baseinfo.Gend,
  13798. Naty: res.Output.Baseinfo.Naty,
  13799. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13800. PsnName: res.Output.Baseinfo.PsnName,
  13801. Idetinfo: idetinfoStr,
  13802. Insuinfo: infoStr,
  13803. InsuplcAdmdvs: insuplc_admdvs,
  13804. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13805. }
  13806. service.CreateHisPsn(psn)
  13807. c.ServeSuccessJSON(map[string]interface{}{
  13808. "patient": patient,
  13809. "number": res.Output.Baseinfo.Certno,
  13810. })
  13811. }
  13812. } else {
  13813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13814. return
  13815. }
  13816. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13817. var res ResultTwo
  13818. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13819. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13820. "&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)
  13821. resp, requestErr := http.Get(api)
  13822. if requestErr != nil {
  13823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13824. return
  13825. }
  13826. body, ioErr := ioutil.ReadAll(resp.Body)
  13827. if ioErr != nil {
  13828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13830. return
  13831. }
  13832. var respJSON map[string]interface{}
  13833. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13836. return
  13837. }
  13838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13839. result, _ := json.Marshal(respJSON)
  13840. fmt.Println("log")
  13841. fmt.Println(string(result))
  13842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13843. utils.ErrorLog("解析失败:%v", err)
  13844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13845. return
  13846. }
  13847. if res.Infcode == 0 {
  13848. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13849. if err == gorm.ErrRecordNotFound {
  13850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13851. return
  13852. } else if err != nil {
  13853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13854. return
  13855. } else {
  13856. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13857. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13858. infoStr := string(Iinfos)
  13859. idetinfoStr := string(Idetinfos)
  13860. psn := &models.HisPsn{
  13861. PsnNo: res.Output.Baseinfo.PsnNo,
  13862. PatientId: patient.ID,
  13863. Certno: res.Output.Baseinfo.Certno,
  13864. Gend: res.Output.Baseinfo.Gend,
  13865. Naty: res.Output.Baseinfo.Naty,
  13866. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13867. PsnName: res.Output.Baseinfo.PsnName,
  13868. Idetinfo: idetinfoStr,
  13869. Insuinfo: infoStr,
  13870. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13871. }
  13872. service.CreateHisPsn(psn)
  13873. var rf []*ResultFive
  13874. json.Unmarshal([]byte(infoStr), &rf)
  13875. var insutypes []*ResultFive
  13876. var insutype string
  13877. var is390 int = 0
  13878. var is310 int = 0
  13879. for _, item := range rf {
  13880. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13881. insutypes = append(insutypes, item)
  13882. }
  13883. }
  13884. if len(insutypes) == 1 {
  13885. insutype = insutypes[0].Insutype
  13886. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13887. } else {
  13888. for _, i := range insutypes {
  13889. if i.Insutype == "390" {
  13890. is390 = 1
  13891. }
  13892. if i.Insutype == "310" {
  13893. is310 = 1
  13894. }
  13895. }
  13896. }
  13897. if is390 == 1 {
  13898. insutype = "390"
  13899. }
  13900. if is310 == 1 {
  13901. insutype = "310"
  13902. }
  13903. if len(insutypes) == 0 {
  13904. insutype = "310"
  13905. }
  13906. c.ServeSuccessJSON(map[string]interface{}{
  13907. "patient": patient,
  13908. "number": res.Output.Baseinfo.Certno,
  13909. "insutype": insutype,
  13910. })
  13911. }
  13912. } else {
  13913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13914. return
  13915. }
  13916. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13917. var res ResultTwo
  13918. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13919. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13920. "&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)
  13921. resp, requestErr := http.Get(api)
  13922. if requestErr != nil {
  13923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13924. return
  13925. }
  13926. body, ioErr := ioutil.ReadAll(resp.Body)
  13927. if ioErr != nil {
  13928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13930. return
  13931. }
  13932. var respJSON map[string]interface{}
  13933. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13936. return
  13937. }
  13938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13939. result, _ := json.Marshal(respJSON)
  13940. fmt.Println("log")
  13941. fmt.Println(string(result))
  13942. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13943. utils.ErrorLog("解析失败:%v", err)
  13944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13945. return
  13946. }
  13947. if res.Infcode == 0 {
  13948. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13949. if err == gorm.ErrRecordNotFound {
  13950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13951. return
  13952. } else if err != nil {
  13953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13954. return
  13955. } else {
  13956. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13957. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13958. infoStr := string(Iinfos)
  13959. idetinfoStr := string(Idetinfos)
  13960. var rf []*ResultFive
  13961. json.Unmarshal([]byte(infoStr), &rf)
  13962. var insutypes []*ResultFive
  13963. var insutype string
  13964. var is390 int = 0
  13965. var is310 int = 0
  13966. for _, item := range rf {
  13967. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13968. insutypes = append(insutypes, item)
  13969. }
  13970. }
  13971. if len(insutypes) == 1 {
  13972. insutype = insutypes[0].Insutype
  13973. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13974. } else {
  13975. for _, i := range insutypes {
  13976. if i.Insutype == "390" {
  13977. is390 = 1
  13978. }
  13979. if i.Insutype == "310" {
  13980. is310 = 1
  13981. }
  13982. }
  13983. }
  13984. if is390 == 1 {
  13985. insutype = "390"
  13986. }
  13987. if is310 == 1 {
  13988. insutype = "310"
  13989. }
  13990. if len(insutypes) == 0 {
  13991. insutype = "390"
  13992. }
  13993. var insuplc_admdvs string
  13994. for _, item := range rf {
  13995. if item.Insutype == insutype {
  13996. insuplc_admdvs = item.InsuplcAdmdvs
  13997. }
  13998. }
  13999. psn := &models.HisPsn{
  14000. PsnNo: res.Output.Baseinfo.PsnNo,
  14001. PatientId: patient.ID,
  14002. Certno: res.Output.Baseinfo.Certno,
  14003. Gend: res.Output.Baseinfo.Gend,
  14004. Naty: res.Output.Baseinfo.Naty,
  14005. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14006. PsnName: res.Output.Baseinfo.PsnName,
  14007. Idetinfo: idetinfoStr,
  14008. Insuinfo: infoStr,
  14009. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14010. InsuplcAdmdvs: insuplc_admdvs,
  14011. }
  14012. service.CreateHisPsn(psn)
  14013. for _, item := range rf {
  14014. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14015. insutypes = append(insutypes, item)
  14016. }
  14017. }
  14018. if len(insutypes) == 1 {
  14019. insutype = insutypes[0].Insutype
  14020. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14021. } else {
  14022. for _, i := range insutypes {
  14023. if i.Insutype == "390" {
  14024. is390 = 1
  14025. }
  14026. if i.Insutype == "310" {
  14027. is310 = 1
  14028. }
  14029. }
  14030. }
  14031. if is390 == 1 {
  14032. insutype = "390"
  14033. }
  14034. if is310 == 1 {
  14035. insutype = "310"
  14036. }
  14037. if len(insutypes) == 0 {
  14038. insutype = "310"
  14039. }
  14040. c.ServeSuccessJSON(map[string]interface{}{
  14041. "patient": patient,
  14042. "number": res.Output.Baseinfo.Certno,
  14043. "insutype": insutype,
  14044. })
  14045. }
  14046. } else {
  14047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14048. return
  14049. }
  14050. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14051. var res ResultTwo
  14052. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  14053. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14054. "&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)
  14055. resp, requestErr := http.Get(api)
  14056. if requestErr != nil {
  14057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14058. return
  14059. }
  14060. body, ioErr := ioutil.ReadAll(resp.Body)
  14061. if ioErr != nil {
  14062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14064. return
  14065. }
  14066. var respJSON map[string]interface{}
  14067. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14070. return
  14071. }
  14072. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14073. result, _ := json.Marshal(respJSON)
  14074. fmt.Println("log")
  14075. fmt.Println(string(result))
  14076. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14077. utils.ErrorLog("解析失败:%v", err)
  14078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14079. return
  14080. }
  14081. if res.Infcode == 0 {
  14082. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14083. if err == gorm.ErrRecordNotFound {
  14084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14085. return
  14086. } else if err != nil {
  14087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14088. return
  14089. } else {
  14090. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14091. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14092. infoStr := string(Iinfos)
  14093. idetinfoStr := string(Idetinfos)
  14094. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14095. psn := &models.HisPsn{
  14096. PsnNo: res.Output.Baseinfo.PsnNo,
  14097. PatientId: patient.ID,
  14098. Certno: res.Output.Baseinfo.Certno,
  14099. Brdy: b,
  14100. Age: float64(age),
  14101. Gend: res.Output.Baseinfo.Gend,
  14102. Naty: res.Output.Baseinfo.Naty,
  14103. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14104. PsnName: res.Output.Baseinfo.PsnName,
  14105. Idetinfo: idetinfoStr,
  14106. Insuinfo: infoStr,
  14107. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14108. }
  14109. service.CreateHisPsn(psn)
  14110. var rf []*ResultFive
  14111. json.Unmarshal([]byte(infoStr), &rf)
  14112. var insutypes []*ResultFive
  14113. var insutype string
  14114. var is390 int = 0
  14115. var is310 int = 0
  14116. for _, item := range rf {
  14117. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14118. insutypes = append(insutypes, item)
  14119. }
  14120. }
  14121. if len(insutypes) == 1 {
  14122. insutype = insutypes[0].Insutype
  14123. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14124. } else {
  14125. for _, i := range insutypes {
  14126. if i.Insutype == "390" {
  14127. is390 = 1
  14128. }
  14129. if i.Insutype == "310" {
  14130. is310 = 1
  14131. }
  14132. }
  14133. }
  14134. if is390 == 1 {
  14135. insutype = "390"
  14136. }
  14137. if is310 == 1 {
  14138. insutype = "310"
  14139. }
  14140. if len(insutypes) == 0 {
  14141. insutype = "310"
  14142. }
  14143. c.ServeSuccessJSON(map[string]interface{}{
  14144. "patient": patient,
  14145. "number": res.Output.Baseinfo.Certno,
  14146. "insutype": insutype,
  14147. })
  14148. }
  14149. } else {
  14150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14151. return
  14152. }
  14153. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  14154. var api string
  14155. if miConfig.MdtrtareaAdmvs == "320830" {
  14156. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14157. "&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
  14158. fmt.Println(api)
  14159. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14160. 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 +
  14161. "&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
  14162. fmt.Println(api)
  14163. } else {
  14164. 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 +
  14165. "&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)
  14166. }
  14167. resp, requestErr := http.Get(api)
  14168. if requestErr != nil {
  14169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14170. return
  14171. }
  14172. body, ioErr := ioutil.ReadAll(resp.Body)
  14173. if ioErr != nil {
  14174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14176. return
  14177. }
  14178. var respJSON map[string]interface{}
  14179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14182. return
  14183. }
  14184. var status string
  14185. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14186. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14187. //console.log()
  14188. fmt.Println("type===")
  14189. fmt.Println(card_type)
  14190. var token string
  14191. var res ResultTwo //1101结果
  14192. var res10265 ResultTwo10265 //1101结果
  14193. var card_info string //卡信息
  14194. var busi_card_info string
  14195. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14196. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14197. if status == "0" { //读卡成功
  14198. if card_type == "1" {
  14199. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14200. result, _ := json.Marshal(respJSON)
  14201. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14202. utils.ErrorLog("解析失败:%v", err)
  14203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14204. return
  14205. }
  14206. res.ErrMsg = res10265.ErrMsg
  14207. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14208. res.Infcode = infocode
  14209. res.Output = res10265.Output
  14210. res.InfRefmsgid = res10265.InfRefmsgid
  14211. } else {
  14212. //var card_info string //卡信息
  14213. //var busi_card_info string
  14214. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14215. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14216. //fmt.Println(card_info)
  14217. //fmt.Println(busi_card_info)
  14218. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14219. result, _ := json.Marshal(respJSON)
  14220. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14221. utils.ErrorLog("解析失败:%v", err)
  14222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14223. return
  14224. }
  14225. res.ErrMsg = res10265.ErrMsg
  14226. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14227. res.Infcode = infocode
  14228. res.Output = res10265.Output
  14229. res.InfRefmsgid = res10265.InfRefmsgid
  14230. }
  14231. if res.Infcode == 0 {
  14232. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14233. if err == gorm.ErrRecordNotFound {
  14234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14235. return
  14236. } else if err != nil {
  14237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14238. return
  14239. } else {
  14240. if card_type == "1" {
  14241. bas := strings.Split(card_info, "|")
  14242. basNumber := bas[2]
  14243. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14244. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14245. infoStr := string(Iinfos)
  14246. idetinfoStr := string(Idetinfos)
  14247. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14248. psn := &models.HisPsn{
  14249. PsnNo: res.Output.Baseinfo.PsnNo,
  14250. PatientId: patient.ID,
  14251. Certno: res.Output.Baseinfo.Certno,
  14252. Brdy: b,
  14253. Age: float64(age),
  14254. Gend: res.Output.Baseinfo.Gend,
  14255. Naty: res.Output.Baseinfo.Naty,
  14256. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14257. PsnName: res.Output.Baseinfo.PsnName,
  14258. Idetinfo: idetinfoStr,
  14259. Insuinfo: infoStr,
  14260. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14261. CardInfo: card_info,
  14262. VerifyNumber: busi_card_info,
  14263. }
  14264. service.CreateHisPsn(psn)
  14265. var rf []*ResultFive
  14266. json.Unmarshal([]byte(infoStr), &rf)
  14267. var insutypes []*ResultFive
  14268. var insutype string
  14269. var is390 int = 0
  14270. var is310 int = 0
  14271. for _, item := range rf {
  14272. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14273. insutypes = append(insutypes, item)
  14274. }
  14275. }
  14276. if len(insutypes) == 1 {
  14277. insutype = insutypes[0].Insutype
  14278. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14279. } else {
  14280. for _, i := range insutypes {
  14281. if i.Insutype == "390" {
  14282. is390 = 1
  14283. }
  14284. if i.Insutype == "310" {
  14285. is310 = 1
  14286. }
  14287. }
  14288. }
  14289. if is390 == 1 {
  14290. insutype = "390"
  14291. }
  14292. if is310 == 1 {
  14293. insutype = "310"
  14294. }
  14295. if len(insutypes) == 0 {
  14296. insutype = "310"
  14297. }
  14298. c.ServeSuccessJSON(map[string]interface{}{
  14299. "patient": patient,
  14300. "number": basNumber,
  14301. "insutype": insutype,
  14302. })
  14303. } else {
  14304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14306. infoStr := string(Iinfos)
  14307. idetinfoStr := string(Idetinfos)
  14308. psn := &models.HisPsn{
  14309. PsnNo: res.Output.Baseinfo.PsnNo,
  14310. PatientId: patient.ID,
  14311. Certno: res.Output.Baseinfo.Certno,
  14312. Gend: res.Output.Baseinfo.Gend,
  14313. Naty: res.Output.Baseinfo.Naty,
  14314. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14315. PsnName: res.Output.Baseinfo.PsnName,
  14316. Idetinfo: idetinfoStr,
  14317. Insuinfo: infoStr,
  14318. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14319. CardInfo: card_info,
  14320. VerifyNumber: token,
  14321. }
  14322. service.CreateHisPsn(psn)
  14323. c.ServeSuccessJSON(map[string]interface{}{
  14324. "patient": patient,
  14325. "number": token,
  14326. })
  14327. }
  14328. }
  14329. } else {
  14330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14331. return
  14332. }
  14333. } else { //读卡失败
  14334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14335. return
  14336. }
  14337. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14338. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14339. cardnum = DeleteExtraSpaceTwo(cardnum)
  14340. cardCode = DeleteExtraSpaceTwo(cardCode)
  14341. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14342. name = DeleteExtraSpaceTwo(name)
  14343. errmsg = DeleteExtraSpaceTwo(errmsg)
  14344. cardnum = Remove0000(cardnum)
  14345. cardCode = Remove0000(cardCode)
  14346. id_card_no = Remove0000(id_card_no)
  14347. name = Remove0000(name)
  14348. errmsg = Remove0000(errmsg)
  14349. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14350. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14351. //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)
  14352. //fmt.Println(result2)
  14353. //fmt.Println(requestLog2)
  14354. //fmt.Println(errMsgLog2)
  14355. 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)
  14356. saveLog(result, requestLog, "1101", "获取人员信息")
  14357. fmt.Println(errMsgLog)
  14358. if len(errMsgLog) > 0 {
  14359. } else {
  14360. var dat map[string]interface{}
  14361. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14362. fmt.Println(dat)
  14363. } else {
  14364. fmt.Println(err)
  14365. }
  14366. userJSONBytes, _ := json.Marshal(dat)
  14367. var res ResultTwo
  14368. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14369. utils.ErrorLog("解析失败:%v", err)
  14370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14371. return
  14372. }
  14373. res.ErrMsg = errMsgLog
  14374. if res.Infcode == 0 {
  14375. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14376. if err == gorm.ErrRecordNotFound {
  14377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14378. return
  14379. } else if err != nil {
  14380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14381. return
  14382. } else {
  14383. fmt.Println(res)
  14384. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14385. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14386. infoStr := string(Iinfos)
  14387. idetinfoStr := string(Idetinfos)
  14388. var rf []*ResultFive
  14389. json.Unmarshal([]byte(infoStr), &rf)
  14390. var insutypes []*ResultFive
  14391. var insutype string
  14392. var is390 int = 0
  14393. var is310 int = 0
  14394. for _, item := range rf {
  14395. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14396. insutypes = append(insutypes, item)
  14397. }
  14398. }
  14399. if len(insutypes) == 1 {
  14400. insutype = insutypes[0].Insutype
  14401. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14402. } else {
  14403. for _, i := range insutypes {
  14404. if i.Insutype == "390" {
  14405. is390 = 1
  14406. }
  14407. if i.Insutype == "310" {
  14408. is310 = 1
  14409. }
  14410. }
  14411. }
  14412. if is390 == 1 {
  14413. insutype = "390"
  14414. }
  14415. if is310 == 1 {
  14416. insutype = "310"
  14417. }
  14418. if len(insutypes) == 0 {
  14419. insutype = "390"
  14420. }
  14421. var insuplc_admdvs string
  14422. for _, item := range rf {
  14423. if item.Insutype == insutype {
  14424. insuplc_admdvs = item.InsuplcAdmdvs
  14425. }
  14426. }
  14427. psn := &models.HisPsn{
  14428. PsnNo: res.Output.Baseinfo.PsnNo,
  14429. PatientId: patient.ID,
  14430. Certno: res.Output.Baseinfo.Certno,
  14431. Gend: res.Output.Baseinfo.Gend,
  14432. Naty: res.Output.Baseinfo.Naty,
  14433. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14434. PsnName: res.Output.Baseinfo.PsnName,
  14435. Idetinfo: idetinfoStr,
  14436. Insuinfo: infoStr,
  14437. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14438. CardInfo: basStr,
  14439. VerifyNumber: "",
  14440. InsuplcAdmdvs: insuplc_admdvs,
  14441. }
  14442. service.CreateHisPsn(psn)
  14443. c.ServeSuccessJSON(map[string]interface{}{
  14444. "patient": patient,
  14445. "number": cardnum,
  14446. "insutype": insutype,
  14447. })
  14448. }
  14449. } else {
  14450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14451. return
  14452. }
  14453. }
  14454. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14455. fmt.Println(initFlag)
  14456. fmt.Println("initFlag")
  14457. if initFlag == 0 {
  14458. c.TestGetJiangXiBasBaseInit()
  14459. }
  14460. basStr := c.GetBasBaseInfo()
  14461. if len(basStr) == 0 {
  14462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14463. return
  14464. }
  14465. fmt.Println(basStr)
  14466. bas := strings.Split(basStr, "|")
  14467. basNumber := bas[1]
  14468. fmt.Println(basNumber)
  14469. card := bas[2]
  14470. card_sn := bas[3]
  14471. fmt.Println(card_sn)
  14472. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14473. result, _ := service.Jxyb11012(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, card)
  14474. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14475. var dat map[string]interface{}
  14476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14477. fmt.Println(dat)
  14478. } else {
  14479. fmt.Println(err)
  14480. }
  14481. userJSONBytes, _ := json.Marshal(dat)
  14482. var res ResultTwo
  14483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14484. utils.ErrorLog("解析失败:%v", err)
  14485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14486. return
  14487. }
  14488. if res.Infcode == 0 {
  14489. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14490. if err == gorm.ErrRecordNotFound {
  14491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14492. return
  14493. } else if err != nil {
  14494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14495. return
  14496. } else {
  14497. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14498. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14499. infoStr := string(Iinfos)
  14500. idetinfoStr := string(Idetinfos)
  14501. var rf []*ResultFive
  14502. json.Unmarshal([]byte(infoStr), &rf)
  14503. var insutypes []*ResultFive
  14504. var insutype string
  14505. var is390 int = 0
  14506. var is310 int = 0
  14507. var insuplc_admdvs string
  14508. for _, item := range rf {
  14509. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14510. insutypes = append(insutypes, item)
  14511. }
  14512. }
  14513. if len(insutypes) == 1 {
  14514. insutype = insutypes[0].Insutype
  14515. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14516. } else {
  14517. for _, i := range insutypes {
  14518. if i.Insutype == "390" {
  14519. is390 = 1
  14520. }
  14521. if i.Insutype == "310" {
  14522. is310 = 1
  14523. }
  14524. }
  14525. }
  14526. if is390 == 1 {
  14527. insutype = "390"
  14528. }
  14529. if is310 == 1 {
  14530. insutype = "310"
  14531. }
  14532. if len(insutypes) == 0 {
  14533. insutype = "310"
  14534. }
  14535. for _, item := range rf {
  14536. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14537. insuplc_admdvs = item.InsuplcAdmdvs
  14538. }
  14539. }
  14540. psn := &models.HisPsn{
  14541. PsnNo: res.Output.Baseinfo.PsnNo,
  14542. PatientId: patient.ID,
  14543. Certno: res.Output.Baseinfo.Certno,
  14544. Gend: res.Output.Baseinfo.Gend,
  14545. Naty: res.Output.Baseinfo.Naty,
  14546. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14547. PsnName: res.Output.Baseinfo.PsnName,
  14548. Idetinfo: idetinfoStr,
  14549. Insuinfo: infoStr,
  14550. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14551. CardInfo: basStr,
  14552. InsuplcAdmdvs: insuplc_admdvs,
  14553. VerifyNumber: "",
  14554. }
  14555. service.CreateHisPsn(psn)
  14556. c.ServeSuccessJSON(map[string]interface{}{
  14557. "patient": patient,
  14558. "number": basNumber,
  14559. "insutype": insutype,
  14560. })
  14561. }
  14562. } else {
  14563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14564. return
  14565. }
  14566. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14567. basStr := c.GetBasBaseInfo22222()
  14568. fmt.Println(basStr)
  14569. if len(basStr) == 0 {
  14570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14571. return
  14572. }
  14573. fmt.Println(basStr)
  14574. bas := strings.Split(basStr, "|")
  14575. basNumber := bas[2] //卡号
  14576. card_sn := bas[3] //
  14577. id_card_No := bas[1] //卡号
  14578. fmt.Println(basNumber)
  14579. fmt.Println(card_sn)
  14580. fmt.Println(id_card_No)
  14581. var patient service.Patients
  14582. if len(id_card_No) == 0 {
  14583. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14584. } else {
  14585. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14586. }
  14587. 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)
  14588. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14589. var dat map[string]interface{}
  14590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14591. fmt.Println(dat)
  14592. } else {
  14593. fmt.Println(err)
  14594. }
  14595. userJSONBytes, _ := json.Marshal(dat)
  14596. var res ResultTwo
  14597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14598. utils.ErrorLog("解析失败:%v", err)
  14599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14600. return
  14601. }
  14602. if res.Infcode == 0 {
  14603. var pateint2 service.Patients
  14604. var err error
  14605. if len(id_card_No) == 0 {
  14606. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14607. } else {
  14608. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14609. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14610. }
  14611. if err == gorm.ErrRecordNotFound {
  14612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14613. return
  14614. } else if err != nil {
  14615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14616. return
  14617. } else {
  14618. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14619. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14620. infoStr := string(Iinfos)
  14621. idetinfoStr := string(Idetinfos)
  14622. var rf []*ResultFive
  14623. json.Unmarshal([]byte(infoStr), &rf)
  14624. var insutypes []*ResultFive
  14625. var insutype string
  14626. var is390 int = 0
  14627. var is310 int = 0
  14628. var insuplc_admdvs string
  14629. for _, item := range rf {
  14630. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14631. insutypes = append(insutypes, item)
  14632. }
  14633. }
  14634. if len(insutypes) == 1 {
  14635. insutype = insutypes[0].Insutype
  14636. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14637. } else {
  14638. for _, i := range insutypes {
  14639. if i.Insutype == "390" {
  14640. is390 = 1
  14641. }
  14642. if i.Insutype == "310" {
  14643. is310 = 1
  14644. }
  14645. }
  14646. }
  14647. if is390 == 1 {
  14648. insutype = "390"
  14649. }
  14650. if is310 == 1 {
  14651. insutype = "310"
  14652. }
  14653. if len(insutypes) == 0 {
  14654. insutype = "310"
  14655. }
  14656. for _, item := range rf {
  14657. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14658. insuplc_admdvs = item.InsuplcAdmdvs
  14659. }
  14660. }
  14661. psn := &models.HisPsn{
  14662. PsnNo: res.Output.Baseinfo.PsnNo,
  14663. PatientId: pateint2.ID,
  14664. Certno: res.Output.Baseinfo.Certno,
  14665. Gend: res.Output.Baseinfo.Gend,
  14666. Naty: res.Output.Baseinfo.Naty,
  14667. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14668. PsnName: res.Output.Baseinfo.PsnName,
  14669. Idetinfo: idetinfoStr,
  14670. Insuinfo: infoStr,
  14671. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14672. CardInfo: basStr,
  14673. InsuplcAdmdvs: insuplc_admdvs,
  14674. VerifyNumber: "",
  14675. }
  14676. service.CreateHisPsn(psn)
  14677. c.ServeSuccessJSON(map[string]interface{}{
  14678. "patient": patient,
  14679. "number": basNumber,
  14680. "insutype": insutype,
  14681. })
  14682. }
  14683. } else {
  14684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14685. return
  14686. }
  14687. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14688. fmt.Println(initFlag)
  14689. fmt.Println("initFlag")
  14690. if initFlag == 0 {
  14691. c.TestGetJiangXiBasBaseInittwo()
  14692. }
  14693. basStr := c.GetBasBaseInfo()
  14694. if len(basStr) == 0 {
  14695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14696. return
  14697. }
  14698. fmt.Println(basStr)
  14699. bas := strings.Split(basStr, "|")
  14700. basNumber := bas[1]
  14701. fmt.Println(basNumber)
  14702. card_sn := bas[3]
  14703. fmt.Println(card_sn)
  14704. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14705. 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)
  14706. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14707. var dat map[string]interface{}
  14708. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14709. fmt.Println(dat)
  14710. } else {
  14711. fmt.Println(err)
  14712. }
  14713. userJSONBytes, _ := json.Marshal(dat)
  14714. var res ResultTwo
  14715. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14716. utils.ErrorLog("解析失败:%v", err)
  14717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14718. return
  14719. }
  14720. if res.Infcode == 0 {
  14721. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14722. if err == gorm.ErrRecordNotFound {
  14723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14724. return
  14725. } else if err != nil {
  14726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14727. return
  14728. } else {
  14729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14730. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14731. infoStr := string(Iinfos)
  14732. idetinfoStr := string(Idetinfos)
  14733. var rf []*ResultFive
  14734. json.Unmarshal([]byte(infoStr), &rf)
  14735. var insutypes []*ResultFive
  14736. var insutype string
  14737. var is390 int = 0
  14738. var is310 int = 0
  14739. var insuplc_admdvs string
  14740. for _, item := range rf {
  14741. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14742. insutypes = append(insutypes, item)
  14743. }
  14744. }
  14745. if len(insutypes) == 1 {
  14746. insutype = insutypes[0].Insutype
  14747. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14748. } else {
  14749. for _, i := range insutypes {
  14750. if i.Insutype == "390" {
  14751. is390 = 1
  14752. }
  14753. if i.Insutype == "310" {
  14754. is310 = 1
  14755. }
  14756. }
  14757. }
  14758. if is390 == 1 {
  14759. insutype = "390"
  14760. }
  14761. if is310 == 1 {
  14762. insutype = "310"
  14763. }
  14764. if len(insutypes) == 0 {
  14765. insutype = "310"
  14766. }
  14767. for _, item := range rf {
  14768. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14769. insuplc_admdvs = item.InsuplcAdmdvs
  14770. }
  14771. }
  14772. psn := &models.HisPsn{
  14773. PsnNo: res.Output.Baseinfo.PsnNo,
  14774. PatientId: patient.ID,
  14775. Certno: res.Output.Baseinfo.Certno,
  14776. Gend: res.Output.Baseinfo.Gend,
  14777. Naty: res.Output.Baseinfo.Naty,
  14778. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14779. PsnName: res.Output.Baseinfo.PsnName,
  14780. Idetinfo: idetinfoStr,
  14781. Insuinfo: infoStr,
  14782. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14783. CardInfo: basStr,
  14784. InsuplcAdmdvs: insuplc_admdvs,
  14785. VerifyNumber: "",
  14786. }
  14787. service.CreateHisPsn(psn)
  14788. c.ServeSuccessJSON(map[string]interface{}{
  14789. "patient": patient,
  14790. "number": basNumber,
  14791. "insutype": insutype,
  14792. })
  14793. }
  14794. } else {
  14795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14796. return
  14797. }
  14798. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14799. fmt.Println(initFlag)
  14800. fmt.Println("initFlag")
  14801. if initFlag == 0 {
  14802. c.TestGetHnBasBaseInit()
  14803. }
  14804. basStr := c.GetBasBaseInfo()
  14805. if len(basStr) == 0 {
  14806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14807. return
  14808. }
  14809. fmt.Println(basStr)
  14810. bas := strings.Split(basStr, "|")
  14811. basNumber := bas[1]
  14812. fmt.Println(basNumber)
  14813. card_sn := bas[3]
  14814. card_no := bas[2]
  14815. fmt.Println(card_sn)
  14816. name := bas[4]
  14817. name = ConvertToString(name, "gbk", "utf-8")
  14818. 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)
  14819. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14820. var dat map[string]interface{}
  14821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14822. fmt.Println(dat)
  14823. } else {
  14824. fmt.Println(err)
  14825. }
  14826. userJSONBytes, _ := json.Marshal(dat)
  14827. var res ResultTwo
  14828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14829. utils.ErrorLog("解析失败:%v", err)
  14830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14831. return
  14832. }
  14833. if res.Infcode == 0 {
  14834. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14835. if err == gorm.ErrRecordNotFound {
  14836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14837. return
  14838. } else if err != nil {
  14839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14840. return
  14841. } else {
  14842. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14843. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14844. infoStr := string(Iinfos)
  14845. idetinfoStr := string(Idetinfos)
  14846. psn := &models.HisPsn{
  14847. PsnNo: res.Output.Baseinfo.PsnNo,
  14848. PatientId: patient.ID,
  14849. Certno: res.Output.Baseinfo.Certno,
  14850. Gend: res.Output.Baseinfo.Gend,
  14851. Naty: res.Output.Baseinfo.Naty,
  14852. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14853. PsnName: res.Output.Baseinfo.PsnName,
  14854. Idetinfo: idetinfoStr,
  14855. Insuinfo: infoStr,
  14856. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14857. CardInfo: basStr,
  14858. VerifyNumber: "",
  14859. }
  14860. service.CreateHisPsn(psn)
  14861. var rf []*ResultFive
  14862. json.Unmarshal([]byte(infoStr), &rf)
  14863. var insutypes []*ResultFive
  14864. var insutype string
  14865. var is390 int = 0
  14866. var is310 int = 0
  14867. for _, item := range rf {
  14868. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14869. insutypes = append(insutypes, item)
  14870. }
  14871. }
  14872. if len(insutypes) == 1 {
  14873. insutype = insutypes[0].Insutype
  14874. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14875. } else {
  14876. for _, i := range insutypes {
  14877. if i.Insutype == "390" {
  14878. is390 = 1
  14879. }
  14880. if i.Insutype == "310" {
  14881. is310 = 1
  14882. }
  14883. }
  14884. }
  14885. if is390 == 1 {
  14886. insutype = "390"
  14887. }
  14888. if is310 == 1 {
  14889. insutype = "310"
  14890. }
  14891. if len(insutypes) == 0 {
  14892. insutype = "310"
  14893. }
  14894. c.ServeSuccessJSON(map[string]interface{}{
  14895. "patient": patient,
  14896. "number": basNumber,
  14897. "insutype": insutype,
  14898. })
  14899. }
  14900. } else {
  14901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14902. return
  14903. }
  14904. } else if miConfig.MdtrtareaAdmvs == "150404" {
  14905. var api string
  14906. 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 +
  14907. "&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
  14908. fmt.Println(api)
  14909. resp, requestErr := http.Get(api)
  14910. if requestErr != nil {
  14911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14912. return
  14913. }
  14914. body, ioErr := ioutil.ReadAll(resp.Body)
  14915. if ioErr != nil {
  14916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14918. return
  14919. }
  14920. var respJSON map[string]interface{}
  14921. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14924. return
  14925. }
  14926. var res ResultTwo //1101结果
  14927. var res10265 ResultTwo10265 //1101结果
  14928. var card_info string //卡信息
  14929. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14930. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14931. result, _ := json.Marshal(respJSON)
  14932. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14933. utils.ErrorLog("解析失败:%v", err)
  14934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14935. return
  14936. }
  14937. res.ErrMsg = res10265.ErrMsg
  14938. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14939. res.Infcode = infocode
  14940. res.Output = res10265.Output
  14941. res.InfRefmsgid = res10265.InfRefmsgid
  14942. if res.Infcode == 0 {
  14943. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14944. if err == gorm.ErrRecordNotFound {
  14945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14946. return
  14947. } else if err != nil {
  14948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14949. return
  14950. } else {
  14951. bas := strings.Split(card_info, "|")
  14952. basNumber := bas[2]
  14953. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14954. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14955. infoStr := string(Iinfos)
  14956. idetinfoStr := string(Idetinfos)
  14957. psn := &models.HisPsn{
  14958. PsnNo: res.Output.Baseinfo.PsnNo,
  14959. PatientId: patient.ID,
  14960. Certno: res.Output.Baseinfo.Certno,
  14961. Gend: res.Output.Baseinfo.Gend,
  14962. Naty: res.Output.Baseinfo.Naty,
  14963. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14964. PsnName: res.Output.Baseinfo.PsnName,
  14965. Idetinfo: idetinfoStr,
  14966. Insuinfo: infoStr,
  14967. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14968. CardInfo: card_info,
  14969. VerifyNumber: token,
  14970. }
  14971. service.CreateHisPsn(psn)
  14972. var rf []*ResultFive
  14973. json.Unmarshal([]byte(infoStr), &rf)
  14974. var insutypes []*ResultFive
  14975. var insutype string
  14976. var is390 int = 0
  14977. var is310 int = 0
  14978. for _, item := range rf {
  14979. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14980. insutypes = append(insutypes, item)
  14981. }
  14982. }
  14983. if len(insutypes) == 1 {
  14984. insutype = insutypes[0].Insutype
  14985. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14986. } else {
  14987. for _, i := range insutypes {
  14988. if i.Insutype == "390" {
  14989. is390 = 1
  14990. }
  14991. if i.Insutype == "310" {
  14992. is310 = 1
  14993. }
  14994. }
  14995. }
  14996. if is390 == 1 {
  14997. insutype = "390"
  14998. }
  14999. if is310 == 1 {
  15000. insutype = "310"
  15001. }
  15002. if len(insutypes) == 0 {
  15003. insutype = "310"
  15004. }
  15005. c.ServeSuccessJSON(map[string]interface{}{
  15006. "patient": patient,
  15007. "number": basNumber,
  15008. "insutype": insutype,
  15009. })
  15010. }
  15011. } else {
  15012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15013. return
  15014. }
  15015. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15016. res := c.GetoleInfo()
  15017. if res.Infcode == 0 {
  15018. var result string
  15019. if res.Output.MdtrtCertType == "01" {
  15020. 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)
  15021. } else if res.Output.MdtrtCertType == "02" {
  15022. 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)
  15023. } else if res.Output.MdtrtCertType == "03" {
  15024. 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)
  15025. }
  15026. var dat map[string]interface{}
  15027. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15028. fmt.Println(dat)
  15029. } else {
  15030. fmt.Println(err)
  15031. }
  15032. userJSONBytes, _ := json.Marshal(dat)
  15033. var res2 ResultTwo
  15034. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15035. utils.ErrorLog("解析失败:%v", err)
  15036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15037. return
  15038. }
  15039. if res2.Infcode == 0 {
  15040. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15041. if err == gorm.ErrRecordNotFound {
  15042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15043. return
  15044. } else if err != nil {
  15045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15046. return
  15047. } else {
  15048. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15049. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15050. infoStr := string(Iinfos)
  15051. idetinfoStr := string(Idetinfos)
  15052. var rf []*ResultFive
  15053. json.Unmarshal([]byte(infoStr), &rf)
  15054. var insutypes []*ResultFive
  15055. var insutype string
  15056. var is390 int = 0
  15057. var is310 int = 0
  15058. //var insuplc_admdvs string
  15059. for _, item := range rf {
  15060. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15061. insutypes = append(insutypes, item)
  15062. }
  15063. }
  15064. if len(insutypes) == 1 {
  15065. insutype = insutypes[0].Insutype
  15066. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15067. } else {
  15068. for _, i := range insutypes {
  15069. if i.Insutype == "390" {
  15070. is390 = 1
  15071. }
  15072. if i.Insutype == "310" {
  15073. is310 = 1
  15074. }
  15075. }
  15076. }
  15077. if is390 == 1 {
  15078. insutype = "390"
  15079. }
  15080. if is310 == 1 {
  15081. insutype = "310"
  15082. }
  15083. if len(insutypes) == 0 {
  15084. insutype = "310"
  15085. }
  15086. psn := &models.HisPsn{
  15087. PsnNo: res2.Output.Baseinfo.PsnNo,
  15088. PatientId: patient.ID,
  15089. Certno: res2.Output.Baseinfo.Certno,
  15090. Gend: res2.Output.Baseinfo.Gend,
  15091. Naty: res2.Output.Baseinfo.Naty,
  15092. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15093. PsnName: res2.Output.Baseinfo.PsnName,
  15094. Idetinfo: idetinfoStr,
  15095. Insuinfo: infoStr,
  15096. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15097. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15098. VerifyNumber: res.Output.EcToken,
  15099. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15100. }
  15101. if res.Output.MdtrtCertType == "01" {
  15102. psn.VerifyNumber = res.Output.EcToken
  15103. //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)
  15104. } else if res.Output.MdtrtCertType == "02" {
  15105. psn.VerifyNumber = res.Output.MdtrtCertNo
  15106. //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)
  15107. } else if res.Output.MdtrtCertType == "03" {
  15108. psn.VerifyNumber = res.Output.MdtrtCertNo
  15109. //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)
  15110. }
  15111. var balc float64
  15112. for _, item := range rf {
  15113. if item.Insutype == insutype {
  15114. balc = item.Balc
  15115. }
  15116. }
  15117. service.CreateHisPsn(psn)
  15118. c.ServeSuccessJSON(map[string]interface{}{
  15119. "patient": patient,
  15120. "number": res.Output.CardNo,
  15121. "insutype": insutype,
  15122. "blac": balc,
  15123. "desc": idetinfoStr,
  15124. })
  15125. }
  15126. } else {
  15127. c.ServeSuccessJSON(map[string]interface{}{
  15128. "failed_code": -10,
  15129. "msg": res2.ErrMsg,
  15130. })
  15131. }
  15132. } else {
  15133. c.ServeSuccessJSON(map[string]interface{}{
  15134. "failed_code": -10,
  15135. "msg": res.ErrMsg,
  15136. })
  15137. }
  15138. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15139. var api string
  15140. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15141. "&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
  15142. fmt.Println(api)
  15143. resp, requestErr := http.Get(api)
  15144. if requestErr != nil {
  15145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15146. return
  15147. }
  15148. body, ioErr := ioutil.ReadAll(resp.Body)
  15149. if ioErr != nil {
  15150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15152. return
  15153. }
  15154. var respJSON map[string]interface{}
  15155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15158. return
  15159. }
  15160. var status string
  15161. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15162. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15163. //console.log()
  15164. fmt.Println("type===")
  15165. fmt.Println(card_type)
  15166. var token string
  15167. var res ResultTwo //1101结果
  15168. //var res10265 ResultTwoesultTwo10265 //1101结果
  15169. var card_info string //卡信息
  15170. var busi_card_info string
  15171. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15172. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15173. if status == "0" { //读卡成功
  15174. if card_type == "1" {
  15175. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15176. result, _ := json.Marshal(respJSON)
  15177. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15178. utils.ErrorLog("解析失败:%v", err)
  15179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15180. return
  15181. }
  15182. } else {
  15183. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15184. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15185. result, _ := json.Marshal(respJSON)
  15186. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15187. utils.ErrorLog("解析失败:%v", err)
  15188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15189. return
  15190. }
  15191. }
  15192. if res.Infcode == 0 {
  15193. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15194. if err == gorm.ErrRecordNotFound {
  15195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15196. return
  15197. } else if err != nil {
  15198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15199. return
  15200. } else {
  15201. if card_type == "1" {
  15202. bas := strings.Split(card_info, "|")
  15203. basNumber := bas[2]
  15204. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15205. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15206. infoStr := string(Iinfos)
  15207. idetinfoStr := string(Idetinfos)
  15208. psn := &models.HisPsn{
  15209. PsnNo: res.Output.Baseinfo.PsnNo,
  15210. PatientId: patient.ID,
  15211. Certno: res.Output.Baseinfo.Certno,
  15212. Gend: res.Output.Baseinfo.Gend,
  15213. Naty: res.Output.Baseinfo.Naty,
  15214. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15215. PsnName: res.Output.Baseinfo.PsnName,
  15216. Idetinfo: idetinfoStr,
  15217. Insuinfo: infoStr,
  15218. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15219. CardInfo: card_info,
  15220. VerifyNumber: busi_card_info,
  15221. }
  15222. service.CreateHisPsn(psn)
  15223. var rf []*ResultFive
  15224. json.Unmarshal([]byte(infoStr), &rf)
  15225. var insutypes []*ResultFive
  15226. var insutype string
  15227. var is390 int = 0
  15228. var is310 int = 0
  15229. for _, item := range rf {
  15230. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15231. insutypes = append(insutypes, item)
  15232. }
  15233. }
  15234. if len(insutypes) == 1 {
  15235. insutype = insutypes[0].Insutype
  15236. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15237. } else {
  15238. for _, i := range insutypes {
  15239. if i.Insutype == "390" {
  15240. is390 = 1
  15241. }
  15242. if i.Insutype == "310" {
  15243. is310 = 1
  15244. }
  15245. }
  15246. }
  15247. if is390 == 1 {
  15248. insutype = "390"
  15249. }
  15250. if is310 == 1 {
  15251. insutype = "310"
  15252. }
  15253. if len(insutypes) == 0 {
  15254. insutype = "310"
  15255. }
  15256. c.ServeSuccessJSON(map[string]interface{}{
  15257. "patient": patient,
  15258. "number": basNumber,
  15259. "insutype": insutype,
  15260. })
  15261. } else {
  15262. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15263. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15264. infoStr := string(Iinfos)
  15265. idetinfoStr := string(Idetinfos)
  15266. psn := &models.HisPsn{
  15267. PsnNo: res.Output.Baseinfo.PsnNo,
  15268. PatientId: patient.ID,
  15269. Certno: res.Output.Baseinfo.Certno,
  15270. Gend: res.Output.Baseinfo.Gend,
  15271. Naty: res.Output.Baseinfo.Naty,
  15272. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15273. PsnName: res.Output.Baseinfo.PsnName,
  15274. Idetinfo: idetinfoStr,
  15275. Insuinfo: infoStr,
  15276. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15277. CardInfo: card_info,
  15278. VerifyNumber: token,
  15279. }
  15280. service.CreateHisPsn(psn)
  15281. c.ServeSuccessJSON(map[string]interface{}{
  15282. "patient": patient,
  15283. "number": token,
  15284. })
  15285. }
  15286. }
  15287. } else {
  15288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15289. return
  15290. }
  15291. } else { //读卡失败
  15292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15293. return
  15294. }
  15295. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15296. var api string
  15297. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15298. "&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
  15299. fmt.Println(api)
  15300. resp, requestErr := http.Get(api)
  15301. if requestErr != nil {
  15302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15303. return
  15304. }
  15305. body, ioErr := ioutil.ReadAll(resp.Body)
  15306. if ioErr != nil {
  15307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15309. return
  15310. }
  15311. var respJSON map[string]interface{}
  15312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15315. return
  15316. }
  15317. var status string
  15318. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15319. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15320. //console.log()
  15321. fmt.Println("type===")
  15322. fmt.Println(card_type)
  15323. var token string
  15324. var res ResultTwo //1101结果
  15325. //var res10265 ResultTwoesultTwo10265 //1101结果
  15326. var card_info string //卡信息
  15327. //var busi_card_info string
  15328. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15329. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15330. if status == "0" { //读卡成功
  15331. if card_type == "1" {
  15332. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15333. result, _ := json.Marshal(respJSON)
  15334. fmt.Println(result)
  15335. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15336. utils.ErrorLog("解析失败:%v", err)
  15337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15338. return
  15339. }
  15340. fmt.Println(res)
  15341. } else {
  15342. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15343. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15344. result, _ := json.Marshal(respJSON)
  15345. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15346. utils.ErrorLog("解析失败:%v", err)
  15347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15348. return
  15349. }
  15350. }
  15351. if res.Infcode == 0 {
  15352. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15353. if err == gorm.ErrRecordNotFound {
  15354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15355. return
  15356. } else if err != nil {
  15357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15358. return
  15359. } else {
  15360. if card_type == "1" {
  15361. bas := strings.Split(card_info, "|")
  15362. basNumber := bas[2]
  15363. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15364. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15365. infoStr := string(Iinfos)
  15366. idetinfoStr := string(Idetinfos)
  15367. psn := &models.HisPsn{
  15368. PsnNo: res.Output.Baseinfo.PsnNo,
  15369. PatientId: patient.ID,
  15370. Certno: res.Output.Baseinfo.Certno,
  15371. Gend: res.Output.Baseinfo.Gend,
  15372. Naty: res.Output.Baseinfo.Naty,
  15373. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15374. PsnName: res.Output.Baseinfo.PsnName,
  15375. Idetinfo: idetinfoStr,
  15376. Insuinfo: infoStr,
  15377. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15378. CardInfo: card_info,
  15379. //VerifyNumber: busi_card_info,
  15380. }
  15381. service.CreateHisPsn(psn)
  15382. var rf []*ResultFive
  15383. json.Unmarshal([]byte(infoStr), &rf)
  15384. var insutypes []*ResultFive
  15385. var insutype string
  15386. var is390 int = 0
  15387. var is310 int = 0
  15388. for _, item := range rf {
  15389. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15390. insutypes = append(insutypes, item)
  15391. }
  15392. }
  15393. if len(insutypes) == 1 {
  15394. insutype = insutypes[0].Insutype
  15395. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15396. } else {
  15397. for _, i := range insutypes {
  15398. if i.Insutype == "390" {
  15399. is390 = 1
  15400. }
  15401. if i.Insutype == "310" {
  15402. is310 = 1
  15403. }
  15404. }
  15405. }
  15406. if is390 == 1 {
  15407. insutype = "390"
  15408. }
  15409. if is310 == 1 {
  15410. insutype = "310"
  15411. }
  15412. if len(insutypes) == 0 {
  15413. insutype = "310"
  15414. }
  15415. c.ServeSuccessJSON(map[string]interface{}{
  15416. "patient": patient,
  15417. "number": basNumber,
  15418. "insutype": insutype,
  15419. })
  15420. } else {
  15421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15423. infoStr := string(Iinfos)
  15424. idetinfoStr := string(Idetinfos)
  15425. psn := &models.HisPsn{
  15426. PsnNo: res.Output.Baseinfo.PsnNo,
  15427. PatientId: patient.ID,
  15428. Certno: res.Output.Baseinfo.Certno,
  15429. Gend: res.Output.Baseinfo.Gend,
  15430. Naty: res.Output.Baseinfo.Naty,
  15431. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15432. PsnName: res.Output.Baseinfo.PsnName,
  15433. Idetinfo: idetinfoStr,
  15434. Insuinfo: infoStr,
  15435. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15436. CardInfo: card_info,
  15437. VerifyNumber: token,
  15438. }
  15439. service.CreateHisPsn(psn)
  15440. c.ServeSuccessJSON(map[string]interface{}{
  15441. "patient": patient,
  15442. "number": token,
  15443. })
  15444. }
  15445. }
  15446. } else {
  15447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15448. return
  15449. }
  15450. } else { //读卡失败
  15451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15452. return
  15453. }
  15454. } else {
  15455. if initFlag == 0 {
  15456. c.TestGetBasBaseInit()
  15457. }
  15458. basStr := c.GetBasBaseInfo()
  15459. if len(basStr) == 0 {
  15460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15461. return
  15462. }
  15463. fmt.Println(basStr)
  15464. bas := strings.Split(basStr, "|")
  15465. basNumber := bas[1]
  15466. fmt.Println(basNumber)
  15467. card_sn := bas[3]
  15468. fmt.Println(card_sn)
  15469. cardNumber := bas[2]
  15470. fmt.Println(cardNumber)
  15471. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15472. var result string
  15473. if bas[0][:2] == "44" {
  15474. 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)
  15475. } else {
  15476. 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)
  15477. }
  15478. var dat map[string]interface{}
  15479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15480. fmt.Println(dat)
  15481. } else {
  15482. fmt.Println(err)
  15483. }
  15484. userJSONBytes, _ := json.Marshal(dat)
  15485. var res ResultTwo
  15486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15487. utils.ErrorLog("解析失败:%v", err)
  15488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15489. return
  15490. }
  15491. if res.Infcode == 0 {
  15492. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15493. if err == gorm.ErrRecordNotFound {
  15494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15495. return
  15496. } else if err != nil {
  15497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15498. return
  15499. } else {
  15500. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15501. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15502. infoStr := string(Iinfos)
  15503. idetinfoStr := string(Idetinfos)
  15504. var rf []*ResultFive
  15505. json.Unmarshal([]byte(infoStr), &rf)
  15506. var insutypes []*ResultFive
  15507. var insutype string
  15508. var is390 int = 0
  15509. var is310 int = 0
  15510. var insuplc_admdvs string
  15511. for _, item := range rf {
  15512. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15513. insutypes = append(insutypes, item)
  15514. }
  15515. }
  15516. if len(insutypes) == 1 {
  15517. insutype = insutypes[0].Insutype
  15518. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15519. } else {
  15520. for _, i := range insutypes {
  15521. if i.Insutype == "390" {
  15522. is390 = 1
  15523. }
  15524. if i.Insutype == "310" {
  15525. is310 = 1
  15526. }
  15527. }
  15528. }
  15529. if is390 == 1 {
  15530. insutype = "390"
  15531. }
  15532. if is310 == 1 {
  15533. insutype = "310"
  15534. }
  15535. if len(insutypes) == 0 {
  15536. insutype = "310"
  15537. }
  15538. for _, item := range rf {
  15539. if item.Insutype == insutype {
  15540. insuplc_admdvs = item.InsuplcAdmdvs
  15541. }
  15542. }
  15543. psn := &models.HisPsn{
  15544. PsnNo: res.Output.Baseinfo.PsnNo,
  15545. PatientId: patient.ID,
  15546. Certno: res.Output.Baseinfo.Certno,
  15547. Gend: res.Output.Baseinfo.Gend,
  15548. Naty: res.Output.Baseinfo.Naty,
  15549. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15550. PsnName: res.Output.Baseinfo.PsnName,
  15551. Idetinfo: idetinfoStr,
  15552. Insuinfo: infoStr,
  15553. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15554. CardInfo: basStr,
  15555. VerifyNumber: "",
  15556. InsuplcAdmdvs: insuplc_admdvs,
  15557. }
  15558. service.CreateHisPsn(psn)
  15559. c.ServeSuccessJSON(map[string]interface{}{
  15560. "patient": patient,
  15561. "insutype": insutype,
  15562. "number": basNumber,
  15563. })
  15564. }
  15565. } else {
  15566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15567. return
  15568. }
  15569. break
  15570. }
  15571. case 2:
  15572. if miConfig.MdtrtareaAdmvs == "430800" {
  15573. if initFlag == 0 {
  15574. c.TestGetHnBasBaseInit()
  15575. }
  15576. SFZStr := c.GetSFZBaseInfo()
  15577. if len(SFZStr) == 0 {
  15578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15579. return
  15580. }
  15581. fmt.Println(SFZStr)
  15582. id_card_str := strings.Split(SFZStr, "^")
  15583. card_no := id_card_str[0]
  15584. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15585. //name := id_card_str[1]
  15586. //name = ConvertToString(name, "gbk", "utf-8")
  15587. 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)
  15588. var dat map[string]interface{}
  15589. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15590. fmt.Println(dat)
  15591. } else {
  15592. fmt.Println(err)
  15593. }
  15594. userJSONBytes, _ := json.Marshal(dat)
  15595. var res ResultTwo
  15596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15597. utils.ErrorLog("解析失败:%v", err)
  15598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15599. return
  15600. }
  15601. if res.Infcode == 0 {
  15602. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15603. if err == gorm.ErrRecordNotFound {
  15604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15605. return
  15606. } else if err != nil {
  15607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15608. return
  15609. } else {
  15610. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15611. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15612. infoStr := string(Iinfos)
  15613. idetinfoStr := string(Idetinfos)
  15614. var rf []*ResultFive
  15615. json.Unmarshal([]byte(infoStr), &rf)
  15616. var insutypes []*ResultFive
  15617. var insutype string
  15618. var is390 int = 0
  15619. var is310 int = 0
  15620. for _, item := range rf {
  15621. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15622. insutypes = append(insutypes, item)
  15623. }
  15624. }
  15625. if len(insutypes) == 1 {
  15626. insutype = insutypes[0].Insutype
  15627. } else {
  15628. for _, i := range insutypes {
  15629. if i.Insutype == "390" {
  15630. is390 = 1
  15631. }
  15632. if i.Insutype == "310" {
  15633. is310 = 1
  15634. }
  15635. }
  15636. }
  15637. if is390 == 1 {
  15638. insutype = "390"
  15639. }
  15640. if is310 == 1 {
  15641. insutype = "310"
  15642. }
  15643. if len(insutypes) == 0 {
  15644. insutype = "310"
  15645. }
  15646. var InsuplcAdmdvs string
  15647. for _, item := range rf {
  15648. if item.Insutype == insutype {
  15649. InsuplcAdmdvs = item.InsuplcAdmdvs
  15650. }
  15651. }
  15652. psn := &models.HisPsn{
  15653. PsnNo: res.Output.Baseinfo.PsnNo,
  15654. PatientId: patient.ID,
  15655. Certno: res.Output.Baseinfo.Certno,
  15656. Gend: res.Output.Baseinfo.Gend,
  15657. Naty: res.Output.Baseinfo.Naty,
  15658. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15659. PsnName: res.Output.Baseinfo.PsnName,
  15660. Idetinfo: idetinfoStr,
  15661. Insuinfo: infoStr,
  15662. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15663. CardInfo: SFZStr,
  15664. VerifyNumber: "",
  15665. InsuplcAdmdvs: InsuplcAdmdvs,
  15666. }
  15667. service.CreateHisPsn(psn)
  15668. c.ServeSuccessJSON(map[string]interface{}{
  15669. "patient": patient,
  15670. "number": card_no,
  15671. "insutype": insutype,
  15672. })
  15673. }
  15674. } else {
  15675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15676. return
  15677. }
  15678. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15679. var res ResultTwo
  15680. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15681. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15682. "&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)
  15683. resp, requestErr := http.Get(api)
  15684. if requestErr != nil {
  15685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15686. return
  15687. }
  15688. body, ioErr := ioutil.ReadAll(resp.Body)
  15689. if ioErr != nil {
  15690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15692. return
  15693. }
  15694. var respJSON map[string]interface{}
  15695. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15698. return
  15699. }
  15700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15701. result, _ := json.Marshal(respJSON)
  15702. fmt.Println("log")
  15703. fmt.Println(string(result))
  15704. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15705. utils.ErrorLog("解析失败:%v", err)
  15706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15707. return
  15708. }
  15709. if res.Infcode == 0 {
  15710. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15711. if err == gorm.ErrRecordNotFound {
  15712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15713. return
  15714. } else if err != nil {
  15715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15716. return
  15717. } else {
  15718. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15719. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15720. infoStr := string(Iinfos)
  15721. idetinfoStr := string(Idetinfos)
  15722. psn := &models.HisPsn{
  15723. PsnNo: res.Output.Baseinfo.PsnNo,
  15724. PatientId: patient.ID,
  15725. Certno: res.Output.Baseinfo.Certno,
  15726. Gend: res.Output.Baseinfo.Gend,
  15727. Naty: res.Output.Baseinfo.Naty,
  15728. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15729. PsnName: res.Output.Baseinfo.PsnName,
  15730. Idetinfo: idetinfoStr,
  15731. Insuinfo: infoStr,
  15732. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15733. }
  15734. service.CreateHisPsn(psn)
  15735. c.ServeSuccessJSON(map[string]interface{}{
  15736. "patient": patient,
  15737. "number": res.Output.Baseinfo.Certno,
  15738. })
  15739. }
  15740. } else {
  15741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15742. return
  15743. }
  15744. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15745. var res ResultTwo
  15746. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15747. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15748. "&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)
  15749. resp, requestErr := http.Get(api)
  15750. if requestErr != nil {
  15751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15752. return
  15753. }
  15754. body, ioErr := ioutil.ReadAll(resp.Body)
  15755. if ioErr != nil {
  15756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15758. return
  15759. }
  15760. var respJSON map[string]interface{}
  15761. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15764. return
  15765. }
  15766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15767. result, _ := json.Marshal(respJSON)
  15768. fmt.Println("log")
  15769. fmt.Println(string(result))
  15770. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15771. utils.ErrorLog("解析失败:%v", err)
  15772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15773. return
  15774. }
  15775. if res.Infcode == 0 {
  15776. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15777. if err == gorm.ErrRecordNotFound {
  15778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15779. return
  15780. } else if err != nil {
  15781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15782. return
  15783. } else {
  15784. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15785. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15786. infoStr := string(Iinfos)
  15787. idetinfoStr := string(Idetinfos)
  15788. psn := &models.HisPsn{
  15789. PsnNo: res.Output.Baseinfo.PsnNo,
  15790. PatientId: patient.ID,
  15791. Certno: res.Output.Baseinfo.Certno,
  15792. Gend: res.Output.Baseinfo.Gend,
  15793. Naty: res.Output.Baseinfo.Naty,
  15794. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15795. PsnName: res.Output.Baseinfo.PsnName,
  15796. Idetinfo: idetinfoStr,
  15797. Insuinfo: infoStr,
  15798. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15799. }
  15800. service.CreateHisPsn(psn)
  15801. c.ServeSuccessJSON(map[string]interface{}{
  15802. "patient": patient,
  15803. "number": res.Output.Baseinfo.Certno,
  15804. })
  15805. }
  15806. } else {
  15807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15808. return
  15809. }
  15810. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15811. var res ResultTwo
  15812. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15813. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15814. "&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)
  15815. resp, requestErr := http.Get(api)
  15816. if requestErr != nil {
  15817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15818. return
  15819. }
  15820. body, ioErr := ioutil.ReadAll(resp.Body)
  15821. if ioErr != nil {
  15822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15824. return
  15825. }
  15826. var respJSON map[string]interface{}
  15827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15830. return
  15831. }
  15832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15833. result, _ := json.Marshal(respJSON)
  15834. fmt.Println("log")
  15835. fmt.Println(string(result))
  15836. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15837. utils.ErrorLog("解析失败:%v", err)
  15838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15839. return
  15840. }
  15841. if res.Infcode == 0 {
  15842. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15843. if err == gorm.ErrRecordNotFound {
  15844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15845. return
  15846. } else if err != nil {
  15847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15848. return
  15849. } else {
  15850. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15851. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15852. infoStr := string(Iinfos)
  15853. idetinfoStr := string(Idetinfos)
  15854. var rf []*ResultFive
  15855. json.Unmarshal([]byte(infoStr), &rf)
  15856. var insutypes []*ResultFive
  15857. var insutype string
  15858. var is390 int = 0
  15859. var is310 int = 0
  15860. for _, item := range rf {
  15861. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15862. insutypes = append(insutypes, item)
  15863. }
  15864. }
  15865. if len(insutypes) == 1 {
  15866. insutype = insutypes[0].Insutype
  15867. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15868. } else {
  15869. for _, i := range insutypes {
  15870. if i.Insutype == "390" {
  15871. is390 = 1
  15872. }
  15873. if i.Insutype == "310" {
  15874. is310 = 1
  15875. }
  15876. }
  15877. }
  15878. if is390 == 1 {
  15879. insutype = "390"
  15880. }
  15881. if is310 == 1 {
  15882. insutype = "310"
  15883. }
  15884. if len(insutypes) == 0 {
  15885. insutype = "390"
  15886. }
  15887. var insuplc_admdvs string
  15888. for _, item := range rf {
  15889. if item.Insutype == insutype {
  15890. insuplc_admdvs = item.InsuplcAdmdvs
  15891. }
  15892. }
  15893. psn := &models.HisPsn{
  15894. PsnNo: res.Output.Baseinfo.PsnNo,
  15895. PatientId: patient.ID,
  15896. Certno: res.Output.Baseinfo.Certno,
  15897. Gend: res.Output.Baseinfo.Gend,
  15898. Naty: res.Output.Baseinfo.Naty,
  15899. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15900. PsnName: res.Output.Baseinfo.PsnName,
  15901. Idetinfo: idetinfoStr,
  15902. Insuinfo: infoStr,
  15903. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15904. InsuplcAdmdvs: insuplc_admdvs,
  15905. }
  15906. service.CreateHisPsn(psn)
  15907. c.ServeSuccessJSON(map[string]interface{}{
  15908. "patient": patient,
  15909. "number": res.Output.Baseinfo.Certno,
  15910. })
  15911. }
  15912. } else {
  15913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15914. return
  15915. }
  15916. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15917. res := c.GetoleInfo()
  15918. if res.Infcode == 0 {
  15919. var result string
  15920. if res.Output.MdtrtCertType == "01" {
  15921. 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)
  15922. } else if res.Output.MdtrtCertType == "02" {
  15923. 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)
  15924. } else if res.Output.MdtrtCertType == "03" {
  15925. 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)
  15926. }
  15927. var dat map[string]interface{}
  15928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15929. fmt.Println(dat)
  15930. } else {
  15931. fmt.Println(err)
  15932. }
  15933. userJSONBytes, _ := json.Marshal(dat)
  15934. var res2 ResultTwo
  15935. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15936. utils.ErrorLog("解析失败:%v", err)
  15937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15938. return
  15939. }
  15940. if res2.Infcode == 0 {
  15941. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15942. if err == gorm.ErrRecordNotFound {
  15943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15944. return
  15945. } else if err != nil {
  15946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15947. return
  15948. } else {
  15949. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15950. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15951. infoStr := string(Iinfos)
  15952. idetinfoStr := string(Idetinfos)
  15953. var rf []*ResultFive
  15954. json.Unmarshal([]byte(infoStr), &rf)
  15955. var insutypes []*ResultFive
  15956. var insutype string
  15957. var is390 int = 0
  15958. var is310 int = 0
  15959. //var insuplc_admdvs string
  15960. for _, item := range rf {
  15961. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15962. insutypes = append(insutypes, item)
  15963. }
  15964. }
  15965. if len(insutypes) == 1 {
  15966. insutype = insutypes[0].Insutype
  15967. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15968. } else {
  15969. for _, i := range insutypes {
  15970. if i.Insutype == "390" {
  15971. is390 = 1
  15972. }
  15973. if i.Insutype == "310" {
  15974. is310 = 1
  15975. }
  15976. }
  15977. }
  15978. if is390 == 1 {
  15979. insutype = "390"
  15980. }
  15981. if is310 == 1 {
  15982. insutype = "310"
  15983. }
  15984. if len(insutypes) == 0 {
  15985. insutype = "310"
  15986. }
  15987. psn := &models.HisPsn{
  15988. PsnNo: res2.Output.Baseinfo.PsnNo,
  15989. PatientId: patient.ID,
  15990. //Brdy: res2.Output.Baseinfo.Brdy,
  15991. Certno: res2.Output.Baseinfo.Certno,
  15992. Gend: res2.Output.Baseinfo.Gend,
  15993. Naty: res2.Output.Baseinfo.Naty,
  15994. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15995. PsnName: res2.Output.Baseinfo.PsnName,
  15996. Idetinfo: idetinfoStr,
  15997. Insuinfo: infoStr,
  15998. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15999. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16000. VerifyNumber: res.Output.EcToken,
  16001. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16002. }
  16003. service.CreateHisPsn(psn)
  16004. var balc float64
  16005. for _, item := range rf {
  16006. if item.Insutype == insutype {
  16007. balc = item.Balc
  16008. }
  16009. }
  16010. c.ServeSuccessJSON(map[string]interface{}{
  16011. "patient": patient,
  16012. "number": res.Output.CardNo,
  16013. "insutype": insutype,
  16014. "blac": balc,
  16015. "desc": idetinfoStr,
  16016. })
  16017. }
  16018. } else {
  16019. c.ServeSuccessJSON(map[string]interface{}{
  16020. "failed_code": -10,
  16021. "msg": res2.ErrMsg,
  16022. })
  16023. }
  16024. } else {
  16025. c.ServeSuccessJSON(map[string]interface{}{
  16026. "failed_code": -10,
  16027. "msg": res.ErrMsg,
  16028. })
  16029. }
  16030. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16031. var insuplc_admdvs string
  16032. if len(patient.InsuplcAdmdvs) > 0 {
  16033. insuplc_admdvs = patient.InsuplcAdmdvs
  16034. } else {
  16035. if len(insuplc_admdvs_str) > 0 {
  16036. insuplc_admdvs = insuplc_admdvs_str
  16037. } else {
  16038. insuplc_admdvs = miConfig.InsuplcAdmdvs
  16039. }
  16040. }
  16041. //请求内网数据
  16042. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  16043. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16044. "&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=" + ""
  16045. resp, requestErr := http.Get(api)
  16046. if requestErr != nil {
  16047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16048. return
  16049. }
  16050. body, ioErr := ioutil.ReadAll(resp.Body)
  16051. if ioErr != nil {
  16052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16054. return
  16055. }
  16056. var respJSON map[string]interface{}
  16057. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16060. return
  16061. }
  16062. status := respJSON["data"].(map[string]interface{})["status"].(string)
  16063. if status == "0" {
  16064. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  16065. c.ServeSuccessJSON(map[string]interface{}{
  16066. "failed_code": -10,
  16067. "msg": err_msg,
  16068. })
  16069. return
  16070. }
  16071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16072. var res ResultTwo
  16073. result, _ := json.Marshal(respJSON)
  16074. fmt.Println("log")
  16075. fmt.Println(string(result))
  16076. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16077. utils.ErrorLog("解析失败:%v", err)
  16078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16079. return
  16080. }
  16081. if res.Infcode == 0 {
  16082. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16083. if err == gorm.ErrRecordNotFound {
  16084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16085. return
  16086. } else if err != nil {
  16087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16088. return
  16089. } else {
  16090. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16091. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16092. infoStr := string(Iinfos)
  16093. idetinfoStr := string(Idetinfos)
  16094. psn := &models.HisPsn{
  16095. PsnNo: res.Output.Baseinfo.PsnNo,
  16096. PatientId: patient.ID,
  16097. Certno: res.Output.Baseinfo.Certno,
  16098. Gend: res.Output.Baseinfo.Gend,
  16099. Naty: res.Output.Baseinfo.Naty,
  16100. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16101. PsnName: res.Output.Baseinfo.PsnName,
  16102. Idetinfo: idetinfoStr,
  16103. Insuinfo: infoStr,
  16104. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16105. }
  16106. service.CreateHisPsn(psn)
  16107. var rf []*ResultFive
  16108. json.Unmarshal([]byte(infoStr), &rf)
  16109. var insutypes []*ResultFive
  16110. var is390 int = 0
  16111. var is310 int = 0
  16112. var insutype string
  16113. for _, item := range rf {
  16114. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16115. insutypes = append(insutypes, item)
  16116. }
  16117. }
  16118. if len(insutypes) == 1 {
  16119. insutype = insutypes[0].Insutype
  16120. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16121. } else {
  16122. for _, i := range insutypes {
  16123. if i.Insutype == "390" {
  16124. is390 = 1
  16125. }
  16126. if i.Insutype == "310" {
  16127. is310 = 1
  16128. }
  16129. }
  16130. }
  16131. if is390 == 1 {
  16132. insutype = "390"
  16133. }
  16134. if is310 == 1 {
  16135. insutype = "310"
  16136. }
  16137. if len(insutypes) == 0 {
  16138. insutype = "390"
  16139. }
  16140. c.ServeSuccessJSON(map[string]interface{}{
  16141. "patient": patient,
  16142. "insutype": insutype,
  16143. "number": res.Output.Baseinfo.Certno,
  16144. "info": res,
  16145. })
  16146. }
  16147. } else {
  16148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16149. return
  16150. }
  16151. } else {
  16152. SFZStr := c.GetSFZBaseInfo()
  16153. id_card_str := strings.Split(SFZStr, "^")
  16154. id_card_number := id_card_str[0]
  16155. card_sn := ""
  16156. 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)
  16157. var dat map[string]interface{}
  16158. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16159. fmt.Println(dat)
  16160. } else {
  16161. fmt.Println(err)
  16162. }
  16163. userJSONBytes, _ := json.Marshal(dat)
  16164. var res ResultTwo
  16165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16166. utils.ErrorLog("解析失败:%v", err)
  16167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16168. return
  16169. }
  16170. if res.Infcode == 0 {
  16171. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16172. if err == gorm.ErrRecordNotFound {
  16173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16174. return
  16175. } else if err != nil {
  16176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16177. return
  16178. } else {
  16179. c.ServeSuccessJSON(map[string]interface{}{
  16180. "patient": patient,
  16181. "number": id_card_number,
  16182. })
  16183. }
  16184. } else {
  16185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16186. return
  16187. }
  16188. }
  16189. break
  16190. case 3:
  16191. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16192. var api string
  16193. if miConfig.MdtrtareaAdmvs == "320830" {
  16194. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16195. "&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
  16196. fmt.Println(api)
  16197. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16198. 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 +
  16199. "&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
  16200. fmt.Println(api)
  16201. } else {
  16202. 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 +
  16203. "&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)
  16204. }
  16205. resp, requestErr := http.Get(api)
  16206. if requestErr != nil {
  16207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16208. return
  16209. }
  16210. body, ioErr := ioutil.ReadAll(resp.Body)
  16211. if ioErr != nil {
  16212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16214. return
  16215. }
  16216. var respJSON map[string]interface{}
  16217. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16220. return
  16221. }
  16222. var status string
  16223. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16224. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16225. var token string
  16226. var res ResultTwo //1101结果
  16227. var res10265 ResultTwo10265 //1101结果
  16228. var card_info string //卡信息
  16229. var busi_card_info string
  16230. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16231. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16232. if status == "0" { //读卡成功
  16233. if card_type == "1" {
  16234. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16235. result, _ := json.Marshal(respJSON)
  16236. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16237. utils.ErrorLog("解析失败:%v", err)
  16238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16239. return
  16240. }
  16241. res.ErrMsg = res10265.ErrMsg
  16242. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16243. res.Infcode = infocode
  16244. res.Output = res10265.Output
  16245. res.InfRefmsgid = res10265.InfRefmsgid
  16246. } else {
  16247. //var card_info string //卡信息
  16248. //var busi_card_info string
  16249. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16250. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16251. //fmt.Println(card_info)
  16252. //fmt.Println(busi_card_info)
  16253. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16254. result, _ := json.Marshal(respJSON)
  16255. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16256. utils.ErrorLog("解析失败:%v", err)
  16257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16258. return
  16259. }
  16260. res.ErrMsg = res10265.ErrMsg
  16261. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16262. res.Infcode = infocode
  16263. res.Output = res10265.Output
  16264. res.InfRefmsgid = res10265.InfRefmsgid
  16265. }
  16266. if res.Infcode == 0 {
  16267. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16268. if err == gorm.ErrRecordNotFound {
  16269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16270. return
  16271. } else if err != nil {
  16272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16273. return
  16274. } else {
  16275. if card_type == "1" {
  16276. bas := strings.Split(card_info, "|")
  16277. basNumber := bas[2]
  16278. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16279. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16280. infoStr := string(Iinfos)
  16281. idetinfoStr := string(Idetinfos)
  16282. psn := &models.HisPsn{
  16283. PsnNo: res.Output.Baseinfo.PsnNo,
  16284. PatientId: patient.ID,
  16285. Certno: res.Output.Baseinfo.Certno,
  16286. //Brdy: res.Output.Baseinfo.Brdy,
  16287. Gend: res.Output.Baseinfo.Gend,
  16288. Naty: res.Output.Baseinfo.Naty,
  16289. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16290. PsnName: res.Output.Baseinfo.PsnName,
  16291. Idetinfo: idetinfoStr,
  16292. Insuinfo: infoStr,
  16293. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16294. CardInfo: card_info,
  16295. VerifyNumber: busi_card_info,
  16296. }
  16297. service.CreateHisPsn(psn)
  16298. c.ServeSuccessJSON(map[string]interface{}{
  16299. "patient": patient,
  16300. "number": basNumber,
  16301. })
  16302. } else {
  16303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16305. infoStr := string(Iinfos)
  16306. idetinfoStr := string(Idetinfos)
  16307. psn := &models.HisPsn{
  16308. PsnNo: res.Output.Baseinfo.PsnNo,
  16309. PatientId: patient.ID,
  16310. Certno: res.Output.Baseinfo.Certno,
  16311. Gend: res.Output.Baseinfo.Gend,
  16312. Naty: res.Output.Baseinfo.Naty,
  16313. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16314. PsnName: res.Output.Baseinfo.PsnName,
  16315. Idetinfo: idetinfoStr,
  16316. Insuinfo: infoStr,
  16317. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16318. CardInfo: card_info,
  16319. VerifyNumber: token,
  16320. }
  16321. service.CreateHisPsn(psn)
  16322. var rf []*ResultFive
  16323. json.Unmarshal([]byte(infoStr), &rf)
  16324. var insutypes []*ResultFive
  16325. var insutype string
  16326. var is390 int = 0
  16327. var is310 int = 0
  16328. for _, item := range rf {
  16329. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16330. insutypes = append(insutypes, item)
  16331. }
  16332. }
  16333. if len(insutypes) == 1 {
  16334. insutype = insutypes[0].Insutype
  16335. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16336. } else {
  16337. for _, i := range insutypes {
  16338. if i.Insutype == "390" {
  16339. is390 = 1
  16340. }
  16341. if i.Insutype == "310" {
  16342. is310 = 1
  16343. }
  16344. }
  16345. }
  16346. if is390 == 1 {
  16347. insutype = "390"
  16348. }
  16349. if is310 == 1 {
  16350. insutype = "310"
  16351. }
  16352. if len(insutypes) == 0 {
  16353. insutype = "310"
  16354. }
  16355. c.ServeSuccessJSON(map[string]interface{}{
  16356. "patient": patient,
  16357. "number": token,
  16358. "insutype": insutype,
  16359. })
  16360. }
  16361. }
  16362. } else {
  16363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16364. return
  16365. }
  16366. } else { //读卡失败
  16367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16368. return
  16369. }
  16370. }
  16371. break
  16372. case 4:
  16373. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16374. var api string
  16375. if miConfig.MdtrtareaAdmvs == "320830" {
  16376. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16377. "&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
  16378. fmt.Println(api)
  16379. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16380. 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 +
  16381. "&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
  16382. fmt.Println(api)
  16383. } else {
  16384. 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 +
  16385. "&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)
  16386. }
  16387. resp, requestErr := http.Get(api)
  16388. if requestErr != nil {
  16389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16390. return
  16391. }
  16392. body, ioErr := ioutil.ReadAll(resp.Body)
  16393. if ioErr != nil {
  16394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16396. return
  16397. }
  16398. var respJSON map[string]interface{}
  16399. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16402. return
  16403. }
  16404. var status string
  16405. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16406. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16407. var token string
  16408. var res ResultTwo //1101结果
  16409. var res10265 ResultTwo10265 //1101结果
  16410. if status == "0" { //读卡成功
  16411. var card_info string //卡信息
  16412. var busi_card_info string
  16413. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16414. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16415. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16416. fmt.Println(card_info)
  16417. fmt.Println(busi_card_info)
  16418. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16419. result, _ := json.Marshal(respJSON)
  16420. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16421. utils.ErrorLog("解析失败:%v", err)
  16422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16423. return
  16424. }
  16425. res.ErrMsg = res10265.ErrMsg
  16426. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16427. res.Infcode = infocode
  16428. res.Output = res10265.Output
  16429. res.InfRefmsgid = res10265.InfRefmsgid
  16430. if res.Infcode == 0 {
  16431. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16432. if err == gorm.ErrRecordNotFound {
  16433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16434. return
  16435. } else if err != nil {
  16436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16437. return
  16438. } else {
  16439. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16440. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16441. infoStr := string(Iinfos)
  16442. idetinfoStr := string(Idetinfos)
  16443. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16444. psn := &models.HisPsn{
  16445. PsnNo: res.Output.Baseinfo.PsnNo,
  16446. PatientId: patient.ID,
  16447. Certno: res.Output.Baseinfo.Certno,
  16448. Brdy: b,
  16449. Age: float64(age),
  16450. //Brdy: res.Output.Baseinfo.Brdy,
  16451. Gend: res.Output.Baseinfo.Gend,
  16452. Naty: res.Output.Baseinfo.Naty,
  16453. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16454. PsnName: res.Output.Baseinfo.PsnName,
  16455. Idetinfo: idetinfoStr,
  16456. Insuinfo: infoStr,
  16457. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16458. CardInfo: card_info,
  16459. VerifyNumber: token,
  16460. }
  16461. var rf []*ResultFive
  16462. json.Unmarshal([]byte(infoStr), &rf)
  16463. var insutypes []*ResultFive
  16464. var insutype string
  16465. var is390 int = 0
  16466. var is310 int = 0
  16467. for _, item := range rf {
  16468. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16469. insutypes = append(insutypes, item)
  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. if i.Insutype == "310" {
  16481. is310 = 1
  16482. }
  16483. }
  16484. }
  16485. if is390 == 1 {
  16486. insutype = "390"
  16487. }
  16488. if is310 == 1 {
  16489. insutype = "310"
  16490. }
  16491. if len(insutypes) == 0 {
  16492. insutype = "310"
  16493. }
  16494. service.CreateHisPsn(psn)
  16495. c.ServeSuccessJSON(map[string]interface{}{
  16496. "patient": patient,
  16497. "number": token,
  16498. "insutype": insutype,
  16499. })
  16500. }
  16501. } else {
  16502. c.ServeSuccessJSON(map[string]interface{}{
  16503. "failed_code": -10,
  16504. "msg": res.ErrMsg,
  16505. })
  16506. }
  16507. } else { //读卡失败
  16508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16509. return
  16510. }
  16511. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16512. var api string
  16513. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16514. "&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
  16515. resp, requestErr := http.Get(api)
  16516. if requestErr != nil {
  16517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16518. return
  16519. }
  16520. body, ioErr := ioutil.ReadAll(resp.Body)
  16521. if ioErr != nil {
  16522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16524. return
  16525. }
  16526. var respJSON map[string]interface{}
  16527. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16530. return
  16531. }
  16532. var status string
  16533. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16534. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16535. var token string
  16536. var res ResultTwo //1101结果
  16537. if status == "1" { //读卡成功
  16538. var card_info string //卡信息
  16539. var busi_card_info string
  16540. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16541. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16542. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16543. fmt.Println(card_info)
  16544. fmt.Println(busi_card_info)
  16545. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16546. result, _ := json.Marshal(respJSON)
  16547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16548. utils.ErrorLog("解析失败:%v", err)
  16549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16550. return
  16551. }
  16552. if res.Infcode == 0 {
  16553. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16554. if err == gorm.ErrRecordNotFound {
  16555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16556. return
  16557. } else if err != nil {
  16558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16559. return
  16560. } else {
  16561. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16562. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16563. infoStr := string(Iinfos)
  16564. idetinfoStr := string(Idetinfos)
  16565. psn := &models.HisPsn{
  16566. PsnNo: res.Output.Baseinfo.PsnNo,
  16567. PatientId: patient.ID,
  16568. Certno: res.Output.Baseinfo.Certno,
  16569. Gend: res.Output.Baseinfo.Gend,
  16570. Naty: res.Output.Baseinfo.Naty,
  16571. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16572. PsnName: res.Output.Baseinfo.PsnName,
  16573. Idetinfo: idetinfoStr,
  16574. Insuinfo: infoStr,
  16575. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16576. CardInfo: card_info,
  16577. VerifyNumber: token,
  16578. }
  16579. var rf []*ResultFive
  16580. json.Unmarshal([]byte(infoStr), &rf)
  16581. var insutypes []*ResultFive
  16582. var insutype string
  16583. var is390 int = 0
  16584. var is310 int = 0
  16585. for _, item := range rf {
  16586. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16587. insutypes = append(insutypes, item)
  16588. }
  16589. }
  16590. if len(insutypes) == 1 {
  16591. insutype = insutypes[0].Insutype
  16592. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16593. } else {
  16594. for _, i := range insutypes {
  16595. if i.Insutype == "390" {
  16596. is390 = 1
  16597. }
  16598. if i.Insutype == "310" {
  16599. is310 = 1
  16600. }
  16601. }
  16602. }
  16603. if is390 == 1 {
  16604. insutype = "390"
  16605. }
  16606. if is310 == 1 {
  16607. insutype = "310"
  16608. }
  16609. if len(insutypes) == 0 {
  16610. insutype = "310"
  16611. }
  16612. service.CreateHisPsn(psn)
  16613. c.ServeSuccessJSON(map[string]interface{}{
  16614. "patient": patient,
  16615. "number": token,
  16616. "insutype": insutype,
  16617. })
  16618. }
  16619. } else {
  16620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16621. return
  16622. }
  16623. } else { //读卡失败
  16624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16625. return
  16626. }
  16627. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16628. var api string
  16629. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16630. "&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
  16631. resp, requestErr := http.Get(api)
  16632. if requestErr != nil {
  16633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16634. return
  16635. }
  16636. body, ioErr := ioutil.ReadAll(resp.Body)
  16637. if ioErr != nil {
  16638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16640. return
  16641. }
  16642. var respJSON map[string]interface{}
  16643. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16646. return
  16647. }
  16648. var status string
  16649. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16650. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16651. var token string
  16652. var res ResultTwo //1101结果
  16653. if status == "1" { //读卡成功
  16654. var card_info string //卡信息
  16655. var busi_card_info string
  16656. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16657. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16658. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16659. fmt.Println(card_info)
  16660. fmt.Println(busi_card_info)
  16661. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16662. result, _ := json.Marshal(respJSON)
  16663. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16664. utils.ErrorLog("解析失败:%v", err)
  16665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16666. return
  16667. }
  16668. if res.Infcode == 0 {
  16669. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16670. if err == gorm.ErrRecordNotFound {
  16671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16672. return
  16673. } else if err != nil {
  16674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16675. return
  16676. } else {
  16677. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16678. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16679. infoStr := string(Iinfos)
  16680. idetinfoStr := string(Idetinfos)
  16681. psn := &models.HisPsn{
  16682. PsnNo: res.Output.Baseinfo.PsnNo,
  16683. PatientId: patient.ID,
  16684. Certno: res.Output.Baseinfo.Certno,
  16685. Gend: res.Output.Baseinfo.Gend,
  16686. Naty: res.Output.Baseinfo.Naty,
  16687. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16688. PsnName: res.Output.Baseinfo.PsnName,
  16689. Idetinfo: idetinfoStr,
  16690. Insuinfo: infoStr,
  16691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16692. CardInfo: card_info,
  16693. VerifyNumber: token,
  16694. }
  16695. var rf []*ResultFive
  16696. json.Unmarshal([]byte(infoStr), &rf)
  16697. var insutypes []*ResultFive
  16698. var insutype string
  16699. var is390 int = 0
  16700. var is310 int = 0
  16701. for _, item := range rf {
  16702. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16703. insutypes = append(insutypes, item)
  16704. }
  16705. }
  16706. if len(insutypes) == 1 {
  16707. insutype = insutypes[0].Insutype
  16708. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16709. } else {
  16710. for _, i := range insutypes {
  16711. if i.Insutype == "390" {
  16712. is390 = 1
  16713. }
  16714. if i.Insutype == "310" {
  16715. is310 = 1
  16716. }
  16717. }
  16718. }
  16719. if is390 == 1 {
  16720. insutype = "390"
  16721. }
  16722. if is310 == 1 {
  16723. insutype = "310"
  16724. }
  16725. if len(insutypes) == 0 {
  16726. insutype = "390"
  16727. }
  16728. service.CreateHisPsn(psn)
  16729. c.ServeSuccessJSON(map[string]interface{}{
  16730. "patient": patient,
  16731. "number": token,
  16732. "insutype": insutype,
  16733. })
  16734. }
  16735. } else {
  16736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16737. return
  16738. }
  16739. } else { //读卡失败
  16740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16741. return
  16742. }
  16743. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16744. //idNo := c.GetString("idNo")
  16745. //userName := c.GetString("userName")
  16746. //ecToken := c.GetString("ecToken")
  16747. //insuOrg := c.GetString("insuOrg")
  16748. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16749. utils.ErrorLog("解析失败:%v", json_result)
  16750. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16751. type ELeData struct {
  16752. Data struct {
  16753. IdNo string `json:"idNo"`
  16754. IdType string `json:"idType"`
  16755. UserName string `json:"userName"`
  16756. EcToken string `json:"ecToken"`
  16757. InsuOrg string `json:"insuOrg"`
  16758. Gender string `json:"gender"`
  16759. Birthday string `json:"birthday"`
  16760. Nationality string `json:"nationality"`
  16761. Email string `json:"email"`
  16762. Extra string `json:"extra"`
  16763. } `json:"data"`
  16764. Code int `json:"code"`
  16765. Message string `json:"message"`
  16766. }
  16767. var ele ELeData
  16768. err := json.Unmarshal([]byte(json_result), &ele)
  16769. if err != nil {
  16770. utils.ErrorLog("解析失败:%v", err)
  16771. }
  16772. token := ele.Data.EcToken
  16773. token = Remove0000(token)
  16774. 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)
  16775. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16776. var res ResultTwo
  16777. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16778. utils.ErrorLog("解析失败:%v", err)
  16779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16780. return
  16781. }
  16782. if res.Infcode == 0 {
  16783. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16784. if err == gorm.ErrRecordNotFound {
  16785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16786. return
  16787. } else if err != nil {
  16788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16789. return
  16790. } else {
  16791. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16792. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16793. infoStr := string(Iinfos)
  16794. idetinfoStr := string(Idetinfos)
  16795. psn := &models.HisPsn{
  16796. PsnNo: res.Output.Baseinfo.PsnNo,
  16797. PatientId: patient.ID,
  16798. Certno: res.Output.Baseinfo.Certno,
  16799. Gend: res.Output.Baseinfo.Gend,
  16800. Naty: res.Output.Baseinfo.Naty,
  16801. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16802. PsnName: res.Output.Baseinfo.PsnName,
  16803. Idetinfo: idetinfoStr,
  16804. Insuinfo: infoStr,
  16805. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16806. CardInfo: "",
  16807. Stage: "1",
  16808. VerifyNumber: token,
  16809. InsuplcAdmdvs: ele.Data.InsuOrg,
  16810. }
  16811. service.CreateHisPsn(psn)
  16812. var rf []*ResultFive
  16813. json.Unmarshal([]byte(infoStr), &rf)
  16814. var insutypes []*ResultFive
  16815. var insutype string
  16816. var is390 int = 0
  16817. var is310 int = 0
  16818. for _, item := range rf {
  16819. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16820. insutypes = append(insutypes, item)
  16821. }
  16822. }
  16823. if len(insutypes) == 1 {
  16824. insutype = insutypes[0].Insutype
  16825. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16826. } else {
  16827. for _, i := range insutypes {
  16828. if i.Insutype == "390" {
  16829. is390 = 1
  16830. }
  16831. if i.Insutype == "310" {
  16832. is310 = 1
  16833. }
  16834. }
  16835. }
  16836. if is390 == 1 {
  16837. insutype = "390"
  16838. }
  16839. if is310 == 1 {
  16840. insutype = "310"
  16841. }
  16842. if len(insutypes) == 0 {
  16843. insutype = "310"
  16844. }
  16845. c.ServeSuccessJSON(map[string]interface{}{
  16846. "patient": patient,
  16847. "number": token,
  16848. "insutype": insutype,
  16849. })
  16850. }
  16851. } else {
  16852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16853. return
  16854. }
  16855. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16856. //if initFlag == 0 {
  16857. //c.TestGetJiangXiBasBaseInit()
  16858. //}
  16859. //if initEleFlag == 0 {
  16860. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16861. //}
  16862. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16863. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16864. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16865. type ELeData struct {
  16866. Data struct {
  16867. IdNo string `json:"idNo"`
  16868. IdType string `json:"idType"`
  16869. UserName string `json:"userName"`
  16870. EcToken string `json:"ecToken"`
  16871. InsuOrg string `json:"insuOrg"`
  16872. Gender string `json:"gender"`
  16873. Birthday string `json:"birthday"`
  16874. Nationality string `json:"nationality"`
  16875. Email string `json:"email"`
  16876. Extra string `json:"extra"`
  16877. } `json:"data"`
  16878. Code int `json:"code"`
  16879. Message string `json:"message"`
  16880. }
  16881. var ele ELeData
  16882. err := json.Unmarshal([]byte(result), &ele)
  16883. if err != nil {
  16884. utils.ErrorLog("解析失败:%v", err)
  16885. }
  16886. token := ele.Data.EcToken
  16887. token = Remove0000(token)
  16888. 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)
  16889. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16890. var res ResultTwo
  16891. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16892. utils.ErrorLog("解析失败:%v", err)
  16893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16894. return
  16895. }
  16896. if res.Infcode == 0 {
  16897. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16898. if err == gorm.ErrRecordNotFound {
  16899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16900. return
  16901. } else if err != nil {
  16902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16903. return
  16904. } else {
  16905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16907. infoStr := string(Iinfos)
  16908. idetinfoStr := string(Idetinfos)
  16909. psn := &models.HisPsn{
  16910. PsnNo: res.Output.Baseinfo.PsnNo,
  16911. PatientId: patient.ID,
  16912. Certno: res.Output.Baseinfo.Certno,
  16913. Gend: res.Output.Baseinfo.Gend,
  16914. Naty: res.Output.Baseinfo.Naty,
  16915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16916. PsnName: res.Output.Baseinfo.PsnName,
  16917. Idetinfo: idetinfoStr,
  16918. Insuinfo: infoStr,
  16919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16920. CardInfo: "",
  16921. VerifyNumber: token,
  16922. InsuplcAdmdvs: ele.Data.InsuOrg,
  16923. }
  16924. service.CreateHisPsn(psn)
  16925. var rf []*ResultFive
  16926. json.Unmarshal([]byte(infoStr), &rf)
  16927. var insutypes []*ResultFive
  16928. var insutype string
  16929. var is390 int = 0
  16930. var is310 int = 0
  16931. for _, item := range rf {
  16932. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16933. insutypes = append(insutypes, item)
  16934. }
  16935. }
  16936. if len(insutypes) == 1 {
  16937. insutype = insutypes[0].Insutype
  16938. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16939. } else {
  16940. for _, i := range insutypes {
  16941. if i.Insutype == "390" {
  16942. is390 = 1
  16943. }
  16944. if i.Insutype == "310" {
  16945. is310 = 1
  16946. }
  16947. }
  16948. }
  16949. if is390 == 1 {
  16950. insutype = "390"
  16951. }
  16952. if is310 == 1 {
  16953. insutype = "310"
  16954. }
  16955. if len(insutypes) == 0 {
  16956. insutype = "310"
  16957. }
  16958. c.ServeSuccessJSON(map[string]interface{}{
  16959. "patient": patient,
  16960. "number": token,
  16961. "insutype": insutype,
  16962. })
  16963. }
  16964. } else {
  16965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16966. return
  16967. }
  16968. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16969. //if initFlag == 0 {
  16970. //c.TestGetJiangXiBasBaseInit()
  16971. //}
  16972. //if initEleFlag == 0 {
  16973. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16974. //}
  16975. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16976. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16977. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16978. type ELeData struct {
  16979. Data struct {
  16980. IdNo string `json:"idNo"`
  16981. IdType string `json:"idType"`
  16982. UserName string `json:"userName"`
  16983. EcToken string `json:"ecToken"`
  16984. InsuOrg string `json:"insuOrg"`
  16985. Gender string `json:"gender"`
  16986. Birthday string `json:"birthday"`
  16987. Nationality string `json:"nationality"`
  16988. Email string `json:"email"`
  16989. Extra string `json:"extra"`
  16990. } `json:"data"`
  16991. Code int `json:"code"`
  16992. Message string `json:"message"`
  16993. }
  16994. var ele ELeData
  16995. err := json.Unmarshal([]byte(result), &ele)
  16996. if err != nil {
  16997. utils.ErrorLog("解析失败:%v", err)
  16998. }
  16999. token := ele.Data.EcToken
  17000. token = Remove0000(token)
  17001. 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)
  17002. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17003. var res ResultTwo
  17004. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17005. utils.ErrorLog("解析失败:%v", err)
  17006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17007. return
  17008. }
  17009. if res.Infcode == 0 {
  17010. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17011. if err == gorm.ErrRecordNotFound {
  17012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17013. return
  17014. } else if err != nil {
  17015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17016. return
  17017. } else {
  17018. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17019. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17020. infoStr := string(Iinfos)
  17021. idetinfoStr := string(Idetinfos)
  17022. psn := &models.HisPsn{
  17023. PsnNo: res.Output.Baseinfo.PsnNo,
  17024. PatientId: patient.ID,
  17025. Certno: res.Output.Baseinfo.Certno,
  17026. Gend: res.Output.Baseinfo.Gend,
  17027. Naty: res.Output.Baseinfo.Naty,
  17028. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17029. PsnName: res.Output.Baseinfo.PsnName,
  17030. Idetinfo: idetinfoStr,
  17031. Insuinfo: infoStr,
  17032. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17033. CardInfo: "",
  17034. VerifyNumber: token,
  17035. InsuplcAdmdvs: ele.Data.InsuOrg,
  17036. }
  17037. service.CreateHisPsn(psn)
  17038. var rf []*ResultFive
  17039. json.Unmarshal([]byte(infoStr), &rf)
  17040. var insutypes []*ResultFive
  17041. var insutype string
  17042. var is390 int = 0
  17043. var is310 int = 0
  17044. for _, item := range rf {
  17045. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17046. insutypes = append(insutypes, item)
  17047. }
  17048. }
  17049. if len(insutypes) == 1 {
  17050. insutype = insutypes[0].Insutype
  17051. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17052. } else {
  17053. for _, i := range insutypes {
  17054. if i.Insutype == "390" {
  17055. is390 = 1
  17056. }
  17057. if i.Insutype == "310" {
  17058. is310 = 1
  17059. }
  17060. }
  17061. }
  17062. if is390 == 1 {
  17063. insutype = "390"
  17064. }
  17065. if is310 == 1 {
  17066. insutype = "310"
  17067. }
  17068. if len(insutypes) == 0 {
  17069. insutype = "310"
  17070. }
  17071. c.ServeSuccessJSON(map[string]interface{}{
  17072. "patient": patient,
  17073. "number": token,
  17074. "insutype": insutype,
  17075. })
  17076. }
  17077. } else {
  17078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17079. return
  17080. }
  17081. } else if miConfig.MdtrtareaAdmvs == "360100" {
  17082. //if initFlag == 0 {
  17083. //c.TestGetJiangXiBasBaseInit()
  17084. //}
  17085. //if initEleFlag == 0 {
  17086. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17087. //}
  17088. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  17089. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  17090. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17091. type ELeData struct {
  17092. Data struct {
  17093. IdNo string `json:"idNo"`
  17094. IdType string `json:"idType"`
  17095. UserName string `json:"userName"`
  17096. EcToken string `json:"ecToken"`
  17097. InsuOrg string `json:"insuOrg"`
  17098. Gender string `json:"gender"`
  17099. Birthday string `json:"birthday"`
  17100. Nationality string `json:"nationality"`
  17101. Email string `json:"email"`
  17102. Extra string `json:"extra"`
  17103. } `json:"data"`
  17104. Code int `json:"code"`
  17105. Message string `json:"message"`
  17106. }
  17107. var ele ELeData
  17108. err := json.Unmarshal([]byte(result), &ele)
  17109. if err != nil {
  17110. utils.ErrorLog("解析失败:%v", err)
  17111. }
  17112. token := ele.Data.EcToken
  17113. token = Remove0000(token)
  17114. 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)
  17115. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17116. var res ResultTwo
  17117. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17118. utils.ErrorLog("解析失败:%v", err)
  17119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17120. return
  17121. }
  17122. if res.Infcode == 0 {
  17123. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17124. if err == gorm.ErrRecordNotFound {
  17125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17126. return
  17127. } else if err != nil {
  17128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17129. return
  17130. } else {
  17131. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17132. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17133. infoStr := string(Iinfos)
  17134. idetinfoStr := string(Idetinfos)
  17135. psn := &models.HisPsn{
  17136. PsnNo: res.Output.Baseinfo.PsnNo,
  17137. PatientId: patient.ID,
  17138. Certno: res.Output.Baseinfo.Certno,
  17139. Gend: res.Output.Baseinfo.Gend,
  17140. Naty: res.Output.Baseinfo.Naty,
  17141. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17142. PsnName: res.Output.Baseinfo.PsnName,
  17143. Idetinfo: idetinfoStr,
  17144. Insuinfo: infoStr,
  17145. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17146. CardInfo: "",
  17147. VerifyNumber: token,
  17148. InsuplcAdmdvs: ele.Data.InsuOrg,
  17149. }
  17150. service.CreateHisPsn(psn)
  17151. var rf []*ResultFive
  17152. json.Unmarshal([]byte(infoStr), &rf)
  17153. var insutypes []*ResultFive
  17154. var insutype string
  17155. var is390 int = 0
  17156. var is310 int = 0
  17157. for _, item := range rf {
  17158. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17159. insutypes = append(insutypes, item)
  17160. }
  17161. }
  17162. if len(insutypes) == 1 {
  17163. insutype = insutypes[0].Insutype
  17164. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17165. } else {
  17166. for _, i := range insutypes {
  17167. if i.Insutype == "390" {
  17168. is390 = 1
  17169. }
  17170. if i.Insutype == "310" {
  17171. is310 = 1
  17172. }
  17173. }
  17174. }
  17175. if is390 == 1 {
  17176. insutype = "390"
  17177. }
  17178. if is310 == 1 {
  17179. insutype = "310"
  17180. }
  17181. if len(insutypes) == 0 {
  17182. insutype = "310"
  17183. }
  17184. c.ServeSuccessJSON(map[string]interface{}{
  17185. "patient": patient,
  17186. "number": token,
  17187. "insutype": insutype,
  17188. })
  17189. }
  17190. } else {
  17191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17192. return
  17193. }
  17194. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17195. //if initFlag == 0 {
  17196. c.TestGetJiangXiBasBaseInit()
  17197. //}
  17198. //if initEleFlag == 0 {
  17199. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17200. //}
  17201. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17202. type ELeData struct {
  17203. Data struct {
  17204. IdNo string `json:"idNo"`
  17205. IdType string `json:"idType"`
  17206. UserName string `json:"userName"`
  17207. EcToken string `json:"ecToken"`
  17208. InsuOrg string `json:"insuOrg"`
  17209. Gender string `json:"gender"`
  17210. Birthday string `json:"birthday"`
  17211. Nationality string `json:"nationality"`
  17212. Email string `json:"email"`
  17213. Extra string `json:"extra"`
  17214. } `json:"data"`
  17215. Code int `json:"code"`
  17216. Message string `json:"message"`
  17217. }
  17218. var ele ELeData
  17219. err := json.Unmarshal([]byte(json_result), &ele)
  17220. if err != nil {
  17221. utils.ErrorLog("解析失败:%v", err)
  17222. }
  17223. token := ele.Data.EcToken
  17224. token = Remove0000(token)
  17225. 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)
  17226. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17227. var res ResultTwo
  17228. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17229. utils.ErrorLog("解析失败:%v", err)
  17230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17231. return
  17232. }
  17233. if res.Infcode == 0 {
  17234. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17235. if err == gorm.ErrRecordNotFound {
  17236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17237. return
  17238. } else if err != nil {
  17239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17240. return
  17241. } else {
  17242. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17243. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17244. infoStr := string(Iinfos)
  17245. idetinfoStr := string(Idetinfos)
  17246. psn := &models.HisPsn{
  17247. PsnNo: res.Output.Baseinfo.PsnNo,
  17248. PatientId: patient.ID,
  17249. Certno: res.Output.Baseinfo.Certno,
  17250. Gend: res.Output.Baseinfo.Gend,
  17251. Naty: res.Output.Baseinfo.Naty,
  17252. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17253. PsnName: res.Output.Baseinfo.PsnName,
  17254. Idetinfo: idetinfoStr,
  17255. Insuinfo: infoStr,
  17256. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17257. CardInfo: "",
  17258. VerifyNumber: token,
  17259. }
  17260. service.CreateHisPsn(psn)
  17261. var rf []*ResultFive
  17262. json.Unmarshal([]byte(infoStr), &rf)
  17263. var insutypes []*ResultFive
  17264. var insutype string
  17265. var is390 int = 0
  17266. var is310 int = 0
  17267. for _, item := range rf {
  17268. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17269. insutypes = append(insutypes, item)
  17270. }
  17271. }
  17272. if len(insutypes) == 1 {
  17273. insutype = insutypes[0].Insutype
  17274. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17275. } else {
  17276. for _, i := range insutypes {
  17277. if i.Insutype == "390" {
  17278. is390 = 1
  17279. }
  17280. if i.Insutype == "310" {
  17281. is310 = 1
  17282. }
  17283. }
  17284. }
  17285. if is390 == 1 {
  17286. insutype = "390"
  17287. }
  17288. if is310 == 1 {
  17289. insutype = "310"
  17290. }
  17291. if len(insutypes) == 0 {
  17292. insutype = "310"
  17293. }
  17294. c.ServeSuccessJSON(map[string]interface{}{
  17295. "patient": patient,
  17296. "number": token,
  17297. "insutype": insutype,
  17298. })
  17299. }
  17300. } else {
  17301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17302. return
  17303. }
  17304. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17305. type ELeData struct {
  17306. Code string `json:"code"`
  17307. Data struct {
  17308. Aac002 string `json:"aac002"`
  17309. Aaz500 string `json:"aaz500"`
  17310. ActCardNo string `json:"actCardNo"`
  17311. Bab520 string `json:"bab520"`
  17312. Bkz543 string `json:"bkz543"`
  17313. BusinessType string `json:"businessType"`
  17314. CertfCodg string `json:"certfCodg"`
  17315. EcIndexNo string `json:"ecIndexNo"`
  17316. EcToken string `json:"ecToken"`
  17317. ID0000 string `json:"id0000"`
  17318. IDNo string `json:"idNo"`
  17319. IDType string `json:"idType"`
  17320. Idcode string `json:"idcode"`
  17321. IdentityToken string `json:"identity_token"`
  17322. InsuOrg string `json:"insuOrg"`
  17323. OfficeID string `json:"officeId"`
  17324. OfficeName string `json:"officeName"`
  17325. OperatorID string `json:"operatorId"`
  17326. OperatorName string `json:"operatorName"`
  17327. OrgID string `json:"orgId"`
  17328. UserName string `json:"userName"`
  17329. } `json:"data"`
  17330. Infno interface{} `json:"infno"`
  17331. Message string `json:"message"`
  17332. OrgID string `json:"orgId"`
  17333. TransType string `json:"transType"`
  17334. }
  17335. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17336. outPutInfo = Remove0000(outPutInfo)
  17337. if len(outPutInfo) > 0 {
  17338. var ele ELeData
  17339. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17340. if err != nil {
  17341. utils.ErrorLog("解析失败:%v", err)
  17342. }
  17343. token := ele.Data.EcToken
  17344. fmt.Println(inputInfo)
  17345. fmt.Println(outPutInfo)
  17346. 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)
  17347. saveLog(result, requestLog, "1101", "获取人员信息")
  17348. var dat map[string]interface{}
  17349. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17350. fmt.Println(dat)
  17351. } else {
  17352. fmt.Println(err)
  17353. }
  17354. userJSONBytes, _ := json.Marshal(dat)
  17355. var res ResultTwo
  17356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17357. utils.ErrorLog("解析失败:%v", err)
  17358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17359. return
  17360. }
  17361. res.ErrMsg = errMsgLog
  17362. if res.Infcode == 0 {
  17363. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17364. if err == gorm.ErrRecordNotFound {
  17365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17366. return
  17367. } else if err != nil {
  17368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17369. return
  17370. } else {
  17371. fmt.Println(res)
  17372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17374. infoStr := string(Iinfos)
  17375. idetinfoStr := string(Idetinfos)
  17376. psn := &models.HisPsn{
  17377. PsnNo: res.Output.Baseinfo.PsnNo,
  17378. PatientId: patient.ID,
  17379. Certno: res.Output.Baseinfo.Certno,
  17380. Gend: res.Output.Baseinfo.Gend,
  17381. Naty: res.Output.Baseinfo.Naty,
  17382. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17383. PsnName: res.Output.Baseinfo.PsnName,
  17384. Idetinfo: idetinfoStr,
  17385. Insuinfo: infoStr,
  17386. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17387. CardInfo: outPutInfo,
  17388. VerifyNumber: token,
  17389. InsuplcAdmdvs: ele.Data.InsuOrg,
  17390. }
  17391. service.CreateHisPsn(psn)
  17392. var rf []*ResultFive
  17393. json.Unmarshal([]byte(infoStr), &rf)
  17394. var insutypes []*ResultFive
  17395. var insutype string
  17396. var is390 int = 0
  17397. var is310 int = 0
  17398. for _, item := range rf {
  17399. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17400. insutypes = append(insutypes, item)
  17401. }
  17402. }
  17403. if len(insutypes) == 1 {
  17404. insutype = insutypes[0].Insutype
  17405. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17406. } else {
  17407. for _, i := range insutypes {
  17408. if i.Insutype == "390" {
  17409. is390 = 1
  17410. }
  17411. if i.Insutype == "310" {
  17412. is310 = 1
  17413. }
  17414. }
  17415. }
  17416. if is390 == 1 {
  17417. insutype = "390"
  17418. }
  17419. if is310 == 1 {
  17420. insutype = "310"
  17421. }
  17422. if len(insutypes) == 0 {
  17423. insutype = "310"
  17424. }
  17425. c.ServeSuccessJSON(map[string]interface{}{
  17426. "patient": patient,
  17427. "number": token,
  17428. "insutype": insutype,
  17429. })
  17430. }
  17431. } else {
  17432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17433. return
  17434. }
  17435. }
  17436. } else if miConfig.MdtrtareaAdmvs == "150404" {
  17437. var api string
  17438. 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 +
  17439. "&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
  17440. resp, requestErr := http.Get(api)
  17441. if requestErr != nil {
  17442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17443. return
  17444. }
  17445. body, ioErr := ioutil.ReadAll(resp.Body)
  17446. if ioErr != nil {
  17447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17449. return
  17450. }
  17451. var respJSON map[string]interface{}
  17452. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17455. return
  17456. }
  17457. var status string
  17458. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17459. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17460. var token string
  17461. var res ResultTwo //1101结果
  17462. var res10265 ResultTwo10265 //1101结果
  17463. if status == "0" { //读卡成功
  17464. var card_info string //卡信息
  17465. var busi_card_info string
  17466. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17467. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17468. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17469. fmt.Println(card_info)
  17470. fmt.Println(busi_card_info)
  17471. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17472. result, _ := json.Marshal(respJSON)
  17473. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17474. utils.ErrorLog("解析失败:%v", err)
  17475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17476. return
  17477. }
  17478. res.ErrMsg = res10265.ErrMsg
  17479. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17480. res.Infcode = infocode
  17481. res.Output = res10265.Output
  17482. res.InfRefmsgid = res10265.InfRefmsgid
  17483. if res.Infcode == 0 {
  17484. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17485. if err == gorm.ErrRecordNotFound {
  17486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17487. return
  17488. } else if err != nil {
  17489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17490. return
  17491. } else {
  17492. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17493. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17494. infoStr := string(Iinfos)
  17495. idetinfoStr := string(Idetinfos)
  17496. psn := &models.HisPsn{
  17497. PsnNo: res.Output.Baseinfo.PsnNo,
  17498. PatientId: patient.ID,
  17499. Certno: res.Output.Baseinfo.Certno,
  17500. Gend: res.Output.Baseinfo.Gend,
  17501. Naty: res.Output.Baseinfo.Naty,
  17502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17503. PsnName: res.Output.Baseinfo.PsnName,
  17504. Idetinfo: idetinfoStr,
  17505. Insuinfo: infoStr,
  17506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17507. CardInfo: card_info,
  17508. VerifyNumber: token,
  17509. }
  17510. var rf []*ResultFive
  17511. json.Unmarshal([]byte(infoStr), &rf)
  17512. var insutypes []*ResultFive
  17513. var insutype string
  17514. var is390 int = 0
  17515. var is310 int = 0
  17516. for _, item := range rf {
  17517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17518. insutypes = append(insutypes, item)
  17519. }
  17520. }
  17521. if len(insutypes) == 1 {
  17522. insutype = insutypes[0].Insutype
  17523. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17524. } else {
  17525. for _, i := range insutypes {
  17526. if i.Insutype == "390" {
  17527. is390 = 1
  17528. }
  17529. if i.Insutype == "310" {
  17530. is310 = 1
  17531. }
  17532. }
  17533. }
  17534. if is390 == 1 {
  17535. insutype = "390"
  17536. }
  17537. if is310 == 1 {
  17538. insutype = "310"
  17539. }
  17540. if len(insutypes) == 0 {
  17541. insutype = "310"
  17542. }
  17543. service.CreateHisPsn(psn)
  17544. c.ServeSuccessJSON(map[string]interface{}{
  17545. "patient": patient,
  17546. "number": token,
  17547. "insutype": insutype,
  17548. })
  17549. }
  17550. } else {
  17551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17552. return
  17553. }
  17554. } else { //读卡失败
  17555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17556. return
  17557. }
  17558. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17559. res := c.GetoleInfo()
  17560. if res.Infcode == 0 {
  17561. var result string
  17562. if res.Output.MdtrtCertType == "01" {
  17563. 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)
  17564. } else if res.Output.MdtrtCertType == "02" {
  17565. 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)
  17566. } else if res.Output.MdtrtCertType == "03" {
  17567. 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)
  17568. }
  17569. var dat map[string]interface{}
  17570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17571. fmt.Println(dat)
  17572. } else {
  17573. fmt.Println(err)
  17574. }
  17575. userJSONBytes, _ := json.Marshal(dat)
  17576. var res2 ResultTwo
  17577. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17578. utils.ErrorLog("解析失败:%v", err)
  17579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17580. return
  17581. }
  17582. if res2.Infcode == 0 {
  17583. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17584. if err == gorm.ErrRecordNotFound {
  17585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17586. return
  17587. } else if err != nil {
  17588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17589. return
  17590. } else {
  17591. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17592. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17593. infoStr := string(Iinfos)
  17594. idetinfoStr := string(Idetinfos)
  17595. var rf []*ResultFive
  17596. json.Unmarshal([]byte(infoStr), &rf)
  17597. var insutypes []*ResultFive
  17598. var insutype string
  17599. var is390 int = 0
  17600. var is310 int = 0
  17601. //var insuplc_admdvs string
  17602. for _, item := range rf {
  17603. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17604. insutypes = append(insutypes, item)
  17605. }
  17606. }
  17607. if len(insutypes) == 1 {
  17608. insutype = insutypes[0].Insutype
  17609. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17610. } else {
  17611. for _, i := range insutypes {
  17612. if i.Insutype == "390" {
  17613. is390 = 1
  17614. }
  17615. if i.Insutype == "310" {
  17616. is310 = 1
  17617. }
  17618. }
  17619. }
  17620. if is390 == 1 {
  17621. insutype = "390"
  17622. }
  17623. if is310 == 1 {
  17624. insutype = "310"
  17625. }
  17626. if len(insutypes) == 0 {
  17627. insutype = "310"
  17628. }
  17629. psn := &models.HisPsn{
  17630. PsnNo: res2.Output.Baseinfo.PsnNo,
  17631. PatientId: patient.ID,
  17632. Certno: res2.Output.Baseinfo.Certno,
  17633. Gend: res2.Output.Baseinfo.Gend,
  17634. Naty: res2.Output.Baseinfo.Naty,
  17635. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17636. PsnName: res2.Output.Baseinfo.PsnName,
  17637. Idetinfo: idetinfoStr,
  17638. Insuinfo: infoStr,
  17639. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17640. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17641. VerifyNumber: res.Output.EcToken,
  17642. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17643. }
  17644. if res.Output.MdtrtCertType == "01" {
  17645. psn.VerifyNumber = res.Output.EcToken
  17646. //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)
  17647. } else if res.Output.MdtrtCertType == "02" {
  17648. psn.VerifyNumber = res.Output.CardNo
  17649. //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)
  17650. } else if res.Output.MdtrtCertType == "03" {
  17651. psn.VerifyNumber = res.Output.MdtrtCertNo
  17652. //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)
  17653. }
  17654. service.CreateHisPsn(psn)
  17655. var balc float64
  17656. for _, item := range rf {
  17657. if item.Insutype == insutype {
  17658. balc = item.Balc
  17659. }
  17660. }
  17661. c.ServeSuccessJSON(map[string]interface{}{
  17662. "patient": patient,
  17663. "number": res.Output.CardNo,
  17664. "insutype": insutype,
  17665. "blac": balc,
  17666. "desc": idetinfoStr,
  17667. })
  17668. }
  17669. } else {
  17670. c.ServeSuccessJSON(map[string]interface{}{
  17671. "failed_code": -10,
  17672. "msg": res2.ErrMsg,
  17673. })
  17674. }
  17675. } else {
  17676. c.ServeSuccessJSON(map[string]interface{}{
  17677. "failed_code": -10,
  17678. "msg": res.ErrMsg,
  17679. })
  17680. }
  17681. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17682. var res ResultTwo
  17683. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17684. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17685. "&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)
  17686. resp, requestErr := http.Get(api)
  17687. if requestErr != nil {
  17688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17689. return
  17690. }
  17691. body, ioErr := ioutil.ReadAll(resp.Body)
  17692. if ioErr != nil {
  17693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17695. return
  17696. }
  17697. var respJSON map[string]interface{}
  17698. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17701. return
  17702. }
  17703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17704. result, _ := json.Marshal(respJSON)
  17705. fmt.Println("log")
  17706. fmt.Println(string(result))
  17707. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17708. utils.ErrorLog("解析失败:%v", err)
  17709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17710. return
  17711. }
  17712. if res.Infcode == 0 {
  17713. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17714. if err == gorm.ErrRecordNotFound {
  17715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17716. return
  17717. } else if err != nil {
  17718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17719. return
  17720. } else {
  17721. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17722. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17723. infoStr := string(Iinfos)
  17724. idetinfoStr := string(Idetinfos)
  17725. var rf []*ResultFive
  17726. json.Unmarshal([]byte(infoStr), &rf)
  17727. var insutypes []*ResultFive
  17728. var insutype string
  17729. var is390 int = 0
  17730. var is310 int = 0
  17731. for _, item := range rf {
  17732. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17733. insutypes = append(insutypes, item)
  17734. }
  17735. }
  17736. if len(insutypes) == 1 {
  17737. insutype = insutypes[0].Insutype
  17738. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17739. } else {
  17740. for _, i := range insutypes {
  17741. if i.Insutype == "390" {
  17742. is390 = 1
  17743. }
  17744. if i.Insutype == "310" {
  17745. is310 = 1
  17746. }
  17747. }
  17748. }
  17749. if is390 == 1 {
  17750. insutype = "390"
  17751. }
  17752. if is310 == 1 {
  17753. insutype = "310"
  17754. }
  17755. if len(insutypes) == 0 {
  17756. insutype = "390"
  17757. }
  17758. var insuplc_admdvs string
  17759. for _, item := range rf {
  17760. if item.Insutype == insutype {
  17761. insuplc_admdvs = item.InsuplcAdmdvs
  17762. }
  17763. }
  17764. psn := &models.HisPsn{
  17765. PsnNo: res.Output.Baseinfo.PsnNo,
  17766. PatientId: patient.ID,
  17767. Certno: res.Output.Baseinfo.Certno,
  17768. Gend: res.Output.Baseinfo.Gend,
  17769. Naty: res.Output.Baseinfo.Naty,
  17770. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17771. PsnName: res.Output.Baseinfo.PsnName,
  17772. Idetinfo: idetinfoStr,
  17773. Insuinfo: infoStr,
  17774. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17775. InsuplcAdmdvs: insuplc_admdvs,
  17776. }
  17777. service.CreateHisPsn(psn)
  17778. c.ServeSuccessJSON(map[string]interface{}{
  17779. "patient": patient,
  17780. "number": res.Output.Baseinfo.Certno,
  17781. })
  17782. }
  17783. } else {
  17784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17785. return
  17786. }
  17787. } else {
  17788. type ELeData struct {
  17789. Code string `json:"code"`
  17790. Data struct {
  17791. Aac002 string `json:"aac002"`
  17792. Aaz500 string `json:"aaz500"`
  17793. ActCardNo string `json:"actCardNo"`
  17794. Bab520 string `json:"bab520"`
  17795. Bkz543 string `json:"bkz543"`
  17796. BusinessType string `json:"businessType"`
  17797. CertfCodg string `json:"certfCodg"`
  17798. EcIndexNo string `json:"ecIndexNo"`
  17799. EcToken string `json:"ecToken"`
  17800. ID0000 string `json:"id0000"`
  17801. IDNo string `json:"idNo"`
  17802. IDType string `json:"idType"`
  17803. Idcode string `json:"idcode"`
  17804. IdentityToken string `json:"identity_token"`
  17805. InsuOrg string `json:"insuOrg"`
  17806. OfficeID string `json:"officeId"`
  17807. OfficeName string `json:"officeName"`
  17808. OperatorID string `json:"operatorId"`
  17809. OperatorName string `json:"operatorName"`
  17810. OrgID string `json:"orgId"`
  17811. UserName string `json:"userName"`
  17812. } `json:"data"`
  17813. Infno interface{} `json:"infno"`
  17814. Message string `json:"message"`
  17815. OrgID string `json:"orgId"`
  17816. TransType string `json:"transType"`
  17817. }
  17818. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17819. fmt.Println(result)
  17820. outPutInfo := Remove0000(result)
  17821. fmt.Println(outPutInfo)
  17822. if len(outPutInfo) > 0 {
  17823. var ele ELeData
  17824. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17825. if err != nil {
  17826. utils.ErrorLog("解析失败:%v", err)
  17827. }
  17828. token := ele.Data.EcToken
  17829. fmt.Println(outPutInfo)
  17830. 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)
  17831. saveLog(result, requestLog, "1101", "获取人员信息")
  17832. var dat map[string]interface{}
  17833. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17834. fmt.Println(dat)
  17835. } else {
  17836. fmt.Println(err)
  17837. }
  17838. userJSONBytes, _ := json.Marshal(dat)
  17839. var res ResultTwo
  17840. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17841. utils.ErrorLog("解析失败:%v", err)
  17842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17843. return
  17844. }
  17845. if res.Infcode == 0 {
  17846. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17847. if err == gorm.ErrRecordNotFound {
  17848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17849. return
  17850. } else if err != nil {
  17851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17852. return
  17853. } else {
  17854. fmt.Println(res)
  17855. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17856. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17857. infoStr := string(Iinfos)
  17858. idetinfoStr := string(Idetinfos)
  17859. psn := &models.HisPsn{
  17860. PsnNo: res.Output.Baseinfo.PsnNo,
  17861. PatientId: patient.ID,
  17862. Certno: res.Output.Baseinfo.Certno,
  17863. Gend: res.Output.Baseinfo.Gend,
  17864. Naty: res.Output.Baseinfo.Naty,
  17865. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17866. PsnName: res.Output.Baseinfo.PsnName,
  17867. Idetinfo: idetinfoStr,
  17868. Insuinfo: infoStr,
  17869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17870. CardInfo: outPutInfo,
  17871. VerifyNumber: token,
  17872. InsuplcAdmdvs: ele.Data.InsuOrg,
  17873. }
  17874. service.CreateHisPsn(psn)
  17875. var rf []*ResultFive
  17876. json.Unmarshal([]byte(infoStr), &rf)
  17877. var insutypes []*ResultFive
  17878. var insutype string
  17879. var is390 int = 0
  17880. var is310 int = 0
  17881. for _, item := range rf {
  17882. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17883. insutypes = append(insutypes, item)
  17884. }
  17885. }
  17886. if len(insutypes) == 1 {
  17887. insutype = insutypes[0].Insutype
  17888. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17889. } else {
  17890. for _, i := range insutypes {
  17891. if i.Insutype == "390" {
  17892. is390 = 1
  17893. }
  17894. if i.Insutype == "310" {
  17895. is310 = 1
  17896. }
  17897. }
  17898. }
  17899. if is390 == 1 {
  17900. insutype = "390"
  17901. }
  17902. if is310 == 1 {
  17903. insutype = "310"
  17904. }
  17905. if len(insutypes) == 0 {
  17906. insutype = "310"
  17907. }
  17908. c.ServeSuccessJSON(map[string]interface{}{
  17909. "patient": patient,
  17910. "number": token,
  17911. "insutype": insutype,
  17912. })
  17913. }
  17914. } else {
  17915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17916. return
  17917. }
  17918. }
  17919. //fmt.Println(result)
  17920. //
  17921. //if initFlag == 0 {
  17922. // c.TestGetBasBaseInit()
  17923. //}
  17924. //token := c.GetEleBaseInfo()
  17925. //
  17926. //token = Remove0000(token)
  17927. //
  17928. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17929. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17930. ////
  17931. //var res ResultTwo
  17932. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17933. // utils.ErrorLog("解析失败:%v", err)
  17934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17935. // return
  17936. //}
  17937. //
  17938. //if res.Infcode == 0 {
  17939. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17940. // if err == gorm.ErrRecordNotFound {
  17941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17942. // return
  17943. // } else if err != nil {
  17944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17945. // return
  17946. //
  17947. // } else {
  17948. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17949. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17950. // infoStr := string(Iinfos)
  17951. // idetinfoStr := string(Idetinfos)
  17952. //
  17953. //
  17954. //
  17955. //
  17956. // var rf []*ResultFive
  17957. // json.Unmarshal([]byte(infoStr), &rf)
  17958. //
  17959. // var insutypes []*ResultFive
  17960. // var insutype string
  17961. // var is390 int = 0
  17962. // var is310 int = 0
  17963. // var insuplc_admdvs string
  17964. //
  17965. // for _, item := range rf {
  17966. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17967. // insutypes = append(insutypes, item)
  17968. // }
  17969. // }
  17970. //
  17971. // if len(insutypes) == 1 {
  17972. // insutype = insutypes[0].Insutype
  17973. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17974. // } else {
  17975. // for _, i := range insutypes {
  17976. // if i.Insutype == "390" {
  17977. // is390 = 1
  17978. // }
  17979. //
  17980. // if i.Insutype == "310" {
  17981. // is310 = 1
  17982. // }
  17983. // }
  17984. // }
  17985. // if is390 == 1 {
  17986. // insutype = "390"
  17987. // }
  17988. //
  17989. // if is310 == 1 {
  17990. // insutype = "310"
  17991. // }
  17992. // if len(insutypes) == 0 {
  17993. // insutype = "310"
  17994. // }
  17995. // for _, item := range rf {
  17996. // if item.Insutype == insutype {
  17997. // insuplc_admdvs = item.InsuplcAdmdvs
  17998. // }
  17999. // }
  18000. // psn := &models.HisPsn{
  18001. // PsnNo: res.Output.Baseinfo.PsnNo,
  18002. // Age: res.Output.Baseinfo.Age,
  18003. // PatientId: patient.ID,
  18004. // Certno: res.Output.Baseinfo.Certno,
  18005. // Brdy: res.Output.Baseinfo.Brdy,
  18006. // Gend: res.Output.Baseinfo.Gend,
  18007. // Naty: res.Output.Baseinfo.Naty,
  18008. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  18009. // PsnName: res.Output.Baseinfo.PsnName,
  18010. // Idetinfo: idetinfoStr,
  18011. // Insuinfo: infoStr,
  18012. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18013. // CardInfo: "",
  18014. // VerifyNumber: token,
  18015. // InsuplcAdmdvs: insuplc_admdvs,
  18016. // }
  18017. // service.CreateHisPsn(psn)
  18018. //
  18019. // c.ServeSuccessJSON(map[string]interface{}{
  18020. // "patient": patient,
  18021. // "number": token,
  18022. // })
  18023. // }
  18024. //} else {
  18025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18026. // return
  18027. //}
  18028. }
  18029. break
  18030. case 5:
  18031. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  18032. var api string
  18033. if miConfig.MdtrtareaAdmvs == "320830" {
  18034. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  18035. "&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
  18036. fmt.Println(api)
  18037. } else if miConfig.MdtrtareaAdmvs == "320921" {
  18038. 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 +
  18039. "&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
  18040. fmt.Println(api)
  18041. } else {
  18042. 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 +
  18043. "&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)
  18044. }
  18045. resp, requestErr := http.Get(api)
  18046. if requestErr != nil {
  18047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18048. return
  18049. }
  18050. body, ioErr := ioutil.ReadAll(resp.Body)
  18051. if ioErr != nil {
  18052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18054. return
  18055. }
  18056. var respJSON map[string]interface{}
  18057. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18060. return
  18061. }
  18062. var status string
  18063. status = respJSON["data"].(map[string]interface{})["status"].(string)
  18064. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  18065. var token string
  18066. var res ResultTwo //1101结果
  18067. var res10265 ResultTwo10265 //1101结果
  18068. if status == "0" { //读卡成功
  18069. var card_info string //卡信息
  18070. //var busi_card_info string
  18071. var auth_info string
  18072. token = respJSON["data"].(map[string]interface{})["token"].(string)
  18073. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  18074. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  18075. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  18076. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  18077. result, _ := json.Marshal(respJSON)
  18078. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18079. utils.ErrorLog("解析失败:%v", err)
  18080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18081. return
  18082. }
  18083. res.ErrMsg = res10265.ErrMsg
  18084. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18085. res.Infcode = infocode
  18086. res.Output = res10265.Output
  18087. res.InfRefmsgid = res10265.InfRefmsgid
  18088. if res.Infcode == 0 {
  18089. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  18090. if err == gorm.ErrRecordNotFound {
  18091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18092. return
  18093. } else if err != nil {
  18094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18095. return
  18096. } else {
  18097. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18098. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18099. infoStr := string(Iinfos)
  18100. idetinfoStr := string(Idetinfos)
  18101. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  18102. psn := &models.HisPsn{
  18103. PsnNo: res.Output.Baseinfo.PsnNo,
  18104. PatientId: patient.ID,
  18105. Certno: res.Output.Baseinfo.Certno,
  18106. Gend: res.Output.Baseinfo.Gend,
  18107. Brdy: b,
  18108. Age: float64(age),
  18109. Naty: res.Output.Baseinfo.Naty,
  18110. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18111. PsnName: res.Output.Baseinfo.PsnName,
  18112. Idetinfo: idetinfoStr,
  18113. Insuinfo: infoStr,
  18114. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18115. CardInfo: card_info,
  18116. VerifyNumber: token,
  18117. AuthInfo: auth_info,
  18118. }
  18119. var rf []*ResultFive
  18120. json.Unmarshal([]byte(infoStr), &rf)
  18121. var insutypes []*ResultFive
  18122. var insutype string
  18123. var is390 int = 0
  18124. var is310 int = 0
  18125. for _, item := range rf {
  18126. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18127. insutypes = append(insutypes, item)
  18128. }
  18129. }
  18130. if len(insutypes) == 1 {
  18131. insutype = insutypes[0].Insutype
  18132. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18133. } else {
  18134. for _, i := range insutypes {
  18135. if i.Insutype == "390" {
  18136. is390 = 1
  18137. }
  18138. if i.Insutype == "310" {
  18139. is310 = 1
  18140. }
  18141. }
  18142. }
  18143. if is390 == 1 {
  18144. insutype = "390"
  18145. }
  18146. if is310 == 1 {
  18147. insutype = "310"
  18148. }
  18149. if len(insutypes) == 0 {
  18150. insutype = "310"
  18151. }
  18152. service.CreateHisPsn(psn)
  18153. c.ServeSuccessJSON(map[string]interface{}{
  18154. "patient": patient,
  18155. "number": token,
  18156. "insutype": insutype,
  18157. })
  18158. }
  18159. } else {
  18160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18161. return
  18162. }
  18163. } else { //读卡失败
  18164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18165. return
  18166. }
  18167. }
  18168. break
  18169. }
  18170. }
  18171. var initFlag int64 = 0
  18172. var initEleFlag int64 = 0
  18173. func (c *HisApiController) TestGetBasBaseInit() {
  18174. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18175. Iinit := DllDef.MustFindProc("Init")
  18176. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18177. url := ""
  18178. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18179. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18180. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18181. url = ""
  18182. } else {
  18183. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18184. }
  18185. fmt.Println("SSCard的报错原因:", url)
  18186. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18187. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18188. if ret != 0 {
  18189. fmt.Println("SSCard的报错原因:", err)
  18190. fmt.Println("SSCard的运算结果为:", ret)
  18191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18192. return
  18193. }
  18194. result := int(ret)
  18195. fmt.Println("SSCard的运算结果为1:", result)
  18196. initFlag = 1
  18197. return
  18198. }
  18199. func (c *HisApiController) HandleJiangXiReadCard() {
  18200. fmt.Println("~~~~~~")
  18201. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18202. admin_user_id, _ := c.GetInt64("admin_user_id")
  18203. id_card_type, _ := c.GetInt64("id_card_type")
  18204. //certificates, _ := c.GetInt64("certificates")
  18205. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18206. if initFlag == 0 {
  18207. c.TestGetJiangXiBasBaseInit()
  18208. }
  18209. basStr := c.GetBasBaseInfo()
  18210. if len(basStr) == 0 {
  18211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18212. return
  18213. }
  18214. fmt.Println(basStr)
  18215. bas := strings.Split(basStr, "|")
  18216. basNumber := bas[1]
  18217. fmt.Println(basNumber)
  18218. card_sn := bas[3]
  18219. fmt.Println(card_sn)
  18220. 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, "")
  18221. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18222. var dat map[string]interface{}
  18223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18224. fmt.Println(dat)
  18225. } else {
  18226. fmt.Println(err)
  18227. }
  18228. userJSONBytes, _ := json.Marshal(dat)
  18229. var res ResultTwo
  18230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18231. utils.ErrorLog("解析失败:%v", err)
  18232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18233. return
  18234. }
  18235. if res.Infcode == 0 {
  18236. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18237. if err == gorm.ErrRecordNotFound {
  18238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18239. return
  18240. } else if err != nil {
  18241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18242. return
  18243. } else {
  18244. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18245. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18246. infoStr := string(Iinfos)
  18247. idetinfoStr := string(Idetinfos)
  18248. psn := &models.HisPsn{
  18249. PsnNo: res.Output.Baseinfo.PsnNo,
  18250. PatientId: patient.ID,
  18251. Certno: res.Output.Baseinfo.Certno,
  18252. Gend: res.Output.Baseinfo.Gend,
  18253. Naty: res.Output.Baseinfo.Naty,
  18254. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18255. PsnName: res.Output.Baseinfo.PsnName,
  18256. Idetinfo: idetinfoStr,
  18257. Insuinfo: infoStr,
  18258. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18259. CardInfo: basStr,
  18260. VerifyNumber: "",
  18261. }
  18262. service.CreateHisPsn(psn)
  18263. c.ServeSuccessJSON(map[string]interface{}{
  18264. "patient": patient,
  18265. "number": basNumber,
  18266. })
  18267. }
  18268. } else {
  18269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18270. return
  18271. }
  18272. }
  18273. func (c *HisApiController) TestGetHnBasBaseInit() {
  18274. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18275. Iinit := DllDef.MustFindProc("Init")
  18276. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18277. //http://10.77.211.236/CSB/hsa-fsi-1303
  18278. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18279. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18280. // 调用 Init 函数
  18281. 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"))))
  18282. //if ret != 0 {
  18283. fmt.Println("SSCard的报错原因:", err)
  18284. fmt.Println("SSCard的运算结果为:", ret)
  18285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18286. // return
  18287. //}
  18288. result := int(ret)
  18289. fmt.Println("SSCard的运算结果为1:", result)
  18290. initFlag = 1
  18291. return
  18292. }
  18293. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18294. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18295. Iinit := DllDef.MustFindProc("Init")
  18296. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18297. //http://10.77.211.236/CSB/hsa-fsi-1303
  18298. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18299. if ret != 0 {
  18300. fmt.Println("SSCard的报错原因:", err)
  18301. fmt.Println("SSCard的运算结果为:", ret)
  18302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18303. return
  18304. }
  18305. result := int(ret)
  18306. fmt.Println("SSCard的运算结果为1:", result)
  18307. initFlag = 1
  18308. return
  18309. }
  18310. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18311. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18312. Iinit := DllDef.MustFindProc("Init")
  18313. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18314. //http://10.77.211.236/CSB/hsa-fsi-1303
  18315. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18316. if ret != 0 {
  18317. fmt.Println("SSCard的报错原因:", err)
  18318. fmt.Println("SSCard的运算结果为:", ret)
  18319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18320. return
  18321. }
  18322. result := int(ret)
  18323. fmt.Println("SSCard的运算结果为1:", result)
  18324. initFlag = 1
  18325. return
  18326. }
  18327. func (c *HisApiController) GetSFZBaseInfo() string {
  18328. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18329. readCard := DllDef.MustFindProc("ReadSFZ")
  18330. if readCard == nil {
  18331. fmt.Println("readcard is nil")
  18332. readCard = DllDef.MustFindProc("ReadSFZ")
  18333. }
  18334. str := make([]byte, 8096)
  18335. str1 := make([]byte, 8096)
  18336. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18337. fmt.Println(r)
  18338. return Remove0000(string(str))
  18339. }
  18340. func (c *HisApiController) GetEleBaseInfo() string {
  18341. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18342. readCard := DllDef.MustFindProc("GetQRBase")
  18343. fmt.Println(readCard)
  18344. if readCard == nil {
  18345. fmt.Println("readcard is nil")
  18346. readCard = DllDef.MustFindProc("GetQRBase")
  18347. }
  18348. str := make([]byte, 1024)
  18349. str1 := make([]byte, 1024)
  18350. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18351. fmt.Println(ret2)
  18352. fmt.Println(string(str1))
  18353. fmt.Println(string(str))
  18354. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18355. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18356. if ret2 != 0 {
  18357. return ""
  18358. }
  18359. return string(str)
  18360. }
  18361. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18362. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18363. readCard := DllDef.MustFindProc("NationEcTrans")
  18364. fmt.Println(readCard)
  18365. fmt.Println("!!!!!")
  18366. pBusiCardInfo := make([]byte, 2048)
  18367. input := make(map[string]interface{})
  18368. inputData := make(map[string]interface{})
  18369. inputData["orgId"] = code
  18370. inputData["businessType"] = "01101"
  18371. inputData["operatorId"] = "1"
  18372. inputData["operatorName"] = "admin"
  18373. inputData["officeId"] = "001"
  18374. inputData["officeName"] = "血透室"
  18375. inputData["deviceType"] = ""
  18376. input["data"] = inputData
  18377. input["orgId"] = code
  18378. input["transType"] = "ec.query"
  18379. bytesData, _ := json.Marshal(input)
  18380. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18381. fmt.Println(ret2)
  18382. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18383. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18384. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18385. }
  18386. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18387. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18388. readCard := DllDef.MustFindProc("NationEcTrans")
  18389. fmt.Println(readCard)
  18390. fmt.Println("!!!!!")
  18391. pBusiCardInfo := make([]byte, 2048)
  18392. input := make(map[string]interface{})
  18393. inputData := make(map[string]interface{})
  18394. inputData["orgId"] = code
  18395. inputData["businessType"] = "01101"
  18396. inputData["operatorId"] = "9"
  18397. inputData["operatorName"] = "admin"
  18398. inputData["officeId"] = "001"
  18399. inputData["officeName"] = "血透室"
  18400. inputData["deviceType"] = ""
  18401. input["data"] = inputData
  18402. input["orgId"] = code
  18403. input["transType"] = "ec.query"
  18404. bytesData, _ := json.Marshal(input)
  18405. 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])))
  18406. fmt.Println(ret2)
  18407. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18408. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18409. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18410. }
  18411. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18412. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18413. readCard := DllDef.MustFindProc("NationEcTrans")
  18414. fmt.Println(readCard)
  18415. fmt.Println("!!!!!")
  18416. pBusiCardInfo := make([]byte, 2048)
  18417. input := make(map[string]interface{})
  18418. inputData := make(map[string]interface{})
  18419. inputData["orgId"] = code
  18420. inputData["businessType"] = "01301"
  18421. inputData["operatorId"] = "9"
  18422. inputData["operatorName"] = "admin"
  18423. inputData["officeId"] = "001"
  18424. inputData["officeName"] = "血透室"
  18425. inputData["deviceType"] = ""
  18426. input["data"] = inputData
  18427. input["orgId"] = code
  18428. input["transType"] = "ec.query"
  18429. bytesData, _ := json.Marshal(input)
  18430. 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])))
  18431. fmt.Println(ret2)
  18432. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18433. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18434. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18435. }
  18436. func GetJxEleBaseInfo(org_id int64) string {
  18437. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18438. readCard := DllDef.MustFindProc("NationEcTrans")
  18439. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18440. if readCard == nil {
  18441. fmt.Println("readcard is nil")
  18442. readCard = DllDef.MustFindProc("NationEcTrans")
  18443. }
  18444. str1 := make([]byte, 1024)
  18445. data := make(map[string]interface{})
  18446. inputData := make(map[string]interface{})
  18447. inputData["orgId"] = miConfig.Code
  18448. inputData["businessType"] = "01101"
  18449. inputData["operatorId"] = "test001"
  18450. inputData["operatorName"] = "cn"
  18451. inputData["officeId"] = "32760"
  18452. inputData["officeName"] = "waike"
  18453. inputData["deviceType"] = ""
  18454. data["data"] = inputData
  18455. data["transType"] = "ec.query"
  18456. data["extra "] = ""
  18457. data["orgId"] = miConfig.Code
  18458. bytesData, _ := json.Marshal(data)
  18459. //bytesData, _ := json.Marshal(data)
  18460. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18461. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18462. fmt.Println(ret2)
  18463. fmt.Println(string(str1))
  18464. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18465. if ret2 != 0 {
  18466. return ""
  18467. }
  18468. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18469. }
  18470. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18471. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18472. // readCard := DllDef.MustFindProc("NationEcTrans")
  18473. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18474. //
  18475. // if readCard == nil {
  18476. // fmt.Println("readcard is nil")
  18477. // readCard = DllDef.MustFindProc("NationEcTrans")
  18478. // }
  18479. // str1 := make([]byte, 1024)
  18480. //
  18481. // data := make(map[string]interface{})
  18482. //
  18483. // inputData := make(map[string]interface{})
  18484. // inputData["orgId"] = miConfig.Code
  18485. // inputData["businessType"] = "01101"
  18486. // inputData["operatorId"] = "test001"
  18487. // inputData["operatorName"] = "cn"
  18488. // inputData["officeId"] = "32760"
  18489. // inputData["officeName"] = "waike"
  18490. // inputData["deviceType"] = ""
  18491. //
  18492. // data["data"] = inputData
  18493. // data["transType"] = "ec.query"
  18494. // data["extra "] = ""
  18495. // data["orgId"] = miConfig.Code
  18496. // bytesData, _ := json.Marshal(data)
  18497. // //bytesData, _ := json.Marshal(data)
  18498. //
  18499. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18500. //
  18501. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18502. // fmt.Println(ret2)
  18503. // fmt.Println(string(str1))
  18504. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18505. //
  18506. // if ret2 != 0 {
  18507. // return ""
  18508. // }
  18509. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18510. //}
  18511. func GetJxEleBaseInitInfo(org_id int64) string {
  18512. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18513. readCard := DllDef.MustFindProc("NationEcTrans")
  18514. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18515. if readCard == nil {
  18516. fmt.Println("readcard is nil")
  18517. readCard = DllDef.MustFindProc("NationEcTrans")
  18518. }
  18519. str1 := make([]byte, 2048)
  18520. data := make(map[string]interface{})
  18521. inputData := make(map[string]interface{})
  18522. inputData["orgId"] = miConfig.Code
  18523. inputData["businessType"] = "01101"
  18524. inputData["operatorId"] = "1"
  18525. inputData["operatorName"] = "huangchuang"
  18526. inputData["officeId"] = "101"
  18527. inputData["officeName"] = "xuetou"
  18528. inputData["deviceType"] = ""
  18529. data["data"] = inputData
  18530. data["transType"] = "ec.query"
  18531. data["orgId"] = miConfig.Code
  18532. bytesData, _ := json.Marshal(data)
  18533. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18534. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18535. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18536. fmt.Println(ret2)
  18537. fmt.Println(string(str1))
  18538. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18539. if ret2 != 0 {
  18540. return ""
  18541. }
  18542. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18543. initEleFlag = 1
  18544. }
  18545. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18546. }
  18547. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18548. // // 构建命令
  18549. // cmd := exec.Command("python", "b.py")
  18550. //
  18551. // // 执行命令并等待完成
  18552. // output, err := cmd.CombinedOutput()
  18553. // if err != nil {
  18554. // fmt.Println("Error executing Python script:", err)
  18555. // return
  18556. // }
  18557. //
  18558. // // 打印Python脚本的输出
  18559. // fmt.Println(string(output))
  18560. //}
  18561. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18562. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18563. readCard := DllDef.MustFindProc("gxyb_call")
  18564. if readCard == nil {
  18565. fmt.Println("readcard is nil")
  18566. readCard = DllDef.MustFindProc("gxyb_call")
  18567. }
  18568. str := make([]byte, 1024)
  18569. str1 := make([]byte, 1024)
  18570. //data := make(map[string]interface{})
  18571. currentTime := time.Now()
  18572. // 格式化时间为 "YYYYMMDDHH24MISS"
  18573. formattedTime := currentTime.Format("20060102150405")
  18574. inputData := make(map[string]interface{})
  18575. inputData2 := make(map[string]interface{})
  18576. inputData["transNo"] = "1401"
  18577. inputData["transType"] = "passwordCheck"
  18578. inputData["timestamp"] = formattedTime
  18579. inputData2["fixmedinsCode"] = code
  18580. inputData2["psnNo"] = ""
  18581. inputData["data"] = inputData2
  18582. jsonBytes, err := json.Marshal(inputData)
  18583. if err != nil {
  18584. fmt.Println("Error encoding map to JSON:", err)
  18585. }
  18586. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18587. fmt.Println(string(str1))
  18588. fmt.Println(string(str))
  18589. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18590. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18591. if ret2 != 0 {
  18592. return ""
  18593. }
  18594. return string(str)
  18595. }
  18596. func (c *HisApiController) GetoleInfo() Response {
  18597. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18598. defer ole.CoUninitialize()
  18599. // Replace with the ProgID or CLSID of your COM object
  18600. progID := "YinHai.XJ.Actual.Interface.New"
  18601. // Create COM object
  18602. unknown, err := oleutil.CreateObject(progID)
  18603. if err != nil {
  18604. fmt.Println("Unable to create COM object:", err)
  18605. }
  18606. defer unknown.Release()
  18607. // Query for the IDispatch interface
  18608. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18609. if err != nil {
  18610. fmt.Println("Unable to get IDispatch interface:", err)
  18611. }
  18612. defer dispatch.Release()
  18613. // Prepare parameters
  18614. transNo := "1401"
  18615. transType := "passwordCheck"
  18616. timestamp := time.Now().Unix()
  18617. fixmedinsCode := "H45072101171"
  18618. psnNo := ""
  18619. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18620. result2 := ""
  18621. // Call COM object's method using the IDispatch interface
  18622. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18623. fmt.Println(resulr)
  18624. fmt.Println(result2)
  18625. if err != nil {
  18626. fmt.Println("调用COM对象方法失败:", err)
  18627. }
  18628. var response Response
  18629. err2 := json.Unmarshal([]byte(result2), &response)
  18630. if err2 != nil {
  18631. fmt.Println("解析JSON失败:", err)
  18632. }
  18633. return response
  18634. }
  18635. func (c *HisApiController) GetBasBaseInfo() string {
  18636. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18637. readCard := DllDef.MustFindProc("ReadCardBas")
  18638. if readCard == nil {
  18639. fmt.Println("readcard is nil")
  18640. readCard = DllDef.MustFindProc("ReadCardBas")
  18641. }
  18642. str := make([]byte, 1024)
  18643. str1 := make([]byte, 1024)
  18644. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18645. fmt.Println(string(str1))
  18646. fmt.Println(string(str))
  18647. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18648. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18649. if ret2 != 0 {
  18650. return ""
  18651. }
  18652. return string(str)
  18653. }
  18654. type Program struct {
  18655. FunctionID string `xml:"function_id"`
  18656. CardInfo string `xml:"cardinfo"`
  18657. User string `xml:"user"`
  18658. }
  18659. func (c *HisApiController) GetBasBaseInfo1111() string {
  18660. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18661. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18662. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18663. if readCard == nil {
  18664. fmt.Println("readcard is nil")
  18665. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18666. }
  18667. if readCard2 == nil {
  18668. fmt.Println("readcard is nil")
  18669. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18670. }
  18671. str := make([]byte, 1024)
  18672. str1 := make([]byte, 1024)
  18673. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18674. str3 := make([]byte, 1024)
  18675. str4 := make([]byte, 1024)
  18676. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18677. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18678. //if err != nil {
  18679. // fmt.Println("Error opening file:", err)
  18680. //}
  18681. //defer file.Close()
  18682. //
  18683. //var lastProgram Program
  18684. //scanner := bufio.NewScanner(file)
  18685. //inProgram := false
  18686. //
  18687. //for scanner.Scan() {
  18688. // line := scanner.Text()
  18689. // if strings.Contains(line, "<program>") {
  18690. // inProgram = true
  18691. // programXML := "<program>"
  18692. // for scanner.Scan() {
  18693. // line = scanner.Text()
  18694. // programXML += line
  18695. // if strings.Contains(line, "</program>") {
  18696. // programXML += "</program>"
  18697. // break
  18698. // }
  18699. // }
  18700. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18701. // // 解析成功,更新最后的 Program
  18702. // }
  18703. // inProgram = false
  18704. // }
  18705. //}
  18706. //
  18707. // fmt.Println("Error reading file:", inProgram)
  18708. //
  18709. //if err := scanner.Err(); err != nil {
  18710. // fmt.Println("Error reading file:", err)
  18711. //}
  18712. // 输出最后一次的 Program
  18713. //fmt.Printf("最后一次的 <program>:\n")
  18714. //fmt.Printf("<program>\n")
  18715. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18716. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18717. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18718. //fmt.Printf("</program>\n")
  18719. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18720. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18721. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18722. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18723. return ConvertToString(string(str), "gbk", "utf-8")
  18724. }
  18725. func (c *HisApiController) GetBasBaseInfo22222() string {
  18726. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18727. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18728. if readCard == nil {
  18729. fmt.Println("readcard is nil")
  18730. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18731. }
  18732. str := make([]byte, 1024)
  18733. str1 := make([]byte, 1024)
  18734. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18735. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18736. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18737. //if err != nil {
  18738. // fmt.Println("Error opening file:", err)
  18739. //}
  18740. //defer file.Close()
  18741. //
  18742. //var lastProgram Program
  18743. //scanner := bufio.NewScanner(file)
  18744. //inProgram := false
  18745. //
  18746. //for scanner.Scan() {
  18747. // line := scanner.Text()
  18748. // if strings.Contains(line, "<program>") {
  18749. // inProgram = true
  18750. // programXML := "<program>"
  18751. // for scanner.Scan() {
  18752. // line = scanner.Text()
  18753. // programXML += line
  18754. // if strings.Contains(line, "</program>") {
  18755. // programXML += "</program>"
  18756. // break
  18757. // }
  18758. // }
  18759. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18760. // // 解析成功,更新最后的 Program
  18761. // }
  18762. // inProgram = false
  18763. // }
  18764. //}
  18765. //
  18766. // fmt.Println("Error reading file:", inProgram)
  18767. //
  18768. //if err := scanner.Err(); err != nil {
  18769. // fmt.Println("Error reading file:", err)
  18770. //}
  18771. // 输出最后一次的 Program
  18772. //fmt.Printf("最后一次的 <program>:\n")
  18773. //fmt.Printf("<program>\n")
  18774. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18775. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18776. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18777. //fmt.Printf("</program>\n")
  18778. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18779. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18780. return ConvertToString(string(str1), "gbk", "utf-8")
  18781. }
  18782. func (c *HisApiController) GetahBasBaseInfo() string {
  18783. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18784. readCard := DllDef.MustFindProc("iReadCardBas")
  18785. if readCard == nil {
  18786. fmt.Println("readcard is nil")
  18787. readCard = DllDef.MustFindProc("iReadCardBas")
  18788. }
  18789. //str := make([]byte, 1024)
  18790. str1 := make([]byte, 1024)
  18791. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18792. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18793. //if err != nil {
  18794. // fmt.Println("Error opening file:", err)
  18795. //}
  18796. //defer file.Close()
  18797. //
  18798. //var lastProgram Program
  18799. //scanner := bufio.NewScanner(file)
  18800. //inProgram := false
  18801. //
  18802. //for scanner.Scan() {
  18803. // line := scanner.Text()
  18804. // if strings.Contains(line, "<program>") {
  18805. // inProgram = true
  18806. // programXML := "<program>"
  18807. // for scanner.Scan() {
  18808. // line = scanner.Text()
  18809. // programXML += line
  18810. // if strings.Contains(line, "</program>") {
  18811. // programXML += "</program>"
  18812. // break
  18813. // }
  18814. // }
  18815. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18816. // // 解析成功,更新最后的 Program
  18817. // }
  18818. // inProgram = false
  18819. // }
  18820. //}
  18821. //
  18822. // fmt.Println("Error reading file:", inProgram)
  18823. //
  18824. //if err := scanner.Err(); err != nil {
  18825. // fmt.Println("Error reading file:", err)
  18826. //}
  18827. // 输出最后一次的 Program
  18828. //fmt.Printf("最后一次的 <program>:\n")
  18829. //fmt.Printf("<program>\n")
  18830. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18831. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18832. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18833. //fmt.Printf("</program>\n")
  18834. fmt.Println(string(str1))
  18835. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18836. if ret2 != 0 {
  18837. return ""
  18838. }
  18839. return string(str1)
  18840. }
  18841. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18842. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18843. readCard := DllDef.MustFindProc("read_cardinfo")
  18844. if readCard == nil {
  18845. fmt.Println("readcard is nil")
  18846. readCard = DllDef.MustFindProc("read_cardinfo")
  18847. }
  18848. str := make([]byte, 1024) //卡号
  18849. str1 := make([]byte, 1024) //卡识别码
  18850. str2 := make([]byte, 1024) //身份证号
  18851. str3 := make([]byte, 1024) //姓名
  18852. str4 := make([]byte, 1024) //错误信息
  18853. 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])))
  18854. fmt.Println(string(str1))
  18855. fmt.Println(string(str))
  18856. fmt.Println(string(str2))
  18857. fmt.Println(string(str3))
  18858. fmt.Println(string(str4))
  18859. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18860. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18861. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18862. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18863. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18864. if ret2 != 0 {
  18865. return "", "", "", "", ""
  18866. }
  18867. return string(str), string(str1), string(str2), string(str3), string(str4)
  18868. }
  18869. type CustomFundPay struct {
  18870. FundPayType string `json:"fund_pay_type"`
  18871. FundPayamt float64 `json:"fund_payamt"`
  18872. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18873. }
  18874. //func (c *HisApiController) GetBatchSettleList() {
  18875. // start_time_str := c.GetString("start_time")
  18876. // //end_time_str := c.GetString("end_time")
  18877. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18878. //
  18879. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18880. //
  18881. // for _, item := range orders {
  18882. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18883. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18884. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18885. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18886. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18887. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18888. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18889. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18890. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18891. //
  18892. // if order.ID == 0 {
  18893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18894. // return
  18895. // }
  18896. //
  18897. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18898. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18899. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18900. // //fmt.Println(count)
  18901. // //var zero string
  18902. // //number := count + 1
  18903. // //if number >= 1000 {
  18904. // // zero = "0000" + strconv.FormatInt(number, 10)
  18905. // //} else if number >= 10000 {
  18906. // // zero = "000" + strconv.FormatInt(number, 10)
  18907. // //} else if number >= 100000 {
  18908. // // zero = "00" + strconv.FormatInt(number, 10)
  18909. // //} else if number >= 1000000 {
  18910. // // zero = "0" + strconv.FormatInt(number, 10)
  18911. // //} else {
  18912. // // zero = strconv.FormatInt(number, 10)
  18913. // //}
  18914. // //fmt.Println(zero)
  18915. //
  18916. // struct4101 := service.Struct4101{
  18917. // PsnNo: order.PsnNo,
  18918. // MdtrtId: order.MdtrtId,
  18919. // SetlId: order.SetlId,
  18920. // PsnName: order.PsnName,
  18921. // Gend: order.Gend,
  18922. // Brdy: his.Brdy,
  18923. // Age: his.Age,
  18924. // Naty: order.Naty,
  18925. // PatnCertType: "01",
  18926. // Certno: order.Certno,
  18927. // Prfs: "90",
  18928. // ConerName: roles[0].UserName,
  18929. // PatnRlts: "99",
  18930. // ConerAddr: miConfig.OrgName,
  18931. // ConerTel: admin.Mobile,
  18932. // HiType: order.Insutype,
  18933. // Insuplc: miConfig.InsuplcAdmdvs,
  18934. // MaindiagFlag: "1",
  18935. // BillCode: order.SetlId,
  18936. // BillNo: order.SetlId,
  18937. // BizSn: order.Number,
  18938. // PsnSelfPay: order.PsnPartAmt,
  18939. // PsnOwnPay: order.PsnPartAmt,
  18940. // AcctPay: order.AcctPay,
  18941. // PsnCashpay: order.PsnCashPay,
  18942. // HiPaymtd: "1",
  18943. // Hsorg: miConfig.InsuplcAdmdvs,
  18944. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18945. // MedinsFillPsn: curRoles.UserName,
  18946. // MedinsFillDept: miConfig.OrgName,
  18947. // IptMedType: "2",
  18948. // }
  18949. // struct4101.SetlBegnDate = order.SetlTime
  18950. // struct4101.SetlEndDate = order.SetlTime
  18951. // time_arr := strings.Split(order.SetlTime, " ")
  18952. // struct4101.AdmTime = time_arr[0]
  18953. // struct4101.AdmEndTime = time_arr[0]
  18954. //
  18955. // var rf []CustomFundPay
  18956. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18957. //
  18958. // var tempFunPays []service.CustomStruct
  18959. // for _, item := range rf {
  18960. // var tempFunPay service.CustomStruct
  18961. // tempFunPay.FundPayamt = item.FundPayamt
  18962. // tempFunPay.FundPayType = item.FundPayType
  18963. // tempFunPays = append(tempFunPays, tempFunPay)
  18964. // }
  18965. // struct4101.CustomStruct = tempFunPays
  18966. //
  18967. // var tempDiaginfos []service.DiaginfoStructTwo
  18968. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18969. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18970. //
  18971. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18972. // var config []*models.HisXtDiagnoseConfig
  18973. // for _, item := range diagnosis_ids {
  18974. // id, _ := strconv.ParseInt(item, 10, 64)
  18975. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18976. // config = append(config, &diagnosisConfig)
  18977. // }
  18978. //
  18979. // for index, item := range config {
  18980. // if index == 0 {
  18981. // var tempDiaginfo service.DiaginfoStructTwo
  18982. // tempDiaginfo.DiagCode = item.CountryCode
  18983. // tempDiaginfo.DiagName = item.CountryContentName
  18984. // tempDiaginfo.DiagType = "1"
  18985. // tempDiaginfo.MaindiagFlag = "1"
  18986. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18987. // } else {
  18988. // var tempDiaginfo service.DiaginfoStructTwo
  18989. // tempDiaginfo.DiagCode = item.CountryCode
  18990. // tempDiaginfo.DiagName = item.CountryContentName
  18991. // tempDiaginfo.DiagType = "1"
  18992. // tempDiaginfo.MaindiagFlag = "0"
  18993. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18994. // }
  18995. // }
  18996. // struct4101.Diseinfo = tempDiaginfos
  18997. //
  18998. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18999. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19000. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19001. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19002. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19003. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19004. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19005. //
  19006. // var iteminfo service.IteminfoStruct
  19007. //
  19008. // var bedCostTotal float64 = 0 //床位总费
  19009. // var bedCostSelfTotal float64 = 0 //床位自费
  19010. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19011. //
  19012. // var operationCostTotal float64 = 0 //手术费
  19013. // var operationCostSelfTotal float64 = 0 //手术费
  19014. // var operationCostPartSelfTotal float64 = 0 //手术费
  19015. //
  19016. // var otherCostTotal float64 = 0 //其他费用
  19017. // var otherCostSelfTotal float64 = 0 //其他费用
  19018. // var otherCostPartSelfTotal float64 = 0 //其他费用
  19019. //
  19020. // var materialCostTotal float64 = 0 //材料费
  19021. // var materialCostSelfTotal float64 = 0 //材料费
  19022. // var materialCostPartSelfTotal float64 = 0 //材料费
  19023. //
  19024. // var westernMedicineCostTotal float64 = 0 //西药费
  19025. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  19026. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19027. //
  19028. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19029. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19030. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19031. //
  19032. // var checkCostTotal float64 = 0 //检查费
  19033. // var checkCostSelfTotal float64 = 0 //检查费
  19034. // var checkCostPartSelfTotal float64 = 0 //检查费
  19035. //
  19036. // var laboratoryCostTotal float64 = 0 //化验费
  19037. // var laboratoryCostSelfTotal float64 = 0 //化验费
  19038. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19039. //
  19040. // var treatCostTotal float64 = 0 //治疗费用
  19041. // var treatCostSelfTotal float64 = 0 //治疗费用
  19042. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  19043. //
  19044. // decimal.DivisionPrecision = 2
  19045. //
  19046. // var bed_fulamt_ownpay_amt float64 = 0
  19047. // var operation_fulamt_ownpay_amt float64 = 0
  19048. // var other_fulamt_ownpay_amt float64 = 0
  19049. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  19050. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19051. // var check_fulamt_ownpay_amt float64 = 0
  19052. // var material_fulamt_ownpay_amt float64 = 0
  19053. // var laboratory_fulamt_ownpay_amt float64 = 0
  19054. // var treat_fulamt_ownpay_amt float64 = 0
  19055. //
  19056. // var bed_claa_sunmfee float64 = 0
  19057. // var bed_clab_amt float64 = 0
  19058. // var bed_other_amt float64 = 0
  19059. //
  19060. // var operation_claa_sunmfee float64 = 0
  19061. // var operation_clab_amt float64 = 0
  19062. // var operation_other_amt float64 = 0
  19063. //
  19064. // var other_claa_sunmfee float64 = 0
  19065. // var other_clab_amt float64 = 0
  19066. // var other_other_amt float64 = 0
  19067. //
  19068. // var westernMedicine_claa_sunmfee float64 = 0
  19069. // var westernMedicine_clab_amt float64 = 0
  19070. // var westernMedicine_other_amt float64 = 0
  19071. //
  19072. // var chineseTraditional_claa_sunmfee float64 = 0
  19073. // var chineseTraditional_clab_amt float64 = 0
  19074. // var chineseTraditional_other_amt float64 = 0
  19075. //
  19076. // var check_claa_sunmfee float64 = 0
  19077. // var check_clab_amt float64 = 0
  19078. // var check_other_amt float64 = 0
  19079. //
  19080. // var material_claa_sunmfee float64 = 0
  19081. // var material_clab_amt float64 = 0
  19082. // var material_other_amt float64 = 0
  19083. //
  19084. // var laboratory_claa_sunmfee float64 = 0
  19085. // var laboratory_clab_amt float64 = 0
  19086. // var laboratory_other_amt float64 = 0
  19087. //
  19088. // var treat_claa_sunmfee float64 = 0
  19089. // var treat_clab_amt float64 = 0
  19090. // var treat_other_amt float64 = 0
  19091. //
  19092. // for _, item := range order.HisOrderInfo {
  19093. // if item.MedChrgitmType == "01" { //床位费
  19094. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19095. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19096. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19097. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19098. // if item.ChrgitmLv == "1" {
  19099. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19100. // }
  19101. // if item.ChrgitmLv == "2" {
  19102. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19103. //
  19104. // }
  19105. // if item.ChrgitmLv == "3" {
  19106. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19107. // }
  19108. //
  19109. // }
  19110. //
  19111. // if item.MedChrgitmType == "03" { //检查费
  19112. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19113. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19114. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19115. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19116. // if item.ChrgitmLv == "1" {
  19117. //
  19118. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19119. //
  19120. // }
  19121. // if item.ChrgitmLv == "2" {
  19122. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19123. //
  19124. // }
  19125. // if item.ChrgitmLv == "3" {
  19126. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19127. // }
  19128. // }
  19129. //
  19130. // if item.MedChrgitmType == "04" { //化验费
  19131. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19132. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19133. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19134. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19135. // if item.ChrgitmLv == "1" {
  19136. //
  19137. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19138. //
  19139. // }
  19140. // if item.ChrgitmLv == "2" {
  19141. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19142. //
  19143. // }
  19144. // if item.ChrgitmLv == "3" {
  19145. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19146. // }
  19147. // }
  19148. //
  19149. // if item.MedChrgitmType == "05" { //治疗费
  19150. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19151. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19152. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19153. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19154. // if item.ChrgitmLv == "1" {
  19155. //
  19156. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19157. //
  19158. // }
  19159. // if item.ChrgitmLv == "2" {
  19160. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19161. //
  19162. // }
  19163. // if item.ChrgitmLv == "3" {
  19164. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19165. // }
  19166. // }
  19167. //
  19168. // if item.MedChrgitmType == "06" { //手术费
  19169. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19170. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19171. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19172. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19173. //
  19174. // if item.ChrgitmLv == "1" {
  19175. //
  19176. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19177. //
  19178. // }
  19179. // if item.ChrgitmLv == "2" {
  19180. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19181. //
  19182. // }
  19183. // if item.ChrgitmLv == "3" {
  19184. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19185. // }
  19186. // }
  19187. //
  19188. // if item.MedChrgitmType == "08" { //材料费
  19189. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19190. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19191. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19192. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19193. // if item.ChrgitmLv == "1" {
  19194. //
  19195. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19196. //
  19197. // }
  19198. // if item.ChrgitmLv == "2" {
  19199. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19200. //
  19201. // }
  19202. // if item.ChrgitmLv == "3" {
  19203. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19204. // }
  19205. // }
  19206. //
  19207. // if item.MedChrgitmType == "09" { //西药费
  19208. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19209. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19210. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19211. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19212. // if item.ChrgitmLv == "1" {
  19213. //
  19214. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19215. //
  19216. // }
  19217. // if item.ChrgitmLv == "2" {
  19218. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19219. //
  19220. // }
  19221. // if item.ChrgitmLv == "3" {
  19222. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19223. // }
  19224. // }
  19225. //
  19226. // if item.MedChrgitmType == "11" { //中成费
  19227. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19228. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19229. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19230. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19231. // if item.ChrgitmLv == "1" {
  19232. //
  19233. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19234. //
  19235. // }
  19236. // if item.ChrgitmLv == "2" {
  19237. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19238. //
  19239. // }
  19240. // if item.ChrgitmLv == "3" {
  19241. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19242. // }
  19243. // }
  19244. //
  19245. // if item.MedChrgitmType == "14" { //其他费
  19246. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19247. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19248. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19249. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19250. // if item.ChrgitmLv == "1" {
  19251. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19252. //
  19253. // }
  19254. // if item.ChrgitmLv == "2" {
  19255. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19256. //
  19257. // }
  19258. // if item.ChrgitmLv == "3" {
  19259. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19260. // }
  19261. // }
  19262. //
  19263. // }
  19264. //
  19265. // var iteminfoStructs []service.IteminfoStruct
  19266. //
  19267. // if bedCostTotal != 0 {
  19268. // iteminfo.MedChrgitm = "01"
  19269. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19270. // iteminfo.Amt = bedCostTotal
  19271. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19272. // iteminfo.ClabAmt = bed_clab_amt
  19273. // iteminfo.OthAmt = bed_other_amt
  19274. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19275. // }
  19276. //
  19277. // if checkCostTotal != 0 {
  19278. // iteminfo.MedChrgitm = "03"
  19279. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19280. // iteminfo.Amt = checkCostTotal
  19281. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19282. // iteminfo.ClabAmt = check_clab_amt
  19283. // iteminfo.OthAmt = check_other_amt
  19284. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19285. //
  19286. // }
  19287. //
  19288. // if laboratoryCostTotal != 0 {
  19289. // iteminfo.MedChrgitm = "04"
  19290. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19291. // iteminfo.Amt = laboratoryCostTotal
  19292. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19293. // iteminfo.ClabAmt = laboratory_clab_amt
  19294. // iteminfo.OthAmt = laboratory_other_amt
  19295. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19296. //
  19297. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19298. //
  19299. // }
  19300. //
  19301. // if treatCostTotal != 0 {
  19302. // iteminfo.MedChrgitm = "05"
  19303. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19304. // iteminfo.Amt = treatCostTotal
  19305. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19306. // iteminfo.ClabAmt = treat_clab_amt
  19307. // iteminfo.OthAmt = treat_other_amt
  19308. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19309. // //(struct4101.IteminfoStruct, iteminfo)
  19310. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19311. // }
  19312. //
  19313. // if operationCostTotal != 0 {
  19314. // iteminfo.MedChrgitm = "06"
  19315. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19316. // iteminfo.Amt = operationCostTotal
  19317. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19318. // iteminfo.ClabAmt = operation_clab_amt
  19319. // iteminfo.OthAmt = operation_other_amt
  19320. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19321. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19322. // }
  19323. //
  19324. // if materialCostTotal != 0 {
  19325. // iteminfo.MedChrgitm = "08"
  19326. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19327. // iteminfo.Amt = materialCostTotal
  19328. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19329. // iteminfo.ClabAmt = material_clab_amt
  19330. // iteminfo.OthAmt = material_other_amt
  19331. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19332. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19333. // }
  19334. //
  19335. // if westernMedicineCostTotal != 0 {
  19336. // iteminfo.MedChrgitm = "09"
  19337. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19338. // iteminfo.Amt = westernMedicineCostTotal
  19339. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19340. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19341. // iteminfo.OthAmt = westernMedicine_other_amt
  19342. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19343. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19344. //
  19345. // }
  19346. // if chineseTraditionalMedicineCostTotal != 0 {
  19347. // iteminfo.MedChrgitm = "11"
  19348. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19349. // iteminfo.Amt = westernMedicineCostTotal
  19350. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19351. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19352. // iteminfo.OthAmt = westernMedicine_other_amt
  19353. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19354. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19355. //
  19356. // }
  19357. // if otherCostTotal != 0 {
  19358. // iteminfo.MedChrgitm = "14"
  19359. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19360. // iteminfo.Amt = otherCostTotal
  19361. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19362. // iteminfo.ClabAmt = other_clab_amt
  19363. // iteminfo.OthAmt = other_other_amt
  19364. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19365. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19366. //
  19367. // }
  19368. // struct4101.IteminfoStruct = iteminfoStructs
  19369. // struct4101.Ntly = "中国"
  19370. // struct4101.AdmCaty = "A03.06"
  19371. //
  19372. // struct4101.DoctorName = doctor.UserName
  19373. // struct4101.DoctorCode = doctor.DoctorNumber
  19374. //
  19375. // var res ResultSeventeen
  19376. //
  19377. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19378. // struct4101.BillCode = order.Number
  19379. // struct4101.BillNo = order.SetlId
  19380. // var resOther ResultSeventeenOther
  19381. // var pp models.PublicParams
  19382. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19383. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19384. // pp.FixmedinsName = miConfig.OrgName
  19385. // pp.FixmedinsCode = miConfig.Code
  19386. // pp.RequestUrl = miConfig.Url
  19387. // pp.Cainfo = miConfig.Cainfo
  19388. // pp.SecretKey = miConfig.SecretKey
  19389. // pp.AccessKey = miConfig.AccessKey
  19390. // pp.OpterName = curRoles.UserName
  19391. //
  19392. // client := &http.Client{}
  19393. // var req *http.Request
  19394. // data := make(map[string]interface{})
  19395. // data["struct4101"] = struct4101
  19396. // data["pp"] = pp
  19397. // bytesData, _ := json.Marshal(data)
  19398. // if miConfig.MdtrtareaAdmvs == "320921" {
  19399. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19400. // } else {
  19401. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19402. // }
  19403. // resp, _ := client.Do(req)
  19404. // defer resp.Body.Close()
  19405. // body, ioErr := ioutil.ReadAll(resp.Body)
  19406. // if ioErr != nil {
  19407. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19409. // return
  19410. // }
  19411. // var respJSON map[string]interface{}
  19412. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19413. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19415. // return
  19416. // }
  19417. //
  19418. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19419. // userJSONBytes, _ := json.Marshal(respJSON)
  19420. // fmt.Println("log")
  19421. // fmt.Println(string(userJSONBytes))
  19422. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19423. // utils.ErrorLog("解析失败:%v", err)
  19424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19425. // return
  19426. // }
  19427. // res.InfRefmsgid = resOther.InfRefmsgid
  19428. // res.Output = resOther.Output
  19429. // res.ErrMsg = resOther.ErrMsg
  19430. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19431. // res.Infcode = infocode
  19432. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19433. //
  19434. // var pp models.PublicParams
  19435. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19436. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19437. // pp.FixmedinsName = miConfig.OrgName
  19438. // pp.FixmedinsCode = miConfig.Code
  19439. // pp.RequestUrl = miConfig.Url
  19440. // pp.Cainfo = miConfig.Cainfo
  19441. // pp.SecretKey = miConfig.SecretKey
  19442. // pp.AccessKey = miConfig.AccessKey
  19443. // pp.OpterName = curRoles.UserName
  19444. // result, _ := service.Jxyb4101(struct4101, pp)
  19445. // var dat map[string]interface{}
  19446. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19447. // fmt.Println(dat)
  19448. // } else {
  19449. // fmt.Println(err)
  19450. // }
  19451. // userJSONBytes, _ := json.Marshal(dat)
  19452. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19453. // utils.ErrorLog("解析失败:%v", err)
  19454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19455. // return
  19456. // }
  19457. //
  19458. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19459. // var pp models.PublicParams
  19460. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19461. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19462. // pp.FixmedinsName = miConfig.OrgName
  19463. // pp.FixmedinsCode = miConfig.Code
  19464. // pp.RequestUrl = miConfig.Url
  19465. // pp.Cainfo = miConfig.Cainfo
  19466. // pp.SecretKey = miConfig.SecretKey
  19467. // pp.AccessKey = miConfig.AccessKey
  19468. // pp.OpterName = curRoles.UserName
  19469. // result, _ := service.Hnyb4101(struct4101, pp)
  19470. // var dat map[string]interface{}
  19471. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19472. // fmt.Println(dat)
  19473. // } else {
  19474. // fmt.Println(err)
  19475. // }
  19476. // userJSONBytes, _ := json.Marshal(dat)
  19477. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19478. // utils.ErrorLog("解析失败:%v", err)
  19479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19480. // return
  19481. // }
  19482. //
  19483. // } else if miConfig.MdtrtareaAdmvs == "150404" {
  19484. // var resOther ResultSeventeenOther
  19485. //
  19486. // var pp models.PublicParams
  19487. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19488. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19489. // pp.FixmedinsName = miConfig.OrgName
  19490. // pp.FixmedinsCode = miConfig.Code
  19491. // pp.RequestUrl = miConfig.Url
  19492. // pp.Cainfo = miConfig.Cainfo
  19493. // pp.SecretKey = miConfig.SecretKey
  19494. // pp.AccessKey = miConfig.AccessKey
  19495. // pp.OpterName = curRoles.UserName
  19496. // client := &http.Client{}
  19497. // var req *http.Request
  19498. // data := make(map[string]interface{})
  19499. // data["struct4101"] = struct4101
  19500. // data["pp"] = pp
  19501. // bytesData, _ := json.Marshal(data)
  19502. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19503. // resp, _ := client.Do(req)
  19504. // defer resp.Body.Close()
  19505. // body, ioErr := ioutil.ReadAll(resp.Body)
  19506. // if ioErr != nil {
  19507. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19509. // return
  19510. // }
  19511. // var respJSON map[string]interface{}
  19512. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19513. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19515. // return
  19516. // }
  19517. //
  19518. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19519. // userJSONBytes, _ := json.Marshal(respJSON)
  19520. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19521. // utils.ErrorLog("解析失败:%v", err)
  19522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19523. // return
  19524. // }
  19525. // res.InfRefmsgid = resOther.InfRefmsgid
  19526. // res.Output = resOther.Output
  19527. // res.ErrMsg = resOther.ErrMsg
  19528. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19529. // res.Infcode = infocode
  19530. //
  19531. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19532. // var pp models.PublicParams
  19533. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19534. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19535. // pp.FixmedinsName = miConfig.OrgName
  19536. // pp.FixmedinsCode = miConfig.Code
  19537. // pp.RequestUrl = miConfig.Url
  19538. // pp.Cainfo = miConfig.Cainfo
  19539. // pp.SecretKey = miConfig.SecretKey
  19540. // pp.AccessKey = miConfig.AccessKey
  19541. // pp.OpterName = curRoles.UserName
  19542. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19543. // fmt.Println(requestLog)
  19544. // fmt.Println(errMsgLog)
  19545. //
  19546. // saveLog(result, requestLog, "4101a", "上传清单")
  19547. //
  19548. // var dat map[string]interface{}
  19549. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19550. // fmt.Println(dat)
  19551. // } else {
  19552. // fmt.Println(err)
  19553. // }
  19554. // userJSONBytes, _ := json.Marshal(dat)
  19555. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19556. // utils.ErrorLog("解析失败:%v", err)
  19557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19558. // return
  19559. // }
  19560. //
  19561. // } else {
  19562. //
  19563. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19564. // var dat map[string]interface{}
  19565. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19566. // fmt.Println(dat)
  19567. // } else {
  19568. // fmt.Println(err)
  19569. // }
  19570. // userJSONBytes, _ := json.Marshal(dat)
  19571. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19572. // utils.ErrorLog("解析失败:%v", err)
  19573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19574. // return
  19575. // }
  19576. // }
  19577. //
  19578. // if res.Infcode != 0 {
  19579. // adminUser := c.GetAdminUserInfo()
  19580. // errlog := &models.HisOrderError{
  19581. // UserOrgId: adminUser.CurrentOrgId,
  19582. // Ctime: time.Now().Unix(),
  19583. // Mtime: time.Now().Unix(),
  19584. // ErrMsg: res.ErrMsg,
  19585. // Status: 1,
  19586. // PatientId: order.ID,
  19587. // Stage: 10265,
  19588. // }
  19589. // service.CreateErrMsgLog(errlog)
  19590. // continue
  19591. // } else {
  19592. // //order.FaPiaoNumber = zero
  19593. // //order.FaPiaoCode = last_order.FaPiaoCode
  19594. // //service.UpdateOrder(order)
  19595. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19596. // Number: res.Output.SetlListId,
  19597. // Status: 1,
  19598. // Ctime: time.Now().Unix(),
  19599. // Mtime: time.Now().Unix(),
  19600. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19601. // IsUpload: 1,
  19602. // OrderId: order.ID,
  19603. // }
  19604. // service.CreateUploadRecord(hisFundSettleListResult)
  19605. // c.ServeSuccessJSON(map[string]interface{}{
  19606. // "msg": "上传成功",
  19607. // "result": hisFundSettleListResult,
  19608. // })
  19609. // continue
  19610. // }
  19611. // }
  19612. //}
  19613. func (c *HisApiController) GetbatchSettleList() {
  19614. //order_id, _ := c.GetInt64("order_id")
  19615. admin_user_id, _ := c.GetInt64("admin_user_id")
  19616. start_date := c.GetString("start_date")
  19617. end_date := c.GetString("end_date")
  19618. orders, _ := service.GetAllHisOrderTwo10485(start_date, end_date)
  19619. for _, item := range orders {
  19620. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19621. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19622. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19623. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19624. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19625. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19626. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19627. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19628. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19629. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19630. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19631. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19632. //fmt.Println(count)
  19633. //var zero string
  19634. //number := count + 1
  19635. //if number >= 1000 {
  19636. // zero = "0000" + strconv.FormatInt(number, 10)
  19637. //} else if number >= 10000 {
  19638. // zero = "000" + strconv.FormatInt(number, 10)
  19639. //} else if number >= 100000 {
  19640. // zero = "00" + strconv.FormatInt(number, 10)
  19641. //} else if number >= 1000000 {
  19642. // zero = "0" + strconv.FormatInt(number, 10)
  19643. //} else {
  19644. // zero = strconv.FormatInt(number, 10)
  19645. //}
  19646. //fmt.Println(zero)
  19647. struct4101 := service.Struct4101{
  19648. PsnNo: order.PsnNo,
  19649. MdtrtId: order.MdtrtId,
  19650. SetlId: order.SetlId,
  19651. PsnName: order.PsnName,
  19652. Gend: order.Gend,
  19653. Brdy: his.Brdy,
  19654. Age: his.Age,
  19655. Naty: order.Naty,
  19656. PatnCertType: "01",
  19657. Certno: order.Certno,
  19658. Prfs: "90",
  19659. ConerName: roles[0].UserName,
  19660. PatnRlts: "99",
  19661. ConerAddr: miConfig.OrgName,
  19662. ConerTel: admin.Mobile,
  19663. HiType: order.Insutype,
  19664. Insuplc: miConfig.InsuplcAdmdvs,
  19665. MaindiagFlag: "1",
  19666. BillCode: order.SetlId,
  19667. BillNo: order.SetlId,
  19668. BizSn: order.Number,
  19669. PsnSelfPay: order.PsnPartAmt,
  19670. PsnOwnPay: order.PsnPartAmt,
  19671. AcctPay: order.AcctPay,
  19672. PsnCashpay: order.PsnCashPay,
  19673. HiPaymtd: "1",
  19674. Hsorg: miConfig.InsuplcAdmdvs,
  19675. HsorgOpter: miConfig.InsuplcAdmdvs,
  19676. MedinsFillPsn: curRoles.UserName,
  19677. MedinsFillDept: miConfig.OrgName,
  19678. IptMedType: "2",
  19679. }
  19680. struct4101.SetlBegnDate = order.SetlTime
  19681. struct4101.SetlEndDate = order.SetlTime
  19682. time_arr := strings.Split(order.SetlTime, " ")
  19683. struct4101.AdmTime = time_arr[0]
  19684. struct4101.AdmEndTime = time_arr[0]
  19685. //var rf []CustomFundPay
  19686. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19687. //
  19688. //var tempFunPays []service.CustomStruct
  19689. //for _, item := range rf {
  19690. // var tempFunPay service.CustomStruct
  19691. // tempFunPay.FundPayamt = item.FundPayamt
  19692. // tempFunPay.FundPayType = item.FundPayType
  19693. // tempFunPays = append(tempFunPays, tempFunPay)
  19694. //}
  19695. //struct4101.CustomStruct = tempFunPays
  19696. var tempDiaginfos []service.DiaginfoStructTwo
  19697. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19698. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19699. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19700. var config []*models.HisXtDiagnoseConfig
  19701. for _, item := range diagnosis_ids {
  19702. id, _ := strconv.ParseInt(item, 10, 64)
  19703. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19704. config = append(config, &diagnosisConfig)
  19705. }
  19706. for index, item := range config {
  19707. if index == 0 {
  19708. var tempDiaginfo service.DiaginfoStructTwo
  19709. tempDiaginfo.DiagCode = item.CountryCode
  19710. tempDiaginfo.DiagName = item.CountryContentName
  19711. tempDiaginfo.DiagType = "1"
  19712. tempDiaginfo.MaindiagFlag = "1"
  19713. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19714. } else {
  19715. var tempDiaginfo service.DiaginfoStructTwo
  19716. tempDiaginfo.DiagCode = item.CountryCode
  19717. tempDiaginfo.DiagName = item.CountryContentName
  19718. tempDiaginfo.DiagType = "1"
  19719. tempDiaginfo.MaindiagFlag = "0"
  19720. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19721. }
  19722. }
  19723. struct4101.Diseinfo = tempDiaginfos
  19724. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19725. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19726. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19727. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19728. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19729. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19730. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19731. var iteminfo service.IteminfoStruct
  19732. var bedCostTotal float64 = 0 //床位总费
  19733. var bedCostSelfTotal float64 = 0 //床位自费
  19734. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19735. var operationCostTotal float64 = 0 //手术费
  19736. var operationCostSelfTotal float64 = 0 //手术费
  19737. var operationCostPartSelfTotal float64 = 0 //手术费
  19738. var otherCostTotal float64 = 0 //其他费用
  19739. var otherCostSelfTotal float64 = 0 //其他费用
  19740. var otherCostPartSelfTotal float64 = 0 //其他费用
  19741. var materialCostTotal float64 = 0 //材料费
  19742. var materialCostSelfTotal float64 = 0 //材料费
  19743. var materialCostPartSelfTotal float64 = 0 //材料费
  19744. var westernMedicineCostTotal float64 = 0 //西药费
  19745. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19746. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19747. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19748. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19749. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19750. var checkCostTotal float64 = 0 //检查费
  19751. var checkCostSelfTotal float64 = 0 //检查费
  19752. var checkCostPartSelfTotal float64 = 0 //检查费
  19753. var laboratoryCostTotal float64 = 0 //化验费
  19754. var laboratoryCostSelfTotal float64 = 0 //化验费
  19755. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19756. var treatCostTotal float64 = 0 //治疗费用
  19757. var treatCostSelfTotal float64 = 0 //治疗费用
  19758. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19759. decimal.DivisionPrecision = 2
  19760. var bed_fulamt_ownpay_amt float64 = 0
  19761. var operation_fulamt_ownpay_amt float64 = 0
  19762. var other_fulamt_ownpay_amt float64 = 0
  19763. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19764. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19765. var check_fulamt_ownpay_amt float64 = 0
  19766. var material_fulamt_ownpay_amt float64 = 0
  19767. var laboratory_fulamt_ownpay_amt float64 = 0
  19768. var treat_fulamt_ownpay_amt float64 = 0
  19769. var bed_claa_sunmfee float64 = 0
  19770. var bed_clab_amt float64 = 0
  19771. var bed_other_amt float64 = 0
  19772. var operation_claa_sunmfee float64 = 0
  19773. var operation_clab_amt float64 = 0
  19774. var operation_other_amt float64 = 0
  19775. var other_claa_sunmfee float64 = 0
  19776. var other_clab_amt float64 = 0
  19777. var other_other_amt float64 = 0
  19778. var westernMedicine_claa_sunmfee float64 = 0
  19779. var westernMedicine_clab_amt float64 = 0
  19780. var westernMedicine_other_amt float64 = 0
  19781. var chineseTraditional_claa_sunmfee float64 = 0
  19782. var chineseTraditional_clab_amt float64 = 0
  19783. var chineseTraditional_other_amt float64 = 0
  19784. var check_claa_sunmfee float64 = 0
  19785. var check_clab_amt float64 = 0
  19786. var check_other_amt float64 = 0
  19787. var material_claa_sunmfee float64 = 0
  19788. var material_clab_amt float64 = 0
  19789. var material_other_amt float64 = 0
  19790. var laboratory_claa_sunmfee float64 = 0
  19791. var laboratory_clab_amt float64 = 0
  19792. var laboratory_other_amt float64 = 0
  19793. var treat_claa_sunmfee float64 = 0
  19794. var treat_clab_amt float64 = 0
  19795. var treat_other_amt float64 = 0
  19796. for _, item := range order.HisOrderInfo {
  19797. if item.MedChrgitmType == "01" { //床位费
  19798. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19799. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19800. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19801. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19802. if item.ChrgitmLv == "1" {
  19803. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19804. }
  19805. if item.ChrgitmLv == "2" {
  19806. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19807. }
  19808. if item.ChrgitmLv == "3" {
  19809. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19810. }
  19811. }
  19812. if item.MedChrgitmType == "03" { //检查费
  19813. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19814. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19815. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19816. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19817. if item.ChrgitmLv == "1" {
  19818. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19819. }
  19820. if item.ChrgitmLv == "2" {
  19821. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19822. }
  19823. if item.ChrgitmLv == "3" {
  19824. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19825. }
  19826. }
  19827. if item.MedChrgitmType == "04" { //化验费
  19828. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19829. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19830. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19831. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19832. if item.ChrgitmLv == "1" {
  19833. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19834. }
  19835. if item.ChrgitmLv == "2" {
  19836. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19837. }
  19838. if item.ChrgitmLv == "3" {
  19839. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19840. }
  19841. }
  19842. if item.MedChrgitmType == "05" { //治疗费
  19843. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19844. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19845. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19846. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19847. if item.ChrgitmLv == "1" {
  19848. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19849. }
  19850. if item.ChrgitmLv == "2" {
  19851. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19852. }
  19853. if item.ChrgitmLv == "3" {
  19854. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19855. }
  19856. }
  19857. if item.MedChrgitmType == "06" { //手术费
  19858. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19859. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19860. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19861. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19862. if item.ChrgitmLv == "1" {
  19863. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19864. }
  19865. if item.ChrgitmLv == "2" {
  19866. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19867. }
  19868. if item.ChrgitmLv == "3" {
  19869. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19870. }
  19871. }
  19872. if item.MedChrgitmType == "08" { //材料费
  19873. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19874. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19875. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19876. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19877. if item.ChrgitmLv == "1" {
  19878. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19879. }
  19880. if item.ChrgitmLv == "2" {
  19881. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19882. }
  19883. if item.ChrgitmLv == "3" {
  19884. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19885. }
  19886. }
  19887. if item.MedChrgitmType == "09" { //西药费
  19888. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19889. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19890. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19891. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19892. if item.ChrgitmLv == "1" {
  19893. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19894. }
  19895. if item.ChrgitmLv == "2" {
  19896. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19897. }
  19898. if item.ChrgitmLv == "3" {
  19899. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19900. }
  19901. }
  19902. if item.MedChrgitmType == "11" { //中成费
  19903. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19904. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19905. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19906. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19907. if item.ChrgitmLv == "1" {
  19908. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19909. }
  19910. if item.ChrgitmLv == "2" {
  19911. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19912. }
  19913. if item.ChrgitmLv == "3" {
  19914. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19915. }
  19916. }
  19917. if item.MedChrgitmType == "14" { //其他费
  19918. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19919. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19920. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19921. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19922. if item.ChrgitmLv == "1" {
  19923. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19924. }
  19925. if item.ChrgitmLv == "2" {
  19926. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19927. }
  19928. if item.ChrgitmLv == "3" {
  19929. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19930. }
  19931. }
  19932. }
  19933. var iteminfoStructs []service.IteminfoStruct
  19934. if bedCostTotal != 0 {
  19935. iteminfo.MedChrgitm = "01"
  19936. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19937. iteminfo.Amt = bedCostTotal
  19938. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19939. iteminfo.ClabAmt = bed_clab_amt
  19940. iteminfo.OthAmt = bed_other_amt
  19941. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19942. }
  19943. if checkCostTotal != 0 {
  19944. iteminfo.MedChrgitm = "03"
  19945. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19946. iteminfo.Amt = checkCostTotal
  19947. iteminfo.ClaaSumfee = check_claa_sunmfee
  19948. iteminfo.ClabAmt = check_clab_amt
  19949. iteminfo.OthAmt = check_other_amt
  19950. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19951. }
  19952. if laboratoryCostTotal != 0 {
  19953. iteminfo.MedChrgitm = "04"
  19954. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19955. iteminfo.Amt = laboratoryCostTotal
  19956. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19957. iteminfo.ClabAmt = laboratory_clab_amt
  19958. iteminfo.OthAmt = laboratory_other_amt
  19959. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19960. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19961. }
  19962. if treatCostTotal != 0 {
  19963. iteminfo.MedChrgitm = "05"
  19964. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19965. iteminfo.Amt = treatCostTotal
  19966. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19967. iteminfo.ClabAmt = treat_clab_amt
  19968. iteminfo.OthAmt = treat_other_amt
  19969. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19970. //(struct4101.IteminfoStruct, iteminfo)
  19971. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19972. }
  19973. if operationCostTotal != 0 {
  19974. iteminfo.MedChrgitm = "06"
  19975. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19976. iteminfo.Amt = operationCostTotal
  19977. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19978. iteminfo.ClabAmt = operation_clab_amt
  19979. iteminfo.OthAmt = operation_other_amt
  19980. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19981. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19982. }
  19983. if materialCostTotal != 0 {
  19984. iteminfo.MedChrgitm = "08"
  19985. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19986. iteminfo.Amt = materialCostTotal
  19987. iteminfo.ClaaSumfee = material_claa_sunmfee
  19988. iteminfo.ClabAmt = material_clab_amt
  19989. iteminfo.OthAmt = material_other_amt
  19990. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19991. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19992. }
  19993. if westernMedicineCostTotal != 0 {
  19994. iteminfo.MedChrgitm = "09"
  19995. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19996. iteminfo.Amt = westernMedicineCostTotal
  19997. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19998. iteminfo.ClabAmt = westernMedicine_clab_amt
  19999. iteminfo.OthAmt = westernMedicine_other_amt
  20000. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20001. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20002. }
  20003. if chineseTraditionalMedicineCostTotal != 0 {
  20004. iteminfo.MedChrgitm = "11"
  20005. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20006. iteminfo.Amt = westernMedicineCostTotal
  20007. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20008. iteminfo.ClabAmt = westernMedicine_clab_amt
  20009. iteminfo.OthAmt = westernMedicine_other_amt
  20010. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20011. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20012. }
  20013. if otherCostTotal != 0 {
  20014. iteminfo.MedChrgitm = "14"
  20015. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20016. iteminfo.Amt = otherCostTotal
  20017. iteminfo.ClaaSumfee = other_claa_sunmfee
  20018. iteminfo.ClabAmt = other_clab_amt
  20019. iteminfo.OthAmt = other_other_amt
  20020. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20021. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20022. }
  20023. struct4101.IteminfoStruct = iteminfoStructs
  20024. struct4101.Ntly = "中国"
  20025. struct4101.AdmCaty = "A03.06"
  20026. struct4101.DoctorName = doctor.UserName
  20027. struct4101.DoctorCode = doctor.DoctorNumber
  20028. var res ResultSeventeen
  20029. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20030. struct4101.BillCode = order.Number
  20031. struct4101.BillNo = order.SetlId
  20032. var resOther ResultSeventeenOther
  20033. var pp models.PublicParams
  20034. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20035. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20036. pp.FixmedinsName = miConfig.OrgName
  20037. pp.FixmedinsCode = miConfig.Code
  20038. pp.RequestUrl = miConfig.Url
  20039. pp.Cainfo = miConfig.Cainfo
  20040. pp.SecretKey = miConfig.SecretKey
  20041. pp.AccessKey = miConfig.AccessKey
  20042. pp.OpterName = curRoles.UserName
  20043. client := &http.Client{}
  20044. var req *http.Request
  20045. data := make(map[string]interface{})
  20046. data["struct4101"] = struct4101
  20047. data["pp"] = pp
  20048. bytesData, _ := json.Marshal(data)
  20049. if miConfig.MdtrtareaAdmvs == "320830" {
  20050. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20051. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20052. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20053. } else {
  20054. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20055. }
  20056. resp, _ := client.Do(req)
  20057. defer resp.Body.Close()
  20058. body, ioErr := ioutil.ReadAll(resp.Body)
  20059. if ioErr != nil {
  20060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20062. return
  20063. }
  20064. var respJSON map[string]interface{}
  20065. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20068. return
  20069. }
  20070. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20071. userJSONBytes, _ := json.Marshal(respJSON)
  20072. fmt.Println("log")
  20073. fmt.Println(string(userJSONBytes))
  20074. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20075. utils.ErrorLog("解析失败:%v", err)
  20076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20077. return
  20078. }
  20079. res.InfRefmsgid = resOther.InfRefmsgid
  20080. res.Output = resOther.Output
  20081. res.ErrMsg = resOther.ErrMsg
  20082. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20083. res.Infcode = infocode
  20084. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20085. var pp models.PublicParams
  20086. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20087. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20088. pp.FixmedinsName = miConfig.OrgName
  20089. pp.FixmedinsCode = miConfig.Code
  20090. pp.RequestUrl = miConfig.Url
  20091. pp.Cainfo = miConfig.Cainfo
  20092. pp.SecretKey = miConfig.SecretKey
  20093. pp.AccessKey = miConfig.AccessKey
  20094. pp.OpterName = curRoles.UserName
  20095. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20096. result, _ := service.Jxyb4101(struct4101, pp)
  20097. var dat map[string]interface{}
  20098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20099. fmt.Println(dat)
  20100. } else {
  20101. fmt.Println(err)
  20102. }
  20103. userJSONBytes, _ := json.Marshal(dat)
  20104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20105. utils.ErrorLog("解析失败:%v", err)
  20106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20107. return
  20108. }
  20109. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20110. var pp models.PublicParams
  20111. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20112. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20113. pp.FixmedinsName = miConfig.OrgName
  20114. pp.FixmedinsCode = miConfig.Code
  20115. pp.RequestUrl = miConfig.Url
  20116. pp.Cainfo = miConfig.Cainfo
  20117. pp.SecretKey = miConfig.SecretKey
  20118. pp.AccessKey = miConfig.AccessKey
  20119. pp.OpterName = curRoles.UserName
  20120. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20121. result, _ := service.Jxyb4101(struct4101, pp)
  20122. var dat map[string]interface{}
  20123. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20124. fmt.Println(dat)
  20125. } else {
  20126. fmt.Println(err)
  20127. }
  20128. userJSONBytes, _ := json.Marshal(dat)
  20129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20130. utils.ErrorLog("解析失败:%v", err)
  20131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20132. return
  20133. }
  20134. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20135. var pp models.PublicParams
  20136. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20137. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20138. pp.FixmedinsName = miConfig.OrgName
  20139. pp.FixmedinsCode = miConfig.Code
  20140. pp.RequestUrl = miConfig.Url
  20141. pp.Cainfo = miConfig.Cainfo
  20142. pp.SecretKey = miConfig.SecretKey
  20143. pp.AccessKey = miConfig.AccessKey
  20144. pp.OpterName = curRoles.UserName
  20145. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20146. result, _ := service.Jxyb4101(struct4101, pp)
  20147. var dat map[string]interface{}
  20148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20149. fmt.Println(dat)
  20150. } else {
  20151. fmt.Println(err)
  20152. }
  20153. userJSONBytes, _ := json.Marshal(dat)
  20154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20155. utils.ErrorLog("解析失败:%v", err)
  20156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20157. return
  20158. }
  20159. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20160. var pp models.PublicParams
  20161. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20162. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20163. pp.FixmedinsName = miConfig.OrgName
  20164. pp.FixmedinsCode = miConfig.Code
  20165. pp.RequestUrl = miConfig.Url
  20166. pp.Cainfo = miConfig.Cainfo
  20167. pp.SecretKey = miConfig.SecretKey
  20168. pp.AccessKey = miConfig.AccessKey
  20169. pp.OpterName = curRoles.UserName
  20170. result, _ := service.Hnyb4101(struct4101, pp)
  20171. var dat map[string]interface{}
  20172. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20173. fmt.Println(dat)
  20174. } else {
  20175. fmt.Println(err)
  20176. }
  20177. userJSONBytes, _ := json.Marshal(dat)
  20178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20179. utils.ErrorLog("解析失败:%v", err)
  20180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20181. return
  20182. }
  20183. } else if miConfig.MdtrtareaAdmvs == "150404" {
  20184. var resOther ResultSeventeenOther
  20185. var pp models.PublicParams
  20186. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20187. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20188. pp.FixmedinsName = miConfig.OrgName
  20189. pp.FixmedinsCode = miConfig.Code
  20190. pp.RequestUrl = miConfig.Url
  20191. pp.Cainfo = miConfig.Cainfo
  20192. pp.SecretKey = miConfig.SecretKey
  20193. pp.AccessKey = miConfig.AccessKey
  20194. pp.OpterName = curRoles.UserName
  20195. client := &http.Client{}
  20196. var req *http.Request
  20197. data := make(map[string]interface{})
  20198. data["struct4101"] = struct4101
  20199. data["pp"] = pp
  20200. bytesData, _ := json.Marshal(data)
  20201. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20202. resp, _ := client.Do(req)
  20203. defer resp.Body.Close()
  20204. body, ioErr := ioutil.ReadAll(resp.Body)
  20205. if ioErr != nil {
  20206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20208. return
  20209. }
  20210. var respJSON map[string]interface{}
  20211. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20214. return
  20215. }
  20216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20217. userJSONBytes, _ := json.Marshal(respJSON)
  20218. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20219. utils.ErrorLog("解析失败:%v", err)
  20220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20221. return
  20222. }
  20223. res.InfRefmsgid = resOther.InfRefmsgid
  20224. res.Output = resOther.Output
  20225. res.ErrMsg = resOther.ErrMsg
  20226. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20227. res.Infcode = infocode
  20228. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20229. var pp models.PublicParams
  20230. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20231. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20232. pp.FixmedinsName = miConfig.OrgName
  20233. pp.FixmedinsCode = miConfig.Code
  20234. pp.RequestUrl = miConfig.Url
  20235. pp.Cainfo = miConfig.Cainfo
  20236. pp.SecretKey = miConfig.SecretKey
  20237. pp.AccessKey = miConfig.AccessKey
  20238. pp.OpterName = curRoles.UserName
  20239. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20240. fmt.Println(requestLog)
  20241. fmt.Println(errMsgLog)
  20242. saveLog(result, requestLog, "4101a", "上传清单")
  20243. var dat map[string]interface{}
  20244. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20245. fmt.Println(dat)
  20246. } else {
  20247. fmt.Println(err)
  20248. }
  20249. userJSONBytes, _ := json.Marshal(dat)
  20250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20251. utils.ErrorLog("解析失败:%v", err)
  20252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20253. return
  20254. }
  20255. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20256. var pp models.PublicParams
  20257. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20258. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20259. pp.FixmedinsName = miConfig.OrgName
  20260. pp.FixmedinsCode = miConfig.Code
  20261. pp.RequestUrl = miConfig.Url
  20262. pp.Cainfo = miConfig.Cainfo
  20263. pp.SecretKey = miConfig.SecretKey
  20264. pp.AccessKey = miConfig.AccessKey
  20265. pp.OpterName = curRoles.UserName
  20266. client := &http.Client{}
  20267. var req *http.Request
  20268. data := make(map[string]interface{})
  20269. data["struct4101"] = struct4101
  20270. data["pp"] = pp
  20271. bytesData, _ := json.Marshal(data)
  20272. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20273. resp, _ := client.Do(req)
  20274. defer resp.Body.Close()
  20275. body, ioErr := ioutil.ReadAll(resp.Body)
  20276. if ioErr != nil {
  20277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20279. return
  20280. }
  20281. var respJSON map[string]interface{}
  20282. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20285. return
  20286. }
  20287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20288. userJSONBytes, _ := json.Marshal(respJSON)
  20289. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20290. utils.ErrorLog("解析失败:%v", err)
  20291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20292. return
  20293. }
  20294. } else {
  20295. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20296. var dat map[string]interface{}
  20297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20298. fmt.Println(dat)
  20299. } else {
  20300. fmt.Println(err)
  20301. }
  20302. userJSONBytes, _ := json.Marshal(dat)
  20303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20304. utils.ErrorLog("解析失败:%v", err)
  20305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20306. return
  20307. }
  20308. }
  20309. if res.Infcode != 0 {
  20310. errlog := &models.HisOrderError{
  20311. UserOrgId: order.UserOrgId,
  20312. Ctime: time.Now().Unix(),
  20313. Mtime: time.Now().Unix(),
  20314. ErrMsg: res.ErrMsg + "解析失败",
  20315. Status: 1,
  20316. PatientId: order.ID,
  20317. Stage: 10485,
  20318. }
  20319. service.CreateErrMsgLog(errlog)
  20320. continue
  20321. //c.ServeSuccessJSON(map[string]interface{}{
  20322. // "failed_code": -10,
  20323. // "msg": res.ErrMsg,
  20324. //})
  20325. } else {
  20326. //order.FaPiaoNumber = zero
  20327. //order.FaPiaoCode = last_order.FaPiaoCode
  20328. //service.UpdateOrder(order)
  20329. hisFundSettleListResult := &models.HisFundSettleListResult{
  20330. Number: res.Output.SetlListId,
  20331. Status: 1,
  20332. Ctime: time.Now().Unix(),
  20333. Mtime: time.Now().Unix(),
  20334. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20335. IsUpload: 1,
  20336. OrderId: order.ID,
  20337. }
  20338. service.CreateUploadRecord(hisFundSettleListResult)
  20339. continue
  20340. }
  20341. }
  20342. }
  20343. func (c *HisApiController) GetSettleList() {
  20344. order_id, _ := c.GetInt64("order_id")
  20345. admin_user_id, _ := c.GetInt64("admin_user_id")
  20346. order, _ := service.GetHisOrderByIDTwo(order_id)
  20347. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20348. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20349. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20350. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20351. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20352. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20353. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20354. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20355. if order.ID == 0 {
  20356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20357. return
  20358. }
  20359. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20360. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20361. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20362. //fmt.Println(count)
  20363. //var zero string
  20364. //number := count + 1
  20365. //if number >= 1000 {
  20366. // zero = "0000" + strconv.FormatInt(number, 10)
  20367. //} else if number >= 10000 {
  20368. // zero = "000" + strconv.FormatInt(number, 10)
  20369. //} else if number >= 100000 {
  20370. // zero = "00" + strconv.FormatInt(number, 10)
  20371. //} else if number >= 1000000 {
  20372. // zero = "0" + strconv.FormatInt(number, 10)
  20373. //} else {
  20374. // zero = strconv.FormatInt(number, 10)
  20375. //}
  20376. //fmt.Println(zero)
  20377. struct4101 := service.Struct4101{
  20378. PsnNo: order.PsnNo,
  20379. MdtrtId: order.MdtrtId,
  20380. SetlId: order.SetlId,
  20381. PsnName: order.PsnName,
  20382. Gend: order.Gend,
  20383. Brdy: his.Brdy,
  20384. Age: his.Age,
  20385. Naty: order.Naty,
  20386. PatnCertType: "01",
  20387. Certno: order.Certno,
  20388. Prfs: "90",
  20389. ConerName: roles[0].UserName,
  20390. PatnRlts: "99",
  20391. ConerAddr: miConfig.OrgName,
  20392. ConerTel: admin.Mobile,
  20393. HiType: order.Insutype,
  20394. Insuplc: miConfig.InsuplcAdmdvs,
  20395. MaindiagFlag: "1",
  20396. BillCode: order.SetlId,
  20397. BillNo: order.SetlId,
  20398. BizSn: order.Number,
  20399. PsnSelfPay: order.PsnPartAmt,
  20400. PsnOwnPay: order.PsnPartAmt,
  20401. AcctPay: order.AcctPay,
  20402. PsnCashpay: order.PsnCashPay,
  20403. HiPaymtd: "1",
  20404. Hsorg: miConfig.InsuplcAdmdvs,
  20405. HsorgOpter: miConfig.InsuplcAdmdvs,
  20406. MedinsFillPsn: curRoles.UserName,
  20407. MedinsFillDept: miConfig.OrgName,
  20408. IptMedType: "2",
  20409. }
  20410. struct4101.SetlBegnDate = order.SetlTime
  20411. struct4101.SetlEndDate = order.SetlTime
  20412. time_arr := strings.Split(order.SetlTime, " ")
  20413. struct4101.AdmTime = time_arr[0]
  20414. struct4101.AdmEndTime = time_arr[0]
  20415. //
  20416. //var rf []CustomFundPay
  20417. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20418. //
  20419. //var tempFunPays []service.CustomStruct
  20420. //for _, item := range rf {
  20421. // var tempFunPay service.CustomStruct
  20422. // tempFunPay.FundPayamt = item.FundPayamt
  20423. // tempFunPay.FundPayType = item.FundPayType
  20424. // tempFunPays = append(tempFunPays, tempFunPay)
  20425. //}
  20426. //struct4101.CustomStruct = tempFunPays
  20427. var tempDiaginfos []service.DiaginfoStructTwo
  20428. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20429. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20430. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20431. var config []*models.HisXtDiagnoseConfig
  20432. for _, item := range diagnosis_ids {
  20433. id, _ := strconv.ParseInt(item, 10, 64)
  20434. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20435. config = append(config, &diagnosisConfig)
  20436. }
  20437. if miConfig.Code == "H15049901371" {
  20438. //for _, item := range config {
  20439. // if item.ID == 138 {
  20440. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20441. var tempDiaginfo service.DiaginfoStructTwo
  20442. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20443. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20444. tempDiaginfo.DiagType = "1"
  20445. tempDiaginfo.MaindiagFlag = "1"
  20446. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20447. //}
  20448. //}
  20449. for _, item := range config {
  20450. if item.ID != 138 {
  20451. var tempDiaginfo service.DiaginfoStructTwo
  20452. tempDiaginfo.DiagCode = item.CountryCode
  20453. tempDiaginfo.DiagName = item.CountryContentName
  20454. tempDiaginfo.DiagType = "1"
  20455. tempDiaginfo.MaindiagFlag = "0"
  20456. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20457. }
  20458. }
  20459. } else {
  20460. for index, item := range config {
  20461. if index == 0 {
  20462. var tempDiaginfo service.DiaginfoStructTwo
  20463. tempDiaginfo.DiagCode = item.CountryCode
  20464. tempDiaginfo.DiagName = item.CountryContentName
  20465. tempDiaginfo.DiagType = "1"
  20466. tempDiaginfo.MaindiagFlag = "1"
  20467. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20468. } else {
  20469. var tempDiaginfo service.DiaginfoStructTwo
  20470. tempDiaginfo.DiagCode = item.CountryCode
  20471. tempDiaginfo.DiagName = item.CountryContentName
  20472. tempDiaginfo.DiagType = "1"
  20473. tempDiaginfo.MaindiagFlag = "0"
  20474. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20475. }
  20476. }
  20477. }
  20478. struct4101.Diseinfo = tempDiaginfos
  20479. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20480. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20481. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20482. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20483. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20484. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20485. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20486. var iteminfo service.IteminfoStruct
  20487. var bedCostTotal float64 = 0 //床位总费
  20488. var bedCostSelfTotal float64 = 0 //床位自费
  20489. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20490. var operationCostTotal float64 = 0 //手术费
  20491. var operationCostSelfTotal float64 = 0 //手术费
  20492. var operationCostPartSelfTotal float64 = 0 //手术费
  20493. var otherCostTotal float64 = 0 //其他费用
  20494. var otherCostSelfTotal float64 = 0 //其他费用
  20495. var otherCostPartSelfTotal float64 = 0 //其他费用
  20496. var materialCostTotal float64 = 0 //材料费
  20497. var materialCostSelfTotal float64 = 0 //材料费
  20498. var materialCostPartSelfTotal float64 = 0 //材料费
  20499. var westernMedicineCostTotal float64 = 0 //西药费
  20500. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20501. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20502. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20503. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20504. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20505. var checkCostTotal float64 = 0 //检查费
  20506. var checkCostSelfTotal float64 = 0 //检查费
  20507. var checkCostPartSelfTotal float64 = 0 //检查费
  20508. var laboratoryCostTotal float64 = 0 //化验费
  20509. var laboratoryCostSelfTotal float64 = 0 //化验费
  20510. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20511. var treatCostTotal float64 = 0 //治疗费用
  20512. var treatCostSelfTotal float64 = 0 //治疗费用
  20513. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20514. decimal.DivisionPrecision = 2
  20515. var bed_fulamt_ownpay_amt float64 = 0
  20516. var operation_fulamt_ownpay_amt float64 = 0
  20517. var other_fulamt_ownpay_amt float64 = 0
  20518. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20519. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20520. var check_fulamt_ownpay_amt float64 = 0
  20521. var material_fulamt_ownpay_amt float64 = 0
  20522. var laboratory_fulamt_ownpay_amt float64 = 0
  20523. var treat_fulamt_ownpay_amt float64 = 0
  20524. var bed_claa_sunmfee float64 = 0
  20525. var bed_clab_amt float64 = 0
  20526. var bed_other_amt float64 = 0
  20527. var operation_claa_sunmfee float64 = 0
  20528. var operation_clab_amt float64 = 0
  20529. var operation_other_amt float64 = 0
  20530. var other_claa_sunmfee float64 = 0
  20531. var other_clab_amt float64 = 0
  20532. var other_other_amt float64 = 0
  20533. var westernMedicine_claa_sunmfee float64 = 0
  20534. var westernMedicine_clab_amt float64 = 0
  20535. var westernMedicine_other_amt float64 = 0
  20536. var chineseTraditional_claa_sunmfee float64 = 0
  20537. var chineseTraditional_clab_amt float64 = 0
  20538. var chineseTraditional_other_amt float64 = 0
  20539. var check_claa_sunmfee float64 = 0
  20540. var check_clab_amt float64 = 0
  20541. var check_other_amt float64 = 0
  20542. var material_claa_sunmfee float64 = 0
  20543. var material_clab_amt float64 = 0
  20544. var material_other_amt float64 = 0
  20545. var laboratory_claa_sunmfee float64 = 0
  20546. var laboratory_clab_amt float64 = 0
  20547. var laboratory_other_amt float64 = 0
  20548. var treat_claa_sunmfee float64 = 0
  20549. var treat_clab_amt float64 = 0
  20550. var treat_other_amt float64 = 0
  20551. for _, item := range order.HisOrderInfo {
  20552. if item.MedChrgitmType == "01" { //床位费
  20553. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20554. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20555. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20556. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20557. if item.ChrgitmLv == "1" {
  20558. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20559. }
  20560. if item.ChrgitmLv == "2" {
  20561. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20562. }
  20563. if item.ChrgitmLv == "3" {
  20564. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20565. }
  20566. }
  20567. if item.MedChrgitmType == "03" { //检查费
  20568. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20569. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20570. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20571. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20572. if item.ChrgitmLv == "1" {
  20573. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20574. }
  20575. if item.ChrgitmLv == "2" {
  20576. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20577. }
  20578. if item.ChrgitmLv == "3" {
  20579. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20580. }
  20581. }
  20582. if item.MedChrgitmType == "04" { //化验费
  20583. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20584. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20585. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20586. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20587. if item.ChrgitmLv == "1" {
  20588. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20589. }
  20590. if item.ChrgitmLv == "2" {
  20591. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20592. }
  20593. if item.ChrgitmLv == "3" {
  20594. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20595. }
  20596. }
  20597. if item.MedChrgitmType == "05" { //治疗费
  20598. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20599. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20600. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20601. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20602. if item.ChrgitmLv == "1" {
  20603. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20604. }
  20605. if item.ChrgitmLv == "2" {
  20606. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20607. }
  20608. if item.ChrgitmLv == "3" {
  20609. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20610. }
  20611. }
  20612. if item.MedChrgitmType == "06" { //手术费
  20613. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20614. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20615. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20616. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20617. if item.ChrgitmLv == "1" {
  20618. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20619. }
  20620. if item.ChrgitmLv == "2" {
  20621. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20622. }
  20623. if item.ChrgitmLv == "3" {
  20624. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20625. }
  20626. }
  20627. if item.MedChrgitmType == "08" { //材料费
  20628. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20629. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20630. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20631. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20632. if item.ChrgitmLv == "1" {
  20633. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20634. }
  20635. if item.ChrgitmLv == "2" {
  20636. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20637. }
  20638. if item.ChrgitmLv == "3" {
  20639. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20640. }
  20641. }
  20642. if item.MedChrgitmType == "09" { //西药费
  20643. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20644. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20645. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20646. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20647. if item.ChrgitmLv == "1" {
  20648. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20649. }
  20650. if item.ChrgitmLv == "2" {
  20651. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20652. }
  20653. if item.ChrgitmLv == "3" {
  20654. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20655. }
  20656. }
  20657. if item.MedChrgitmType == "11" { //中成费
  20658. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20659. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20660. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20661. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20662. if item.ChrgitmLv == "1" {
  20663. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20664. }
  20665. if item.ChrgitmLv == "2" {
  20666. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20667. }
  20668. if item.ChrgitmLv == "3" {
  20669. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20670. }
  20671. }
  20672. if item.MedChrgitmType == "14" { //其他费
  20673. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20674. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20675. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20676. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20677. if item.ChrgitmLv == "1" {
  20678. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20679. }
  20680. if item.ChrgitmLv == "2" {
  20681. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20682. }
  20683. if item.ChrgitmLv == "3" {
  20684. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20685. }
  20686. }
  20687. }
  20688. var iteminfoStructs []service.IteminfoStruct
  20689. if bedCostTotal != 0 {
  20690. iteminfo.MedChrgitm = "01"
  20691. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20692. iteminfo.Amt = bedCostTotal
  20693. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20694. iteminfo.ClabAmt = bed_clab_amt
  20695. iteminfo.OthAmt = bed_other_amt
  20696. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20697. }
  20698. if checkCostTotal != 0 {
  20699. iteminfo.MedChrgitm = "03"
  20700. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20701. iteminfo.Amt = checkCostTotal
  20702. iteminfo.ClaaSumfee = check_claa_sunmfee
  20703. iteminfo.ClabAmt = check_clab_amt
  20704. iteminfo.OthAmt = check_other_amt
  20705. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20706. }
  20707. if laboratoryCostTotal != 0 {
  20708. iteminfo.MedChrgitm = "04"
  20709. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20710. iteminfo.Amt = laboratoryCostTotal
  20711. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20712. iteminfo.ClabAmt = laboratory_clab_amt
  20713. iteminfo.OthAmt = laboratory_other_amt
  20714. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20715. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20716. }
  20717. if treatCostTotal != 0 {
  20718. iteminfo.MedChrgitm = "05"
  20719. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20720. iteminfo.Amt = treatCostTotal
  20721. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20722. iteminfo.ClabAmt = treat_clab_amt
  20723. iteminfo.OthAmt = treat_other_amt
  20724. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20725. //(struct4101.IteminfoStruct, iteminfo)
  20726. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20727. }
  20728. if operationCostTotal != 0 {
  20729. iteminfo.MedChrgitm = "06"
  20730. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20731. iteminfo.Amt = operationCostTotal
  20732. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20733. iteminfo.ClabAmt = operation_clab_amt
  20734. iteminfo.OthAmt = operation_other_amt
  20735. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20736. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20737. }
  20738. if materialCostTotal != 0 {
  20739. iteminfo.MedChrgitm = "08"
  20740. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20741. iteminfo.Amt = materialCostTotal
  20742. iteminfo.ClaaSumfee = material_claa_sunmfee
  20743. iteminfo.ClabAmt = material_clab_amt
  20744. iteminfo.OthAmt = material_other_amt
  20745. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20746. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20747. }
  20748. if westernMedicineCostTotal != 0 {
  20749. iteminfo.MedChrgitm = "09"
  20750. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20751. iteminfo.Amt = westernMedicineCostTotal
  20752. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20753. iteminfo.ClabAmt = westernMedicine_clab_amt
  20754. iteminfo.OthAmt = westernMedicine_other_amt
  20755. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20756. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20757. }
  20758. if chineseTraditionalMedicineCostTotal != 0 {
  20759. iteminfo.MedChrgitm = "11"
  20760. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20761. iteminfo.Amt = westernMedicineCostTotal
  20762. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20763. iteminfo.ClabAmt = westernMedicine_clab_amt
  20764. iteminfo.OthAmt = westernMedicine_other_amt
  20765. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20766. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20767. }
  20768. if otherCostTotal != 0 {
  20769. iteminfo.MedChrgitm = "14"
  20770. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20771. iteminfo.Amt = otherCostTotal
  20772. iteminfo.ClaaSumfee = other_claa_sunmfee
  20773. iteminfo.ClabAmt = other_clab_amt
  20774. iteminfo.OthAmt = other_other_amt
  20775. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20776. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20777. }
  20778. struct4101.IteminfoStruct = iteminfoStructs
  20779. struct4101.Ntly = "中国"
  20780. struct4101.AdmCaty = "A03.06"
  20781. struct4101.DoctorName = doctor.UserName
  20782. struct4101.DoctorCode = doctor.DoctorNumber
  20783. var res ResultSeventeen
  20784. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20785. struct4101.BillCode = order.Number
  20786. struct4101.BillNo = order.SetlId
  20787. var resOther ResultSeventeenOther
  20788. var pp models.PublicParams
  20789. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20790. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20791. pp.FixmedinsName = miConfig.OrgName
  20792. pp.FixmedinsCode = miConfig.Code
  20793. pp.RequestUrl = miConfig.Url
  20794. pp.Cainfo = miConfig.Cainfo
  20795. pp.SecretKey = miConfig.SecretKey
  20796. pp.AccessKey = miConfig.AccessKey
  20797. pp.OpterName = curRoles.UserName
  20798. client := &http.Client{}
  20799. var req *http.Request
  20800. data := make(map[string]interface{})
  20801. data["struct4101"] = struct4101
  20802. data["pp"] = pp
  20803. bytesData, _ := json.Marshal(data)
  20804. if miConfig.MdtrtareaAdmvs == "320830" {
  20805. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20806. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20807. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20808. } else {
  20809. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20810. }
  20811. resp, _ := client.Do(req)
  20812. defer resp.Body.Close()
  20813. body, ioErr := ioutil.ReadAll(resp.Body)
  20814. if ioErr != nil {
  20815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20817. return
  20818. }
  20819. var respJSON map[string]interface{}
  20820. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20823. return
  20824. }
  20825. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20826. userJSONBytes, _ := json.Marshal(respJSON)
  20827. fmt.Println("log")
  20828. fmt.Println(string(userJSONBytes))
  20829. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20830. utils.ErrorLog("解析失败:%v", err)
  20831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20832. return
  20833. }
  20834. res.InfRefmsgid = resOther.InfRefmsgid
  20835. res.Output = resOther.Output
  20836. res.ErrMsg = resOther.ErrMsg
  20837. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20838. res.Infcode = infocode
  20839. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20840. var pp models.PublicParams
  20841. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20842. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20843. pp.FixmedinsName = miConfig.OrgName
  20844. pp.FixmedinsCode = miConfig.Code
  20845. pp.RequestUrl = miConfig.Url
  20846. pp.Cainfo = miConfig.Cainfo
  20847. pp.SecretKey = miConfig.SecretKey
  20848. pp.AccessKey = miConfig.AccessKey
  20849. pp.OpterName = curRoles.UserName
  20850. result, _ := service.Jxyb4101(struct4101, pp)
  20851. var dat map[string]interface{}
  20852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20853. fmt.Println(dat)
  20854. } else {
  20855. fmt.Println(err)
  20856. }
  20857. userJSONBytes, _ := json.Marshal(dat)
  20858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20859. utils.ErrorLog("解析失败:%v", err)
  20860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20861. return
  20862. }
  20863. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20864. var pp models.PublicParams
  20865. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20866. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20867. pp.FixmedinsName = miConfig.OrgName
  20868. pp.FixmedinsCode = miConfig.Code
  20869. pp.RequestUrl = miConfig.Url
  20870. pp.Cainfo = miConfig.Cainfo
  20871. pp.SecretKey = miConfig.SecretKey
  20872. pp.AccessKey = miConfig.AccessKey
  20873. pp.OpterName = curRoles.UserName
  20874. result, _ := service.Jxyb4101(struct4101, pp)
  20875. var dat map[string]interface{}
  20876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20877. fmt.Println(dat)
  20878. } else {
  20879. fmt.Println(err)
  20880. }
  20881. userJSONBytes, _ := json.Marshal(dat)
  20882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20883. utils.ErrorLog("解析失败:%v", err)
  20884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20885. return
  20886. }
  20887. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20888. var pp models.PublicParams
  20889. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20890. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20891. pp.FixmedinsName = miConfig.OrgName
  20892. pp.FixmedinsCode = miConfig.Code
  20893. pp.RequestUrl = miConfig.Url
  20894. pp.Cainfo = miConfig.Cainfo
  20895. pp.SecretKey = miConfig.SecretKey
  20896. pp.AccessKey = miConfig.AccessKey
  20897. pp.OpterName = curRoles.UserName
  20898. result, _ := service.Jxyb4101(struct4101, pp)
  20899. var dat map[string]interface{}
  20900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20901. fmt.Println(dat)
  20902. } else {
  20903. fmt.Println(err)
  20904. }
  20905. userJSONBytes, _ := json.Marshal(dat)
  20906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20907. utils.ErrorLog("解析失败:%v", err)
  20908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20909. return
  20910. }
  20911. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20912. var pp models.PublicParams
  20913. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20914. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20915. pp.FixmedinsName = miConfig.OrgName
  20916. pp.FixmedinsCode = miConfig.Code
  20917. pp.RequestUrl = miConfig.Url
  20918. pp.Cainfo = miConfig.Cainfo
  20919. pp.SecretKey = miConfig.SecretKey
  20920. pp.AccessKey = miConfig.AccessKey
  20921. pp.OpterName = curRoles.UserName
  20922. result, _ := service.Hnyb4101(struct4101, pp)
  20923. var dat map[string]interface{}
  20924. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20925. fmt.Println(dat)
  20926. } else {
  20927. fmt.Println(err)
  20928. }
  20929. userJSONBytes, _ := json.Marshal(dat)
  20930. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20931. utils.ErrorLog("解析失败:%v", err)
  20932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20933. return
  20934. }
  20935. } else if miConfig.MdtrtareaAdmvs == "150404" {
  20936. var resOther ResultSeventeenOther
  20937. var pp models.PublicParams
  20938. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20939. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20940. pp.FixmedinsName = miConfig.OrgName
  20941. pp.FixmedinsCode = miConfig.Code
  20942. pp.RequestUrl = miConfig.Url
  20943. pp.Cainfo = miConfig.Cainfo
  20944. pp.SecretKey = miConfig.SecretKey
  20945. pp.AccessKey = miConfig.AccessKey
  20946. pp.OpterName = curRoles.UserName
  20947. client := &http.Client{}
  20948. var req *http.Request
  20949. data := make(map[string]interface{})
  20950. data["struct4101"] = struct4101
  20951. data["pp"] = pp
  20952. bytesData, _ := json.Marshal(data)
  20953. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20954. resp, _ := client.Do(req)
  20955. defer resp.Body.Close()
  20956. body, ioErr := ioutil.ReadAll(resp.Body)
  20957. if ioErr != nil {
  20958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20960. return
  20961. }
  20962. var respJSON map[string]interface{}
  20963. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20966. return
  20967. }
  20968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20969. userJSONBytes, _ := json.Marshal(respJSON)
  20970. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20971. utils.ErrorLog("解析失败:%v", err)
  20972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20973. return
  20974. }
  20975. res.InfRefmsgid = resOther.InfRefmsgid
  20976. res.Output = resOther.Output
  20977. res.ErrMsg = resOther.ErrMsg
  20978. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20979. res.Infcode = infocode
  20980. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20981. var pp models.PublicParams
  20982. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20983. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20984. pp.FixmedinsName = miConfig.OrgName
  20985. pp.FixmedinsCode = miConfig.Code
  20986. pp.RequestUrl = miConfig.Url
  20987. pp.Cainfo = miConfig.Cainfo
  20988. pp.SecretKey = miConfig.SecretKey
  20989. pp.AccessKey = miConfig.AccessKey
  20990. pp.OpterName = curRoles.UserName
  20991. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20992. fmt.Println(requestLog)
  20993. fmt.Println(errMsgLog)
  20994. saveLog(result, requestLog, "4101a", "上传清单")
  20995. var dat map[string]interface{}
  20996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20997. fmt.Println(dat)
  20998. } else {
  20999. fmt.Println(err)
  21000. }
  21001. userJSONBytes, _ := json.Marshal(dat)
  21002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21003. utils.ErrorLog("解析失败:%v", err)
  21004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21005. return
  21006. }
  21007. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21008. var pp models.PublicParams
  21009. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21010. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21011. pp.FixmedinsName = miConfig.OrgName
  21012. pp.FixmedinsCode = miConfig.Code
  21013. pp.RequestUrl = miConfig.Url
  21014. pp.Cainfo = miConfig.Cainfo
  21015. pp.SecretKey = miConfig.SecretKey
  21016. pp.AccessKey = miConfig.AccessKey
  21017. pp.OpterName = curRoles.UserName
  21018. client := &http.Client{}
  21019. var req *http.Request
  21020. data := make(map[string]interface{})
  21021. data["struct4101"] = struct4101
  21022. data["pp"] = pp
  21023. bytesData, _ := json.Marshal(data)
  21024. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  21025. resp, _ := client.Do(req)
  21026. defer resp.Body.Close()
  21027. body, ioErr := ioutil.ReadAll(resp.Body)
  21028. if ioErr != nil {
  21029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21031. return
  21032. }
  21033. var respJSON map[string]interface{}
  21034. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21037. return
  21038. }
  21039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21040. userJSONBytes, _ := json.Marshal(respJSON)
  21041. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21042. utils.ErrorLog("解析失败:%v", err)
  21043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21044. return
  21045. }
  21046. } else {
  21047. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21048. var dat map[string]interface{}
  21049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21050. fmt.Println(dat)
  21051. } else {
  21052. fmt.Println(err)
  21053. }
  21054. userJSONBytes, _ := json.Marshal(dat)
  21055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21056. utils.ErrorLog("解析失败:%v", err)
  21057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21058. return
  21059. }
  21060. }
  21061. if res.Infcode != 0 {
  21062. c.ServeSuccessJSON(map[string]interface{}{
  21063. "failed_code": -10,
  21064. "msg": res.ErrMsg,
  21065. })
  21066. return
  21067. } else {
  21068. //order.FaPiaoNumber = zero
  21069. //order.FaPiaoCode = last_order.FaPiaoCode
  21070. //service.UpdateOrder(order)
  21071. hisFundSettleListResult := &models.HisFundSettleListResult{
  21072. Number: res.Output.SetlListId,
  21073. Status: 1,
  21074. Ctime: time.Now().Unix(),
  21075. Mtime: time.Now().Unix(),
  21076. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21077. IsUpload: 1,
  21078. OrderId: order_id,
  21079. }
  21080. service.CreateUploadRecord(hisFundSettleListResult)
  21081. c.ServeSuccessJSON(map[string]interface{}{
  21082. "msg": "上传成功",
  21083. "result": hisFundSettleListResult,
  21084. })
  21085. return
  21086. }
  21087. }
  21088. func (c *HisApiController) GetSettleListHospital() {
  21089. order_id, _ := c.GetInt64("order_id")
  21090. admin_user_id, _ := c.GetInt64("admin_user_id")
  21091. order, _ := service.GetHisOrderByIDTwo(order_id)
  21092. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21093. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  21094. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21095. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  21096. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21097. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21098. if order.ID == 0 {
  21099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21100. return
  21101. }
  21102. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  21103. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  21104. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  21105. fmt.Println(count)
  21106. var zero string
  21107. number := count + 1
  21108. if number >= 1000 {
  21109. zero = "0000" + strconv.FormatInt(number, 10)
  21110. } else if number >= 10000 {
  21111. zero = "000" + strconv.FormatInt(number, 10)
  21112. } else if number >= 100000 {
  21113. zero = "00" + strconv.FormatInt(number, 10)
  21114. } else if number >= 1000000 {
  21115. zero = "0" + strconv.FormatInt(number, 10)
  21116. } else {
  21117. zero = strconv.FormatInt(number, 10)
  21118. }
  21119. fmt.Println(zero)
  21120. struct4101 := service.Struct4101{
  21121. PsnNo: order.PsnNo,
  21122. MdtrtId: order.MdtrtId,
  21123. SetlId: order.SetlId,
  21124. PsnName: order.PsnName,
  21125. Gend: order.Gend,
  21126. Brdy: his.Brdy,
  21127. Age: int64(order.Age),
  21128. Naty: order.Naty,
  21129. PatnCertType: "01",
  21130. Certno: order.Certno,
  21131. Prfs: "90",
  21132. ConerName: roles[0].UserName,
  21133. PatnRlts: "99",
  21134. ConerAddr: miConfig.OrgName,
  21135. ConerTel: admin.Mobile,
  21136. HiType: order.Insutype,
  21137. Insuplc: miConfig.InsuplcAdmdvs,
  21138. MaindiagFlag: "1",
  21139. BillCode: order.SetlId,
  21140. BillNo: order.SetlId,
  21141. BizSn: order.Number,
  21142. PsnSelfPay: order.PsnPartAmt,
  21143. PsnOwnPay: order.PsnPartAmt,
  21144. AcctPay: order.AcctPay,
  21145. PsnCashpay: order.PsnCashPay,
  21146. HiPaymtd: "1",
  21147. Hsorg: miConfig.InsuplcAdmdvs,
  21148. HsorgOpter: miConfig.InsuplcAdmdvs,
  21149. MedinsFillPsn: curRoles.UserName,
  21150. MedinsFillDept: depart.Name,
  21151. IptMedType: "2",
  21152. AdmTime: his.InHosptialTime,
  21153. AdmEndTime: his.OutHosptialTime,
  21154. }
  21155. struct4101.SetlBegnDate = order.SetlTime
  21156. struct4101.SetlEndDate = order.SetlTime
  21157. //var rf []CustomFundPay
  21158. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21159. //
  21160. //var tempFunPays []service.CustomStruct
  21161. //for _, item := range rf {
  21162. // var tempFunPay service.CustomStruct
  21163. // tempFunPay.FundPayamt = item.FundPayamt
  21164. // tempFunPay.FundPayType = item.FundPayType
  21165. // tempFunPays = append(tempFunPays, tempFunPay)
  21166. //}
  21167. //struct4101.CustomStruct = tempFunPays
  21168. var tempDiaginfos []service.DiaginfoStructTwo
  21169. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21170. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21171. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21172. //for _, item := range infos {
  21173. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21174. //}
  21175. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21176. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21177. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21178. fmt.Println(diagnosis_ids_arr)
  21179. if order.UserOrgId == 10210 {
  21180. var diagnosis_ids_arr_two []int64
  21181. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21182. var config []*models.HisXtDiagnoseConfig
  21183. for _, id := range diagnosis_ids_arr_two {
  21184. //id, _ := strconv.ParseInt(item, 10, 64)
  21185. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21186. if diagnosisConfig.ID > 0 {
  21187. config = append(config, &diagnosisConfig)
  21188. }
  21189. }
  21190. for index, item := range config {
  21191. if item.ID > 0 {
  21192. if index == 0 {
  21193. var tempDiaginfo service.DiaginfoStructTwo
  21194. tempDiaginfo.DiagCode = item.CountryCode
  21195. tempDiaginfo.DiagName = item.CountryContentName
  21196. tempDiaginfo.DiagType = "1"
  21197. tempDiaginfo.MaindiagFlag = "1"
  21198. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21199. } else {
  21200. var tempDiaginfo service.DiaginfoStructTwo
  21201. tempDiaginfo.DiagCode = item.CountryCode
  21202. tempDiaginfo.DiagName = item.CountryContentName
  21203. tempDiaginfo.DiagType = "1"
  21204. tempDiaginfo.MaindiagFlag = "0"
  21205. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21206. }
  21207. }
  21208. }
  21209. struct4101.Diseinfo = tempDiaginfos
  21210. } else {
  21211. var config []*models.HisXtDiagnoseConfig
  21212. for _, item := range diagnosis_ids_arr {
  21213. id, _ := strconv.ParseInt(item, 10, 64)
  21214. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21215. if diagnosisConfig.ID > 0 {
  21216. config = append(config, &diagnosisConfig)
  21217. }
  21218. }
  21219. for index, item := range config {
  21220. if item.ID > 0 {
  21221. if index == 0 {
  21222. var tempDiaginfo service.DiaginfoStructTwo
  21223. tempDiaginfo.DiagCode = item.CountryCode
  21224. tempDiaginfo.DiagName = item.CountryContentName
  21225. tempDiaginfo.DiagType = "1"
  21226. tempDiaginfo.MaindiagFlag = "1"
  21227. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21228. } else {
  21229. var tempDiaginfo service.DiaginfoStructTwo
  21230. tempDiaginfo.DiagCode = item.CountryCode
  21231. tempDiaginfo.DiagName = item.CountryContentName
  21232. tempDiaginfo.DiagType = "1"
  21233. tempDiaginfo.MaindiagFlag = "0"
  21234. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21235. }
  21236. }
  21237. }
  21238. struct4101.Diseinfo = tempDiaginfos
  21239. }
  21240. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21241. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21242. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21243. tempOpspdiseinfo2.OprnOprtCode = ""
  21244. tempOpspdiseinfo2.OprnOprtName = ""
  21245. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21246. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21247. var iteminfo service.IteminfoStruct
  21248. var bedCostTotal float64 = 0 //床位总费
  21249. var bedCostSelfTotal float64 = 0 //床位自费
  21250. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21251. var operationCostTotal float64 = 0 //手术费
  21252. var operationCostSelfTotal float64 = 0 //手术费
  21253. var operationCostPartSelfTotal float64 = 0 //手术费
  21254. var otherCostTotal float64 = 0 //其他费用
  21255. var otherCostSelfTotal float64 = 0 //其他费用
  21256. var otherCostPartSelfTotal float64 = 0 //其他费用
  21257. var materialCostTotal float64 = 0 //材料费
  21258. var materialCostSelfTotal float64 = 0 //材料费
  21259. var materialCostPartSelfTotal float64 = 0 //材料费
  21260. var westernMedicineCostTotal float64 = 0 //西药费
  21261. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21262. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21263. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21264. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21265. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21266. var checkCostTotal float64 = 0 //检查费
  21267. var checkCostSelfTotal float64 = 0 //检查费
  21268. var checkCostPartSelfTotal float64 = 0 //检查费
  21269. var laboratoryCostTotal float64 = 0 //化验费
  21270. var laboratoryCostSelfTotal float64 = 0 //化验费
  21271. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21272. var treatCostTotal float64 = 0 //治疗费用
  21273. var treatCostSelfTotal float64 = 0 //治疗费用
  21274. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21275. decimal.DivisionPrecision = 2
  21276. var bed_fulamt_ownpay_amt float64 = 0
  21277. var operation_fulamt_ownpay_amt float64 = 0
  21278. var other_fulamt_ownpay_amt float64 = 0
  21279. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21280. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21281. var check_fulamt_ownpay_amt float64 = 0
  21282. var material_fulamt_ownpay_amt float64 = 0
  21283. var laboratory_fulamt_ownpay_amt float64 = 0
  21284. var treat_fulamt_ownpay_amt float64 = 0
  21285. var bed_claa_sunmfee float64 = 0
  21286. var bed_clab_amt float64 = 0
  21287. var bed_other_amt float64 = 0
  21288. var operation_claa_sunmfee float64 = 0
  21289. var operation_clab_amt float64 = 0
  21290. var operation_other_amt float64 = 0
  21291. var other_claa_sunmfee float64 = 0
  21292. var other_clab_amt float64 = 0
  21293. var other_other_amt float64 = 0
  21294. var westernMedicine_claa_sunmfee float64 = 0
  21295. var westernMedicine_clab_amt float64 = 0
  21296. var westernMedicine_other_amt float64 = 0
  21297. var chineseTraditional_claa_sunmfee float64 = 0
  21298. var chineseTraditional_clab_amt float64 = 0
  21299. var chineseTraditional_other_amt float64 = 0
  21300. var check_claa_sunmfee float64 = 0
  21301. var check_clab_amt float64 = 0
  21302. var check_other_amt float64 = 0
  21303. var material_claa_sunmfee float64 = 0
  21304. var material_clab_amt float64 = 0
  21305. var material_other_amt float64 = 0
  21306. var laboratory_claa_sunmfee float64 = 0
  21307. var laboratory_clab_amt float64 = 0
  21308. var laboratory_other_amt float64 = 0
  21309. var treat_claa_sunmfee float64 = 0
  21310. var treat_clab_amt float64 = 0
  21311. var treat_other_amt float64 = 0
  21312. for _, item := range order.HisOrderInfo {
  21313. if item.MedChrgitmType == "01" { //床位费
  21314. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21315. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21316. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21317. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21318. if item.ChrgitmLv == "1" {
  21319. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21320. }
  21321. if item.ChrgitmLv == "2" {
  21322. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21323. }
  21324. if item.ChrgitmLv == "3" {
  21325. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21326. }
  21327. }
  21328. if item.MedChrgitmType == "03" { //检查费
  21329. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21330. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21331. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21332. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21333. if item.ChrgitmLv == "1" {
  21334. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21335. }
  21336. if item.ChrgitmLv == "2" {
  21337. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21338. }
  21339. if item.ChrgitmLv == "3" {
  21340. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21341. }
  21342. }
  21343. if item.MedChrgitmType == "04" { //化验费
  21344. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21345. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21346. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21347. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21348. if item.ChrgitmLv == "1" {
  21349. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21350. }
  21351. if item.ChrgitmLv == "2" {
  21352. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21353. }
  21354. if item.ChrgitmLv == "3" {
  21355. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21356. }
  21357. }
  21358. if item.MedChrgitmType == "05" { //治疗费
  21359. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21360. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21361. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21362. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21363. if item.ChrgitmLv == "1" {
  21364. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21365. }
  21366. if item.ChrgitmLv == "2" {
  21367. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21368. }
  21369. if item.ChrgitmLv == "3" {
  21370. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21371. }
  21372. }
  21373. if item.MedChrgitmType == "06" { //手术费
  21374. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21375. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21376. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21377. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21378. if item.ChrgitmLv == "1" {
  21379. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21380. }
  21381. if item.ChrgitmLv == "2" {
  21382. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21383. }
  21384. if item.ChrgitmLv == "3" {
  21385. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21386. }
  21387. }
  21388. if item.MedChrgitmType == "08" { //材料费
  21389. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21390. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21391. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21392. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21393. if item.ChrgitmLv == "1" {
  21394. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21395. }
  21396. if item.ChrgitmLv == "2" {
  21397. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21398. }
  21399. if item.ChrgitmLv == "3" {
  21400. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21401. }
  21402. }
  21403. if item.MedChrgitmType == "09" { //西药费
  21404. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21405. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21406. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21407. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21408. if item.ChrgitmLv == "1" {
  21409. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21410. }
  21411. if item.ChrgitmLv == "2" {
  21412. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21413. }
  21414. if item.ChrgitmLv == "3" {
  21415. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21416. }
  21417. }
  21418. if item.MedChrgitmType == "11" { //中成费
  21419. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21420. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21421. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21422. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21423. if item.ChrgitmLv == "1" {
  21424. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21425. }
  21426. if item.ChrgitmLv == "2" {
  21427. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21428. }
  21429. if item.ChrgitmLv == "3" {
  21430. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21431. }
  21432. }
  21433. if item.MedChrgitmType == "14" { //其他费
  21434. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21435. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21436. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21437. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21438. if item.ChrgitmLv == "1" {
  21439. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21440. }
  21441. if item.ChrgitmLv == "2" {
  21442. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21443. }
  21444. if item.ChrgitmLv == "3" {
  21445. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21446. }
  21447. }
  21448. }
  21449. var iteminfoStructs []service.IteminfoStruct
  21450. if bedCostTotal != 0 {
  21451. iteminfo.MedChrgitm = "01"
  21452. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21453. iteminfo.Amt = bedCostTotal
  21454. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21455. iteminfo.ClabAmt = bed_clab_amt
  21456. iteminfo.OthAmt = bed_other_amt
  21457. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21458. }
  21459. if checkCostTotal != 0 {
  21460. iteminfo.MedChrgitm = "03"
  21461. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21462. iteminfo.Amt = checkCostTotal
  21463. iteminfo.ClaaSumfee = check_claa_sunmfee
  21464. iteminfo.ClabAmt = check_clab_amt
  21465. iteminfo.OthAmt = check_other_amt
  21466. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21467. }
  21468. if laboratoryCostTotal != 0 {
  21469. iteminfo.MedChrgitm = "04"
  21470. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21471. iteminfo.Amt = laboratoryCostTotal
  21472. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21473. iteminfo.ClabAmt = laboratory_clab_amt
  21474. iteminfo.OthAmt = laboratory_other_amt
  21475. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21476. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21477. }
  21478. if treatCostTotal != 0 {
  21479. iteminfo.MedChrgitm = "05"
  21480. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21481. iteminfo.Amt = treatCostTotal
  21482. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21483. iteminfo.ClabAmt = treat_clab_amt
  21484. iteminfo.OthAmt = treat_other_amt
  21485. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21486. //(struct4101.IteminfoStruct, iteminfo)
  21487. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21488. }
  21489. if operationCostTotal != 0 {
  21490. iteminfo.MedChrgitm = "06"
  21491. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21492. iteminfo.Amt = operationCostTotal
  21493. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21494. iteminfo.ClabAmt = operation_clab_amt
  21495. iteminfo.OthAmt = operation_other_amt
  21496. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21497. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21498. }
  21499. if materialCostTotal != 0 {
  21500. iteminfo.MedChrgitm = "08"
  21501. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21502. iteminfo.Amt = materialCostTotal
  21503. iteminfo.ClaaSumfee = material_claa_sunmfee
  21504. iteminfo.ClabAmt = material_clab_amt
  21505. iteminfo.OthAmt = material_other_amt
  21506. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21507. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21508. }
  21509. if westernMedicineCostTotal != 0 {
  21510. iteminfo.MedChrgitm = "09"
  21511. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21512. iteminfo.Amt = westernMedicineCostTotal
  21513. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21514. iteminfo.ClabAmt = westernMedicine_clab_amt
  21515. iteminfo.OthAmt = westernMedicine_other_amt
  21516. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21517. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21518. }
  21519. if chineseTraditionalMedicineCostTotal != 0 {
  21520. iteminfo.MedChrgitm = "11"
  21521. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21522. iteminfo.Amt = westernMedicineCostTotal
  21523. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21524. iteminfo.ClabAmt = westernMedicine_clab_amt
  21525. iteminfo.OthAmt = westernMedicine_other_amt
  21526. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21527. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21528. }
  21529. if otherCostTotal != 0 {
  21530. iteminfo.MedChrgitm = "14"
  21531. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21532. iteminfo.Amt = otherCostTotal
  21533. iteminfo.ClaaSumfee = other_claa_sunmfee
  21534. iteminfo.ClabAmt = other_clab_amt
  21535. iteminfo.OthAmt = other_other_amt
  21536. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21537. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21538. }
  21539. struct4101.IteminfoStruct = iteminfoStructs
  21540. struct4101.Ntly = "中国"
  21541. struct4101.AdmCaty = "A03.06"
  21542. var resOther ResultSeventeenOther
  21543. var res ResultSeventeen
  21544. if miConfig.MdtrtareaAdmvs == "150404" {
  21545. var pp models.PublicParams
  21546. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21547. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21548. pp.FixmedinsName = miConfig.OrgName
  21549. pp.FixmedinsCode = miConfig.Code
  21550. pp.RequestUrl = miConfig.Url
  21551. pp.Cainfo = miConfig.Cainfo
  21552. pp.SecretKey = miConfig.SecretKey
  21553. pp.AccessKey = miConfig.AccessKey
  21554. pp.OpterName = curRoles.UserName
  21555. client := &http.Client{}
  21556. var req *http.Request
  21557. data := make(map[string]interface{})
  21558. data["struct4101"] = struct4101
  21559. data["pp"] = pp
  21560. bytesData, _ := json.Marshal(data)
  21561. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21562. resp, _ := client.Do(req)
  21563. defer resp.Body.Close()
  21564. body, ioErr := ioutil.ReadAll(resp.Body)
  21565. if ioErr != nil {
  21566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21568. return
  21569. }
  21570. var respJSON map[string]interface{}
  21571. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21574. return
  21575. }
  21576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21577. userJSONBytes, _ := json.Marshal(respJSON)
  21578. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21579. utils.ErrorLog("解析失败:%v", err)
  21580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21581. return
  21582. }
  21583. res.InfRefmsgid = resOther.InfRefmsgid
  21584. res.Output = resOther.Output
  21585. res.ErrMsg = resOther.ErrMsg
  21586. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21587. res.Infcode = infocode
  21588. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21589. var pp models.PublicParams
  21590. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21591. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21592. pp.FixmedinsName = miConfig.OrgName
  21593. pp.FixmedinsCode = miConfig.Code
  21594. pp.RequestUrl = miConfig.Url
  21595. pp.Cainfo = miConfig.Cainfo
  21596. pp.SecretKey = miConfig.SecretKey
  21597. pp.AccessKey = miConfig.AccessKey
  21598. pp.OpterName = curRoles.UserName
  21599. result, _ := service.Jxyb4101(struct4101, pp)
  21600. var dat map[string]interface{}
  21601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21602. fmt.Println(dat)
  21603. } else {
  21604. fmt.Println(err)
  21605. }
  21606. userJSONBytes, _ := json.Marshal(dat)
  21607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21608. utils.ErrorLog("解析失败:%v", err)
  21609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21610. return
  21611. }
  21612. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21613. var pp models.PublicParams
  21614. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21615. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21616. pp.FixmedinsName = miConfig.OrgName
  21617. pp.FixmedinsCode = miConfig.Code
  21618. pp.RequestUrl = miConfig.Url
  21619. pp.Cainfo = miConfig.Cainfo
  21620. pp.SecretKey = miConfig.SecretKey
  21621. pp.AccessKey = miConfig.AccessKey
  21622. pp.OpterName = curRoles.UserName
  21623. result, _ := service.Jxyb4101(struct4101, pp)
  21624. var dat map[string]interface{}
  21625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21626. fmt.Println(dat)
  21627. } else {
  21628. fmt.Println(err)
  21629. }
  21630. userJSONBytes, _ := json.Marshal(dat)
  21631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21632. utils.ErrorLog("解析失败:%v", err)
  21633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21634. return
  21635. }
  21636. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21637. var pp models.PublicParams
  21638. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21639. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21640. pp.FixmedinsName = miConfig.OrgName
  21641. pp.FixmedinsCode = miConfig.Code
  21642. pp.RequestUrl = miConfig.Url
  21643. pp.Cainfo = miConfig.Cainfo
  21644. pp.SecretKey = miConfig.SecretKey
  21645. pp.AccessKey = miConfig.AccessKey
  21646. pp.OpterName = curRoles.UserName
  21647. result, _ := service.Jxyb4101(struct4101, pp)
  21648. var dat map[string]interface{}
  21649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21650. fmt.Println(dat)
  21651. } else {
  21652. fmt.Println(err)
  21653. }
  21654. userJSONBytes, _ := json.Marshal(dat)
  21655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21656. utils.ErrorLog("解析失败:%v", err)
  21657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21658. return
  21659. }
  21660. } else {
  21661. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21662. var dat map[string]interface{}
  21663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21664. fmt.Println(dat)
  21665. } else {
  21666. fmt.Println(err)
  21667. }
  21668. userJSONBytes, _ := json.Marshal(dat)
  21669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21670. utils.ErrorLog("解析失败:%v", err)
  21671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21672. return
  21673. }
  21674. }
  21675. if res.Infcode != 0 {
  21676. c.ServeSuccessJSON(map[string]interface{}{
  21677. "failed_code": -10,
  21678. "msg": res.ErrMsg,
  21679. })
  21680. return
  21681. } else {
  21682. if miConfig.MdtrtareaAdmvs != "150404" {
  21683. order.FaPiaoNumber = zero
  21684. order.FaPiaoCode = last_order.FaPiaoCode
  21685. service.UpdateOrder(order)
  21686. }
  21687. hisFundSettleListResult := &models.HisFundSettleListResult{
  21688. Number: res.Output.SetlListId,
  21689. Status: 1,
  21690. Ctime: time.Now().Unix(),
  21691. Mtime: time.Now().Unix(),
  21692. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21693. IsUpload: 1,
  21694. OrderId: order_id,
  21695. }
  21696. service.CreateUploadRecord(hisFundSettleListResult)
  21697. c.ServeSuccessJSON(map[string]interface{}{
  21698. "msg": "上传成功",
  21699. "result": hisFundSettleListResult,
  21700. })
  21701. return
  21702. }
  21703. }
  21704. //func (c *HisApiController) GetBatchSettleList() {
  21705. // orders, _ := service.GetAllHisOrder(10106)
  21706. // for _, item := range orders {
  21707. // order_id := item.ID
  21708. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21709. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21710. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21711. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21712. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21713. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21714. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21715. //
  21716. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21717. //
  21718. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21719. //
  21720. // if order.ID == 0 {
  21721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21722. // return
  21723. // }
  21724. // if his.BalanceAccountsType == 2 {
  21725. // continue
  21726. // }
  21727. // struct4101 := service.Struct4101{
  21728. // PsnNo: order.PsnNo,
  21729. // MdtrtId: order.MdtrtId,
  21730. // SetlId: order.SetlId,
  21731. // PsnName: order.PsnName,
  21732. // Gend: order.Gend,
  21733. // Brdy: his.Brdy,
  21734. // Age: his.Age,
  21735. // Naty: order.Naty,
  21736. // PatnCertType: "01",
  21737. // Certno: order.Certno,
  21738. // Prfs: "90",
  21739. // ConerName: roles[0].UserName,
  21740. // PatnRlts: "99",
  21741. // ConerAddr: miConfig.OrgName,
  21742. // ConerTel: admin.Mobile,
  21743. // HiType: order.Insutype,
  21744. // Insuplc: his.InsuplcAdmdvs,
  21745. // MaindiagFlag: "1",
  21746. // BillCode: order.SetlId,
  21747. // BillNo: order.SetlId,
  21748. // BizSn: order.Number,
  21749. // PsnSelfPay: order.PsnPartAmt,
  21750. // PsnOwnPay: order.PsnPartAmt,
  21751. // AcctPay: order.AcctPay,
  21752. // PsnCashpay: order.PsnCashPay,
  21753. // HiPaymtd: "1",
  21754. // Hsorg: his.InsuplcAdmdvs,
  21755. // HsorgOpter: his.InsuplcAdmdvs,
  21756. // MedinsFillPsn: curRoles.UserName,
  21757. // MedinsFillDept: depart.Name,
  21758. // IptMedType: "2",
  21759. // }
  21760. // struct4101.SetlBegnDate = order.SetlTime
  21761. // struct4101.SetlEndDate = order.SetlTime
  21762. // //if order.SettleType == 1 {
  21763. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21764. // // dateStr := t.Format("2006-01-02")
  21765. // // struct4101.SetlBegnDate = dateStr
  21766. // // struct4101.SetlEndDate = dateStr
  21767. // //} else {
  21768. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21769. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21770. // // dateStartStr := t.Format("2006-01-02")
  21771. // // dateEndStr := t2.Format("2006-01-02")
  21772. // // struct4101.SetlBegnDate = dateStartStr
  21773. // // struct4101.SetlEndDate = dateEndStr
  21774. // //}
  21775. //
  21776. // var rf []CustomFundPay
  21777. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21778. //
  21779. // var tempFunPays []service.CustomStruct
  21780. // var tempFunPay610100 service.CustomStruct
  21781. //
  21782. // for _, item := range rf {
  21783. // if item.FundPayType == "610100" {
  21784. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21785. // tempFunPay610100.FundPayType = item.FundPayType
  21786. // } else {
  21787. // var tempFunPay service.CustomStruct
  21788. // tempFunPay.FundPayamt = item.FundPayamt
  21789. // tempFunPay.FundPayType = item.FundPayType
  21790. // tempFunPays = append(tempFunPays, tempFunPay)
  21791. // }
  21792. // }
  21793. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21794. // struct4101.CustomStruct = tempFunPays
  21795. //
  21796. // var tempDiaginfos []service.DiaginfoStructTwo
  21797. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21798. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21799. //
  21800. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21801. // var config []*models.HisXtDiagnoseConfig
  21802. // for _, item := range diagnosis_ids {
  21803. // id, _ := strconv.ParseInt(item, 10, 64)
  21804. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21805. // config = append(config, &diagnosisConfig)
  21806. // }
  21807. //
  21808. // for index, item := range config {
  21809. // if index == 0 {
  21810. // var tempDiaginfo service.DiaginfoStructTwo
  21811. // tempDiaginfo.DiagCode = item.CountryCode
  21812. // tempDiaginfo.DiagName = item.CountryContentName
  21813. // tempDiaginfo.DiagType = "1"
  21814. // tempDiaginfo.MaindiagFlag = "1"
  21815. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21816. // } else {
  21817. //
  21818. // var tempDiaginfo service.DiaginfoStructTwo
  21819. // tempDiaginfo.DiagCode = item.CountryCode
  21820. // tempDiaginfo.DiagName = item.CountryContentName
  21821. // tempDiaginfo.DiagType = "2"
  21822. // tempDiaginfo.MaindiagFlag = "0"
  21823. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21824. // }
  21825. // }
  21826. // struct4101.Diseinfo = tempDiaginfos
  21827. //
  21828. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21829. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21830. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21831. // tempOpspdiseinfo2.OprnOprtCode = ""
  21832. // tempOpspdiseinfo2.OprnOprtName = ""
  21833. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21834. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21835. //
  21836. // var iteminfo service.IteminfoStruct
  21837. //
  21838. // var bedCostTotal float64 = 0 //床位总费
  21839. // var bedCostSelfTotal float64 = 0 //床位自费
  21840. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21841. //
  21842. // var examineCostTotal float64 = 0 //诊查总费
  21843. // var examineCostSelfTotal float64 = 0 //诊查自费
  21844. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21845. //
  21846. // var nursingCostTotal float64 = 0 //护理总费
  21847. // var nursingCostSelfTotal float64 = 0 //护理自费
  21848. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21849. //
  21850. // var chineseMedicineCostTotal float64 = 0 //中成药
  21851. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21852. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21853. //
  21854. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21855. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21856. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21857. //
  21858. // var registerCostTotal float64 = 0 //一般诊疗费
  21859. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21860. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21861. //
  21862. // var operationCostTotal float64 = 0 //手术费
  21863. // var operationCostSelfTotal float64 = 0 //手术费
  21864. // var operationCostPartSelfTotal float64 = 0 //手术费
  21865. //
  21866. // var otherCostTotal float64 = 0 //其他费用
  21867. // var otherCostSelfTotal float64 = 0 //其他费用
  21868. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21869. //
  21870. // var materialCostTotal float64 = 0 //材料费
  21871. // var materialCostSelfTotal float64 = 0 //材料费
  21872. // var materialCostPartSelfTotal float64 = 0 //材料费
  21873. //
  21874. // var westernMedicineCostTotal float64 = 0 //西药费
  21875. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21876. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21877. //
  21878. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21879. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21880. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21881. //
  21882. // var checkCostTotal float64 = 0 //检查费
  21883. // var checkCostSelfTotal float64 = 0 //检查费
  21884. // var checkCostPartSelfTotal float64 = 0 //检查费
  21885. //
  21886. // var laboratoryCostTotal float64 = 0 //化验费
  21887. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21888. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21889. //
  21890. // var treatCostTotal float64 = 0 //治疗费用
  21891. // var treatCostSelfTotal float64 = 0 //治疗费用
  21892. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21893. //
  21894. // decimal.DivisionPrecision = 2
  21895. //
  21896. // var bed_fulamt_ownpay_amt float64 = 0
  21897. //
  21898. // var examine_fulamt_ownpay_amt float64 = 0
  21899. //
  21900. // var nursing_fulamt_ownpay_amt float64 = 0
  21901. //
  21902. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21903. //
  21904. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21905. //
  21906. // var register_fulamt_ownpay_amt float64 = 0
  21907. //
  21908. // var operation_fulamt_ownpay_amt float64 = 0
  21909. // var other_fulamt_ownpay_amt float64 = 0
  21910. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21911. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21912. // var check_fulamt_ownpay_amt float64 = 0
  21913. // var material_fulamt_ownpay_amt float64 = 0
  21914. // var laboratory_fulamt_ownpay_amt float64 = 0
  21915. // var treat_fulamt_ownpay_amt float64 = 0
  21916. //
  21917. // var bed_claa_sunmfee float64 = 0
  21918. // var bed_clab_amt float64 = 0
  21919. // var bed_other_amt float64 = 0
  21920. //
  21921. // var examine_claa_sunmfee float64 = 0
  21922. // var examine_clab_amt float64 = 0
  21923. // var examine_other_amt float64 = 0
  21924. //
  21925. // var nursing_claa_sunmfee float64 = 0
  21926. // var nursing_clab_amt float64 = 0
  21927. // var nursing_other_amt float64 = 0
  21928. //
  21929. // var chinese_medicine_claa_sunmfee float64 = 0
  21930. // var chinese_medicine_clab_amt float64 = 0
  21931. // var chinese_medicine_other_amt float64 = 0
  21932. //
  21933. // var commonly_treatment_claa_sunmfee float64 = 0
  21934. // var commonly_treatment_clab_amt float64 = 0
  21935. // var commonly_treatment_other_amt float64 = 0
  21936. //
  21937. // var operation_claa_sunmfee float64 = 0
  21938. // var operation_clab_amt float64 = 0
  21939. // var operation_other_amt float64 = 0
  21940. //
  21941. // var other_claa_sunmfee float64 = 0
  21942. // var other_clab_amt float64 = 0
  21943. // var other_other_amt float64 = 0
  21944. //
  21945. // var westernMedicine_claa_sunmfee float64 = 0
  21946. // var westernMedicine_clab_amt float64 = 0
  21947. // var westernMedicine_other_amt float64 = 0
  21948. //
  21949. // var chineseTraditional_claa_sunmfee float64 = 0
  21950. // var chineseTraditional_clab_amt float64 = 0
  21951. // var chineseTraditional_other_amt float64 = 0
  21952. //
  21953. // var check_claa_sunmfee float64 = 0
  21954. // var check_clab_amt float64 = 0
  21955. // var check_other_amt float64 = 0
  21956. //
  21957. // var material_claa_sunmfee float64 = 0
  21958. // var material_clab_amt float64 = 0
  21959. // var material_other_amt float64 = 0
  21960. //
  21961. // var laboratory_claa_sunmfee float64 = 0
  21962. // var laboratory_clab_amt float64 = 0
  21963. // var laboratory_other_amt float64 = 0
  21964. //
  21965. // var treat_claa_sunmfee float64 = 0
  21966. // var treat_clab_amt float64 = 0
  21967. // var treat_other_amt float64 = 0
  21968. //
  21969. // var register_claa_sunmfee float64 = 0
  21970. // var register_clab_amt float64 = 0
  21971. // var register_other_amt float64 = 0
  21972. //
  21973. // for _, item := range order.HisOrderInfo {
  21974. // if item.MedChrgitmType == "01" { //床位费
  21975. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21976. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21977. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21978. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21979. // if item.ChrgitmLv == "1" {
  21980. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21981. // }
  21982. // if item.ChrgitmLv == "2" {
  21983. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21984. //
  21985. // }
  21986. // if item.ChrgitmLv == "3" {
  21987. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21988. // }
  21989. //
  21990. // }
  21991. //
  21992. // if item.MedChrgitmType == "02" { //诊查
  21993. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21994. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21995. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21996. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21997. // if item.ChrgitmLv == "1" {
  21998. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21999. // }
  22000. // if item.ChrgitmLv == "2" {
  22001. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22002. //
  22003. // }
  22004. // if item.ChrgitmLv == "3" {
  22005. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22006. // }
  22007. //
  22008. // }
  22009. //
  22010. // if item.MedChrgitmType == "03" { //检查费
  22011. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22012. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22013. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22014. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22015. // if item.ChrgitmLv == "1" {
  22016. //
  22017. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22018. //
  22019. // }
  22020. // if item.ChrgitmLv == "2" {
  22021. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22022. //
  22023. // }
  22024. // if item.ChrgitmLv == "3" {
  22025. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22026. // }
  22027. // }
  22028. //
  22029. // if item.MedChrgitmType == "04" { //化验费
  22030. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22031. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22032. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22033. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22034. // if item.ChrgitmLv == "1" {
  22035. //
  22036. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22037. //
  22038. // }
  22039. // if item.ChrgitmLv == "2" {
  22040. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22041. //
  22042. // }
  22043. // if item.ChrgitmLv == "3" {
  22044. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22045. // }
  22046. // }
  22047. //
  22048. // if item.MedChrgitmType == "05" { //治疗费
  22049. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22050. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22051. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22052. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22053. // if item.ChrgitmLv == "1" {
  22054. //
  22055. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22056. //
  22057. // }
  22058. // if item.ChrgitmLv == "2" {
  22059. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22060. //
  22061. // }
  22062. // if item.ChrgitmLv == "3" {
  22063. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22064. // }
  22065. // }
  22066. //
  22067. // if item.MedChrgitmType == "06" { //手术费
  22068. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22069. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22070. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22071. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22072. //
  22073. // if item.ChrgitmLv == "1" {
  22074. //
  22075. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22076. //
  22077. // }
  22078. // if item.ChrgitmLv == "2" {
  22079. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22080. //
  22081. // }
  22082. // if item.ChrgitmLv == "3" {
  22083. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22084. // }
  22085. // }
  22086. //
  22087. // if item.MedChrgitmType == "07" { //手术费
  22088. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22089. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22090. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22091. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22092. //
  22093. // if item.ChrgitmLv == "1" {
  22094. //
  22095. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22096. //
  22097. // }
  22098. // if item.ChrgitmLv == "2" {
  22099. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22100. //
  22101. // }
  22102. // if item.ChrgitmLv == "3" {
  22103. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22104. // }
  22105. // }
  22106. //
  22107. // if item.MedChrgitmType == "08" { //材料费
  22108. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22109. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22110. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22111. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22112. // if item.ChrgitmLv == "1" {
  22113. //
  22114. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22115. //
  22116. // }
  22117. // if item.ChrgitmLv == "2" {
  22118. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22119. //
  22120. // }
  22121. // if item.ChrgitmLv == "3" {
  22122. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22123. // }
  22124. // }
  22125. // if item.MedChrgitmType == "09" { //西药费
  22126. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22127. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22128. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22129. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22130. // if item.ChrgitmLv == "1" {
  22131. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22132. // }
  22133. // if item.ChrgitmLv == "2" {
  22134. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22135. // }
  22136. // if item.ChrgitmLv == "3" {
  22137. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22138. // }
  22139. // }
  22140. // if item.MedChrgitmType == "10" { //中药饮片
  22141. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22142. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22143. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22144. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22145. // if item.ChrgitmLv == "1" {
  22146. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22147. // }
  22148. // if item.ChrgitmLv == "2" {
  22149. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22150. // }
  22151. // if item.ChrgitmLv == "3" {
  22152. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22153. // }
  22154. // }
  22155. //
  22156. // if item.MedChrgitmType == "11" { //中成费
  22157. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22158. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22159. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22160. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22161. // if item.ChrgitmLv == "1" {
  22162. //
  22163. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22164. //
  22165. // }
  22166. // if item.ChrgitmLv == "2" {
  22167. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22168. //
  22169. // }
  22170. // if item.ChrgitmLv == "3" {
  22171. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22172. // }
  22173. // }
  22174. //
  22175. // if item.MedChrgitmType == "12" { //中成费
  22176. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22177. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22178. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22179. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22180. // if item.ChrgitmLv == "1" {
  22181. //
  22182. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22183. //
  22184. // }
  22185. // if item.ChrgitmLv == "2" {
  22186. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22187. //
  22188. // }
  22189. // if item.ChrgitmLv == "3" {
  22190. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22191. // }
  22192. // }
  22193. //
  22194. // if item.MedChrgitmType == "13" { //中成费
  22195. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22196. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22197. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22198. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22199. // if item.ChrgitmLv == "1" {
  22200. //
  22201. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22202. //
  22203. // }
  22204. // if item.ChrgitmLv == "2" {
  22205. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22206. //
  22207. // }
  22208. // if item.ChrgitmLv == "3" {
  22209. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22210. // }
  22211. // }
  22212. //
  22213. // if item.MedChrgitmType == "14" { //其他费
  22214. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22215. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22216. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22217. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22218. // if item.ChrgitmLv == "1" {
  22219. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22220. //
  22221. // }
  22222. // if item.ChrgitmLv == "2" {
  22223. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22224. //
  22225. // }
  22226. // if item.ChrgitmLv == "3" {
  22227. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22228. // }
  22229. // }
  22230. //
  22231. // }
  22232. //
  22233. // var iteminfoStructs []service.IteminfoStruct
  22234. //
  22235. // if bedCostTotal != 0 {
  22236. // iteminfo.MedChrgitm = "01"
  22237. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22238. // iteminfo.Amt = bedCostTotal
  22239. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22240. // iteminfo.ClabAmt = bed_clab_amt
  22241. // iteminfo.OthAmt = bed_other_amt
  22242. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22243. // }
  22244. //
  22245. // if examineCostTotal != 0 {
  22246. // iteminfo.MedChrgitm = "02"
  22247. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22248. // iteminfo.Amt = examineCostTotal
  22249. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22250. // iteminfo.ClabAmt = examine_clab_amt
  22251. // iteminfo.OthAmt = examine_other_amt
  22252. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22253. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22254. // }
  22255. //
  22256. // if checkCostTotal != 0 {
  22257. // iteminfo.MedChrgitm = "03"
  22258. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22259. // iteminfo.Amt = checkCostTotal
  22260. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22261. // iteminfo.ClabAmt = check_clab_amt
  22262. // iteminfo.OthAmt = check_other_amt
  22263. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22264. //
  22265. // }
  22266. //
  22267. // if laboratoryCostTotal != 0 {
  22268. // iteminfo.MedChrgitm = "04"
  22269. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22270. // iteminfo.Amt = laboratoryCostTotal
  22271. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22272. // iteminfo.ClabAmt = laboratory_clab_amt
  22273. // iteminfo.OthAmt = laboratory_other_amt
  22274. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22275. //
  22276. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22277. //
  22278. // }
  22279. //
  22280. // if treatCostTotal != 0 {
  22281. // iteminfo.MedChrgitm = "05"
  22282. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22283. // iteminfo.Amt = treatCostTotal
  22284. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22285. // iteminfo.ClabAmt = treat_clab_amt
  22286. // iteminfo.OthAmt = treat_other_amt
  22287. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22288. // //(struct4101.IteminfoStruct, iteminfo)
  22289. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22290. // }
  22291. //
  22292. // if operationCostTotal != 0 {
  22293. // iteminfo.MedChrgitm = "06"
  22294. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22295. // iteminfo.Amt = operationCostTotal
  22296. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22297. // iteminfo.ClabAmt = operation_clab_amt
  22298. // iteminfo.OthAmt = operation_other_amt
  22299. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22300. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22301. // }
  22302. //
  22303. // if nursingCostTotal != 0 {
  22304. // iteminfo.MedChrgitm = "07"
  22305. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22306. // iteminfo.Amt = nursingCostTotal
  22307. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22308. // iteminfo.ClabAmt = nursing_clab_amt
  22309. // iteminfo.OthAmt = nursing_other_amt
  22310. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22311. // }
  22312. //
  22313. // if materialCostTotal != 0 {
  22314. // iteminfo.MedChrgitm = "08"
  22315. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22316. // iteminfo.Amt = materialCostTotal
  22317. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22318. // iteminfo.ClabAmt = material_clab_amt
  22319. // iteminfo.OthAmt = material_other_amt
  22320. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22321. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22322. // }
  22323. //
  22324. // if westernMedicineCostTotal != 0 {
  22325. // iteminfo.MedChrgitm = "09"
  22326. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22327. // iteminfo.Amt = westernMedicineCostTotal
  22328. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22329. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22330. // iteminfo.OthAmt = westernMedicine_other_amt
  22331. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22332. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22333. //
  22334. // }
  22335. //
  22336. // if chineseMedicineCostTotal != 0 {
  22337. // iteminfo.MedChrgitm = "10"
  22338. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22339. // iteminfo.Amt = chineseMedicineCostTotal
  22340. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22341. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22342. // iteminfo.OthAmt = chinese_medicine_other_amt
  22343. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22344. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22345. //
  22346. // }
  22347. //
  22348. // if chineseTraditionalMedicineCostTotal != 0 {
  22349. // iteminfo.MedChrgitm = "11"
  22350. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22351. // iteminfo.Amt = westernMedicineCostTotal
  22352. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22353. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22354. // iteminfo.OthAmt = westernMedicine_other_amt
  22355. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22356. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22357. //
  22358. // }
  22359. //
  22360. // if commonlyTreatmentCostTotal != 0 {
  22361. // iteminfo.MedChrgitm = "12"
  22362. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22363. // iteminfo.Amt = commonlyTreatmentCostTotal
  22364. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22365. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22366. // iteminfo.OthAmt = commonly_treatment_other_amt
  22367. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22368. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22369. //
  22370. // }
  22371. //
  22372. // if registerCostTotal != 0 {
  22373. // iteminfo.MedChrgitm = "13"
  22374. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22375. // iteminfo.Amt = registerCostTotal
  22376. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22377. // iteminfo.ClabAmt = register_clab_amt
  22378. // iteminfo.OthAmt = register_other_amt
  22379. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22380. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22381. //
  22382. // }
  22383. //
  22384. // if otherCostTotal != 0 {
  22385. // iteminfo.MedChrgitm = "14"
  22386. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22387. // iteminfo.Amt = otherCostTotal
  22388. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22389. // iteminfo.ClabAmt = other_clab_amt
  22390. // iteminfo.OthAmt = other_other_amt
  22391. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22392. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22393. //
  22394. // }
  22395. // struct4101.IteminfoStruct = iteminfoStructs
  22396. // time_arr := strings.Split(order.SetlTime, " ")
  22397. // struct4101.AdmTime = time_arr[0]
  22398. // struct4101.AdmEndTime = time_arr[0]
  22399. //
  22400. // struct4101.DoctorName = doctor.UserName
  22401. // struct4101.DoctorCode = doctor.DoctorNumber
  22402. //
  22403. // struct4101.Ntly = "中国"
  22404. // struct4101.AdmCaty = "A03.06"
  22405. // var res ResultSeventeen
  22406. // if miConfig.MdtrtareaAdmvs == "421300" {
  22407. // data := make(map[string]interface{})
  22408. // data["struct4101"] = struct4101
  22409. // data["secret_key"] = miConfig.SecretKey
  22410. // data["org_name"] = miConfig.OrgName
  22411. // data["opera"] = curRoles.UserName
  22412. // data["code"] = miConfig.Code
  22413. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22414. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22415. //
  22416. // client := &http.Client{}
  22417. // bytesData, _ := json.Marshal(data)
  22418. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22419. // resp, _ := client.Do(req)
  22420. // defer resp.Body.Close()
  22421. // body, ioErr := ioutil.ReadAll(resp.Body)
  22422. // if ioErr != nil {
  22423. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22425. // return
  22426. // }
  22427. // var respJSON map[string]interface{}
  22428. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22429. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22431. // return
  22432. // }
  22433. //
  22434. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22435. // userJSONBytes, _ := json.Marshal(respJSON)
  22436. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22437. // utils.ErrorLog("解析失败:%v", err)
  22438. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22439. // adminUser := c.GetAdminUserInfo()
  22440. // errlog := &models.HisOrderError{
  22441. // UserOrgId: adminUser.CurrentOrgId,
  22442. // Ctime: time.Now().Unix(),
  22443. // Mtime: time.Now().Unix(),
  22444. // ErrMsg: res.ErrMsg + "解析失败",
  22445. // Status: 1,
  22446. // PatientId: order_id,
  22447. // Stage: 10088,
  22448. // }
  22449. // service.CreateErrMsgLog(errlog)
  22450. // continue
  22451. // }
  22452. //
  22453. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22454. // data := make(map[string]interface{})
  22455. // data["struct4101"] = struct4101
  22456. // data["secret_key"] = miConfig.SecretKey
  22457. // data["org_name"] = miConfig.OrgName
  22458. // data["opera"] = curRoles.UserName
  22459. // data["code"] = miConfig.Code
  22460. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22461. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22462. //
  22463. // client := &http.Client{}
  22464. // bytesData, _ := json.Marshal(data)
  22465. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22466. // resp, _ := client.Do(req)
  22467. // defer resp.Body.Close()
  22468. // body, ioErr := ioutil.ReadAll(resp.Body)
  22469. // if ioErr != nil {
  22470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22472. // return
  22473. // }
  22474. // var respJSON map[string]interface{}
  22475. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22476. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22478. // return
  22479. // }
  22480. //
  22481. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22482. // userJSONBytes, _ := json.Marshal(respJSON)
  22483. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22484. // utils.ErrorLog("解析失败:%v", err)
  22485. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22486. // adminUser := c.GetAdminUserInfo()
  22487. // errlog := &models.HisOrderError{
  22488. // UserOrgId: adminUser.CurrentOrgId,
  22489. // Ctime: time.Now().Unix(),
  22490. // Mtime: time.Now().Unix(),
  22491. // ErrMsg: res.ErrMsg + "解析失败",
  22492. // Status: 1,
  22493. // PatientId: order_id,
  22494. // Stage: 10088,
  22495. // }
  22496. // service.CreateErrMsgLog(errlog)
  22497. // continue
  22498. // }
  22499. //
  22500. // } else {
  22501. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22502. // fmt.Println(result)
  22503. //
  22504. // var dat map[string]interface{}
  22505. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22506. // fmt.Println(dat)
  22507. // } else {
  22508. // fmt.Println(err)
  22509. // }
  22510. // userJSONBytes, _ := json.Marshal(dat)
  22511. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22512. // utils.ErrorLog("解析失败:%v", err)
  22513. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22514. // adminUser := c.GetAdminUserInfo()
  22515. // errlog := &models.HisOrderError{
  22516. // UserOrgId: adminUser.CurrentOrgId,
  22517. // Ctime: time.Now().Unix(),
  22518. // Mtime: time.Now().Unix(),
  22519. // ErrMsg: res.ErrMsg + "解析失败",
  22520. // Status: 1,
  22521. // PatientId: order_id,
  22522. // Stage: 10106,
  22523. // }
  22524. // service.CreateErrMsgLog(errlog)
  22525. // continue
  22526. // }
  22527. // }
  22528. //
  22529. // if res.Infcode != 0 {
  22530. // adminUser := c.GetAdminUserInfo()
  22531. // errlog := &models.HisOrderError{
  22532. // UserOrgId: adminUser.CurrentOrgId,
  22533. // Ctime: time.Now().Unix(),
  22534. // Mtime: time.Now().Unix(),
  22535. // ErrMsg: res.ErrMsg,
  22536. // Status: 1,
  22537. // PatientId: order_id,
  22538. // Stage: 10106,
  22539. // }
  22540. // service.CreateErrMsgLog(errlog)
  22541. // continue
  22542. // } else {
  22543. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22544. // Number: res.Output.SetlListId,
  22545. // Status: 1,
  22546. // Ctime: time.Now().Unix(),
  22547. // Mtime: time.Now().Unix(),
  22548. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22549. // IsUpload: 1,
  22550. // OrderId: order_id,
  22551. // }
  22552. // service.CreateUploadRecord(hisFundSettleListResult)
  22553. // continue
  22554. // }
  22555. // }
  22556. //}
  22557. func (c *HisApiController) GetOrgInfo() {
  22558. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22559. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22560. }
  22561. func (c *HisApiController) GetHisPatientInfo() {
  22562. medical_insurance_card := c.GetString("medical_insurance_card")
  22563. id_card_type, _ := c.GetInt64("id_card_type")
  22564. id_card := c.GetString("id_card")
  22565. adminInfo := c.GetAdminUserInfo()
  22566. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22567. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22568. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22569. IdCardNo := ""
  22570. if id_card_type == 1 {
  22571. IdCardNo = medical_insurance_card
  22572. } else if id_card_type == 2 {
  22573. IdCardNo = id_card
  22574. }
  22575. if config.IsOpen == 1 {
  22576. 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
  22577. resp, requestErr := http.Get(api)
  22578. if requestErr != nil {
  22579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22580. return
  22581. }
  22582. defer resp.Body.Close()
  22583. body, ioErr := ioutil.ReadAll(resp.Body)
  22584. if ioErr != nil {
  22585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22587. return
  22588. }
  22589. var respJSON map[string]interface{}
  22590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22593. return
  22594. }
  22595. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22596. userJSONBytes, _ := json.Marshal(userJSON)
  22597. var res ResultTwo
  22598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22599. utils.ErrorLog("解析失败:%v", err)
  22600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22601. return
  22602. }
  22603. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22604. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22605. infoStr := string(Iinfos)
  22606. idetinfoStr := string(Idetinfos)
  22607. if res.Infcode == 0 {
  22608. his := models.VMHisPatient{
  22609. Status: 1,
  22610. Ctime: time.Now().Unix(),
  22611. Mtime: time.Now().Unix(),
  22612. PsnNo: res.Output.Baseinfo.PsnNo,
  22613. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22614. Certno: res.Output.Baseinfo.Certno,
  22615. PsnName: res.Output.Baseinfo.PsnName,
  22616. Gend: res.Output.Baseinfo.Gend,
  22617. Naty: res.Output.Baseinfo.Naty,
  22618. Iinfo: infoStr,
  22619. Idetinfo: idetinfoStr,
  22620. UserOrgId: adminInfo.CurrentOrgId,
  22621. IsReturn: 1,
  22622. IdCardType: id_card_type,
  22623. }
  22624. c.ServeSuccessJSON(map[string]interface{}{
  22625. "info": his,
  22626. })
  22627. } else {
  22628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22629. return
  22630. }
  22631. }
  22632. }
  22633. //func GetBasBaseInfo() (jsonStr string, err error) {
  22634. //
  22635. // handle := syscall.NewLazyDLL("SSCard.dll")
  22636. // add := handle.NewProc("ReadCardBas")
  22637. // str := make([]byte, 1024)
  22638. // str1 := make([]byte, 1024)
  22639. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22640. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22641. //
  22642. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22643. //
  22644. // fmt.Println("> Add(4,5)的结果为:", ret)
  22645. // handle.Release()
  22646. //
  22647. // return "", nil
  22648. //
  22649. //}
  22650. //func GetQRBaseInfo() (jsonStr string, err error) {
  22651. // handle := syscall.LoadDLL("SSCard.dll")
  22652. // ReadCardBas := handle.FindProc("GetQRBase")
  22653. //
  22654. // str := make([]byte, 256)
  22655. // str1 := make([]byte, 256)
  22656. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22657. //
  22658. // fmt.Println(string(str))
  22659. // fmt.Println(r)
  22660. // return string(str), nil
  22661. //}
  22662. //func CardInit() int {
  22663. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22664. // add := DllTestDef.MustFindProc("Init")
  22665. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22666. // if err != nil {
  22667. // fmt.Println("SSCard的运算结果为:", ret)
  22668. // }
  22669. // result := int(ret)
  22670. // return result
  22671. //}
  22672. //func CardInit() int {
  22673. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22674. // if err != nil {
  22675. // fmt.Println("SSCard的运算结果为:", ret)
  22676. // }
  22677. // fmt.Println(err)
  22678. // result := int(ret)
  22679. // return result
  22680. //}
  22681. func IntPtr(n int) uintptr {
  22682. return uintptr(n)
  22683. }
  22684. func StrPtr(s string) uintptr {
  22685. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22686. }
  22687. type Result2001 struct {
  22688. Cainfo interface{} `json:"cainfo"`
  22689. ErrMsg string `json:"err_msg"`
  22690. InfRefmsgid string `json:"inf_refmsgid"`
  22691. Infcode int64 `json:"infcode"`
  22692. Output struct {
  22693. Trtinfo struct {
  22694. PsnNo string `json:"psn_no"`
  22695. TrtChkType string `json:"trt_chk_type"`
  22696. FundPayType string `json:"fund_pay_type"`
  22697. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22698. Begndate string `json:"begndate"`
  22699. Enddate string `json:"enddate"`
  22700. TrtChkRslt string `json:"trt_chk_rslt"`
  22701. } `json:"trtinfo"`
  22702. } `json:"output"`
  22703. RefmsgTime string `json:"refmsg_time"`
  22704. RespondTime string `json:"respond_time"`
  22705. Signtype interface{} `json:"signtype"`
  22706. WarnMsg interface{} `json:"warn_msg"`
  22707. }
  22708. type Result2001Org10265 struct {
  22709. Cainfo interface{} `json:"cainfo"`
  22710. ErrMsg string `json:"err_msg"`
  22711. InfRefmsgid string `json:"inf_refmsgid"`
  22712. Infcode string `json:"infcode"`
  22713. Output struct {
  22714. Trtinfo struct {
  22715. PsnNo string `json:"psn_no"`
  22716. TrtChkType string `json:"trt_chk_type"`
  22717. FundPayType string `json:"fund_pay_type"`
  22718. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22719. Begndate string `json:"begndate"`
  22720. Enddate string `json:"enddate"`
  22721. TrtChkRslt string `json:"trt_chk_rslt"`
  22722. } `json:"trtinfo"`
  22723. } `json:"output"`
  22724. RefmsgTime string `json:"refmsg_time"`
  22725. RespondTime string `json:"respond_time"`
  22726. Signtype interface{} `json:"signtype"`
  22727. WarnMsg interface{} `json:"warn_msg"`
  22728. }
  22729. type ResultTwo struct {
  22730. ErrMsg string `json:"err_msg"`
  22731. InfRefmsgid string `json:"inf_refmsgid"`
  22732. Infcode int64 `json:"infcode"`
  22733. Output struct {
  22734. Baseinfo struct {
  22735. //Brdy string `json:"brdy"`
  22736. Certno string `json:"certno"`
  22737. Gend string `json:"gend"`
  22738. Naty string `json:"naty"`
  22739. PsnCertType string `json:"psn_cert_type"`
  22740. PsnName string `json:"psn_name"`
  22741. PsnNo string `json:"psn_no"`
  22742. } `json:"baseinfo"`
  22743. Idetinfo []interface{} `json:"idetinfo"`
  22744. Iinfo []struct {
  22745. Balc float64 `json:"balc"`
  22746. CvlservFlag string `json:"cvlserv_flag"`
  22747. EmpName string `json:"emp_name"`
  22748. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22749. Insutype string `json:"insutype"`
  22750. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22751. //PausInsuDate string `json:"paus_insu_date"`
  22752. //PsnInsuDate string `json:"psn_insu_date"`
  22753. PsnInsuStas string `json:"psn_insu_stas"`
  22754. PsnType string `json:"psn_type"`
  22755. } `json:"insuinfo"`
  22756. } `json:"output"`
  22757. RefmsgTime string `json:"refmsg_time"`
  22758. RespondTime string `json:"respond_time"`
  22759. Signtype interface{} `json:"signtype"`
  22760. WarnInfo interface{} `json:"warn_info"`
  22761. }
  22762. type ResultTwo10265 struct {
  22763. ErrMsg string `json:"err_msg"`
  22764. InfRefmsgid string `json:"inf_refmsgid"`
  22765. Infcode string `json:"infcode"`
  22766. Output struct {
  22767. Baseinfo struct {
  22768. //Brdy string `json:"brdy"`
  22769. Certno string `json:"certno"`
  22770. Gend string `json:"gend"`
  22771. Naty string `json:"naty"`
  22772. PsnCertType string `json:"psn_cert_type"`
  22773. PsnName string `json:"psn_name"`
  22774. PsnNo string `json:"psn_no"`
  22775. } `json:"baseinfo"`
  22776. Idetinfo []interface{} `json:"idetinfo"`
  22777. Iinfo []struct {
  22778. Balc float64 `json:"balc"`
  22779. CvlservFlag string `json:"cvlserv_flag"`
  22780. EmpName string `json:"emp_name"`
  22781. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22782. Insutype string `json:"insutype"`
  22783. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22784. PsnInsuStas string `json:"psn_insu_stas"`
  22785. PsnType string `json:"psn_type"`
  22786. } `json:"insuinfo"`
  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 ResultThree struct {
  22794. Cainfo interface{} `json:"cainfo"`
  22795. ErrMsg string `json:"err_msg"`
  22796. InfRefmsgid string `json:"inf_refmsgid"`
  22797. Infcode int64 `json:"infcode"`
  22798. Output struct {
  22799. Data struct {
  22800. IptOtpNo string `json:"ipt_otp_no"`
  22801. MdtrtID string `json:"mdtrt_id"`
  22802. PsnNo string `json:"psn_no"`
  22803. } `json:"data"`
  22804. } `json:"output"`
  22805. RefmsgTime string `json:"refmsg_time"`
  22806. RespondTime string `json:"respond_time"`
  22807. Signtype interface{} `json:"signtype"`
  22808. WarnMsg interface{} `json:"warn_msg"`
  22809. }
  22810. type ResultThree10265 struct {
  22811. Cainfo interface{} `json:"cainfo"`
  22812. ErrMsg string `json:"err_msg"`
  22813. InfRefmsgid string `json:"inf_refmsgid"`
  22814. Infcode string `json:"infcode"`
  22815. Output struct {
  22816. Data struct {
  22817. IptOtpNo string `json:"ipt_otp_no"`
  22818. MdtrtID string `json:"mdtrt_id"`
  22819. PsnNo string `json:"psn_no"`
  22820. } `json:"data"`
  22821. } `json:"output"`
  22822. RefmsgTime string `json:"refmsg_time"`
  22823. RespondTime string `json:"respond_time"`
  22824. Signtype interface{} `json:"signtype"`
  22825. WarnMsg interface{} `json:"warn_msg"`
  22826. }
  22827. type ResultFour struct {
  22828. Cainfo string `json:"cainfo"`
  22829. ErrMsg string `json:"err_msg"`
  22830. InfRefmsgid string `json:"inf_refmsgid"`
  22831. Infcode int64 `json:"infcode"`
  22832. Output struct {
  22833. Result []struct {
  22834. BasMednFlag string `json:"bas_medn_flag"`
  22835. ChldMedcFlag string `json:"chld_medc_flag"`
  22836. ChrgitmLv string `json:"chrgitm_lv"`
  22837. Cnt float64 `json:"cnt"`
  22838. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22839. DrtReimFlag string `json:"drt_reim_flag"`
  22840. FeedetlSn string `json:"feedetl_sn"`
  22841. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22842. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22843. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22844. ListSpItemFlag string `json:"list_sp_item_flag"`
  22845. LmtUsedFlag string `json:"lmt_used_flag"`
  22846. MedChrgitmType string `json:"med_chrgitm_type"`
  22847. Memo string `json:"memo"`
  22848. OverlmtAmt float64 `json:"overlmt_amt"`
  22849. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22850. Pric float64 `json:"pric"`
  22851. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22852. SelfpayProp float64 `json:"selfpay_prop"`
  22853. } `json:"result"`
  22854. } `json:"output"`
  22855. RefmsgTime string `json:"refmsg_time"`
  22856. RespondTime string `json:"respond_time"`
  22857. Signtype string `json:"signtype"`
  22858. WarnMsg string `json:"warn_msg"`
  22859. }
  22860. type ResultFour10265 struct {
  22861. Cainfo string `json:"cainfo"`
  22862. ErrMsg string `json:"err_msg"`
  22863. InfRefmsgid string `json:"inf_refmsgid"`
  22864. Infcode string `json:"infcode"`
  22865. Output struct {
  22866. Result []struct {
  22867. BasMednFlag string `json:"bas_medn_flag"`
  22868. ChldMedcFlag string `json:"chld_medc_flag"`
  22869. ChrgitmLv string `json:"chrgitm_lv"`
  22870. Cnt float64 `json:"cnt"`
  22871. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22872. DrtReimFlag string `json:"drt_reim_flag"`
  22873. FeedetlSn string `json:"feedetl_sn"`
  22874. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22875. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22876. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22877. ListSpItemFlag string `json:"list_sp_item_flag"`
  22878. LmtUsedFlag string `json:"lmt_used_flag"`
  22879. MedChrgitmType string `json:"med_chrgitm_type"`
  22880. Memo string `json:"memo"`
  22881. OverlmtAmt float64 `json:"overlmt_amt"`
  22882. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22883. Pric float64 `json:"pric"`
  22884. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22885. SelfpayProp float64 `json:"selfpay_prop"`
  22886. } `json:"result"`
  22887. } `json:"output"`
  22888. RefmsgTime string `json:"refmsg_time"`
  22889. RespondTime string `json:"respond_time"`
  22890. Signtype string `json:"signtype"`
  22891. WarnMsg string `json:"warn_msg"`
  22892. }
  22893. type ResultMemo struct {
  22894. InsuAdmdvs string `json:"insuAdmdvs"`
  22895. }
  22896. // [{"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}]
  22897. type ResultIDInfo struct {
  22898. Begntime string `json:"begntime"`
  22899. Endtime string `json:"endtime"`
  22900. Memo string `json:"memo"`
  22901. }
  22902. type ResultFive struct {
  22903. Balc float64 `json:"balc"`
  22904. CvlservFlag string `json:"cvlserv_flag"`
  22905. EmpName string `json:"emp_name"`
  22906. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22907. Insutype string `json:"insutype"`
  22908. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22909. PausInsuDate string `json:"paus_insu_date"`
  22910. PsnInsuDate string `json:"psn_insu_date"`
  22911. PsnInsuStas string `json:"psn_insu_stas"`
  22912. PsnType string `json:"psn_type"`
  22913. }
  22914. type ResultSix struct {
  22915. Cainfo interface{} `json:"cainfo"`
  22916. ErrMsg string `json:"err_msg"`
  22917. InfRefmsgid string `json:"inf_refmsgid"`
  22918. Infcode int64 `json:"infcode"`
  22919. Output struct {
  22920. } `json:"output"`
  22921. RefmsgTime string `json:"refmsg_time"`
  22922. RespondTime string `json:"respond_time"`
  22923. Signtype interface{} `json:"signtype"`
  22924. WarnMsg interface{} `json:"warn_msg"`
  22925. }
  22926. type ResultSix3103 struct {
  22927. Cainfo interface{} `json:"cainfo"`
  22928. ErrMsg string `json:"err_msg"`
  22929. InfRefmsgid string `json:"inf_refmsgid"`
  22930. Infcode int64 `json:"infcode"`
  22931. RefmsgTime string `json:"refmsg_time"`
  22932. RespondTime string `json:"respond_time"`
  22933. Signtype interface{} `json:"signtype"`
  22934. WarnMsg interface{} `json:"warn_msg"`
  22935. }
  22936. type FJ3507Result struct {
  22937. Cainfo interface{} `json:"cainfo"`
  22938. ErrMsg string `json:"err_msg"`
  22939. InfRefmsgid string `json:"inf_refmsgid"`
  22940. Infcode int64 `json:"infcode"`
  22941. Output struct {
  22942. retRslt string `json:"retRslt"`
  22943. msgRslt string `json:"msgRslt"`
  22944. } `json:"output"`
  22945. RefmsgTime string `json:"refmsg_time"`
  22946. RespondTime string `json:"respond_time"`
  22947. Signtype interface{} `json:"signtype"`
  22948. WarnMsg interface{} `json:"warn_msg"`
  22949. }
  22950. type FJ3507ResultFor10188 struct {
  22951. Cainfo interface{} `json:"cainfo"`
  22952. ErrMsg string `json:"err_msg"`
  22953. InfRefmsgid string `json:"inf_refmsgid"`
  22954. Infcode string `json:"infcode"`
  22955. RefmsgTime string `json:"refmsg_time"`
  22956. RespondTime string `json:"respond_time"`
  22957. Signtype interface{} `json:"signtype"`
  22958. WarnMsg interface{} `json:"warn_msg"`
  22959. }
  22960. type Result2406 struct {
  22961. Cainfo interface{} `json:"cainfo"`
  22962. ErrMsg string `json:"err_msg"`
  22963. InfRefmsgid string `json:"inf_refmsgid"`
  22964. Infcode int64 `json:"infcode"`
  22965. Output struct {
  22966. Result struct {
  22967. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22968. } `json:"result"`
  22969. } `json:"output"`
  22970. RefmsgTime string `json:"refmsg_time"`
  22971. RespondTime string `json:"respond_time"`
  22972. Signtype interface{} `json:"signtype"`
  22973. WarnMsg interface{} `json:"warn_msg"`
  22974. }
  22975. type GZResultSix struct {
  22976. Cainfo interface{} `json:"cainfo"`
  22977. ErrMsg string `json:"err_msg"`
  22978. InfRefmsgid string `json:"inf_refmsgid"`
  22979. Infcode int64 `json:"infcode"`
  22980. Output string `json:"output"`
  22981. RefmsgTime string `json:"refmsg_time"`
  22982. RespondTime string `json:"respond_time"`
  22983. Signtype interface{} `json:"signtype"`
  22984. WarnMsg interface{} `json:"warn_msg"`
  22985. }
  22986. type ResultSix10265 struct {
  22987. Cainfo interface{} `json:"cainfo"`
  22988. ErrMsg string `json:"err_msg"`
  22989. InfRefmsgid string `json:"inf_refmsgid"`
  22990. Infcode string `json:"infcode"`
  22991. Output struct {
  22992. } `json:"output"`
  22993. RefmsgTime string `json:"refmsg_time"`
  22994. RespondTime string `json:"respond_time"`
  22995. Signtype interface{} `json:"signtype"`
  22996. WarnMsg interface{} `json:"warn_msg"`
  22997. }
  22998. type ResultSeven struct {
  22999. Cainfo string `json:"cainfo"`
  23000. ErrMsg string `json:"err_msg"`
  23001. InfRefmsgid string `json:"inf_refmsgid"`
  23002. Infcode int64 `json:"infcode"`
  23003. Output struct {
  23004. Setlinfo struct {
  23005. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23006. AcctPay float64 `json:"acct_pay"`
  23007. ActPayDedc float64 `json:"act_pay_dedc"`
  23008. Age float64 `json:"age"`
  23009. Balc float64 `json:"balc"`
  23010. Certno string `json:"certno"`
  23011. ClrOptins string `json:"clr_optins"`
  23012. ClrType string `json:"clr_type"`
  23013. ClrWay string `json:"clr_way"`
  23014. CvlservFlag string `json:"cvlserv_flag"`
  23015. CvlservPay float64 `json:"cvlserv_pay"`
  23016. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23017. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23018. Gend string `json:"gend"`
  23019. HifesPay float64 `json:"hifes_pay"`
  23020. HifmiPay float64 `json:"hifmi_pay"`
  23021. HifpPay float64 `json:"hifp_pay"`
  23022. HospPartAmt float64 `json:"hosp_part_amt"`
  23023. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23024. Insutype string `json:"insutype"`
  23025. MafPay float64 `json:"maf_pay"`
  23026. MdtrtCertType string `json:"mdtrt_cert_type"`
  23027. HifobPay float64 `json:"hifob_pay"`
  23028. MdtrtID string `json:"mdtrt_id"`
  23029. MedType string `json:"med_type"`
  23030. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23031. MedinsSetlID string `json:"medins_setl_id"`
  23032. Naty string `json:"naty"`
  23033. OthPay float64 `json:"oth_pay"`
  23034. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23035. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23036. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23037. PsnCashPay float64 `json:"psn_cash_pay"`
  23038. PsnCertType string `json:"psn_cert_type"`
  23039. PsnName string `json:"psn_name"`
  23040. PsnNo string `json:"psn_no"`
  23041. PsnPartAmt float64 `json:"psn_part_amt"`
  23042. PsnType string `json:"psn_type"`
  23043. SetlID string `json:"setl_id"`
  23044. SetlTime string `json:"setl_time"`
  23045. } `json:"setlinfo"`
  23046. Setldetail interface{} `json:"setldetail"`
  23047. } `json:"output"`
  23048. RefmsgTime string `json:"refmsg_time"`
  23049. RespondTime string `json:"respond_time"`
  23050. Signtype interface{} `json:"signtype"`
  23051. WarnMsg interface{} `json:"warn_msg"`
  23052. }
  23053. type ResultSeven10633 struct {
  23054. Cainfo string `json:"cainfo"`
  23055. ErrMsg string `json:"err_msg"`
  23056. InfRefmsgid string `json:"inf_refmsgid"`
  23057. Infcode int64 `json:"infcode"`
  23058. Output struct {
  23059. Setlinfo struct {
  23060. AcctPay float64 `json:"acct_pay"`
  23061. ActPayDedc float64 `json:"act_pay_dedc"`
  23062. Age float64 `json:"age"`
  23063. Balc float64 `json:"balc"`
  23064. Certno string `json:"certno"`
  23065. ClrOptins string `json:"clr_optins"`
  23066. ClrType string `json:"clr_type"`
  23067. ClrWay string `json:"clr_way"`
  23068. CvlservFlag string `json:"cvlserv_flag"`
  23069. CvlservPay float64 `json:"cvlserv_pay"`
  23070. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23071. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23072. Gend string `json:"gend"`
  23073. HifesPay float64 `json:"hifes_pay"`
  23074. HifmiPay float64 `json:"hifmi_pay"`
  23075. HifpPay float64 `json:"hifp_pay"`
  23076. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23077. Insutype string `json:"insutype"`
  23078. MafPay float64 `json:"maf_pay"`
  23079. MdtrtCertType string `json:"mdtrt_cert_type"`
  23080. HifobPay float64 `json:"hifob_pay"`
  23081. MdtrtID string `json:"mdtrt_id"`
  23082. MedType string `json:"med_type"`
  23083. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23084. MedinsSetlID string `json:"medins_setl_id"`
  23085. Naty string `json:"naty"`
  23086. OthPay float64 `json:"oth_pay"`
  23087. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23088. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23089. PsnCashPay float64 `json:"psn_cash_pay"`
  23090. PsnCertType string `json:"psn_cert_type"`
  23091. PsnName string `json:"psn_name"`
  23092. PsnNo string `json:"psn_no"`
  23093. PsnPartAmt float64 `json:"psn_part_amt"`
  23094. PsnType string `json:"psn_type"`
  23095. SetlID string `json:"setl_id"`
  23096. SetlTime string `json:"setl_time"`
  23097. } `json:"setlinfo"`
  23098. Setldetail interface{} `json:"setldetail"`
  23099. } `json:"output"`
  23100. RefmsgTime string `json:"refmsg_time"`
  23101. RespondTime string `json:"respond_time"`
  23102. Signtype interface{} `json:"signtype"`
  23103. WarnMsg interface{} `json:"warn_msg"`
  23104. }
  23105. type ResultSevenAH struct {
  23106. Cainfo string `json:"cainfo"`
  23107. ErrMsg string `json:"err_msg"`
  23108. InfRefmsgid string `json:"inf_refmsgid"`
  23109. Infcode int64 `json:"infcode"`
  23110. Output struct {
  23111. Setlinfo struct {
  23112. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23113. AcctPay float64 `json:"acct_pay"`
  23114. ActPayDedc float64 `json:"act_pay_dedc"`
  23115. Age float64 `json:"age"`
  23116. Balc float64 `json:"balc"`
  23117. Certno string `json:"certno"`
  23118. ClrOptins string `json:"clr_optins"`
  23119. ClrType string `json:"clr_type"`
  23120. ClrWay string `json:"clr_way"`
  23121. CvlservFlag string `json:"cvlserv_flag"`
  23122. CvlservPay float64 `json:"cvlserv_pay"`
  23123. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23124. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23125. Gend string `json:"gend"`
  23126. HifesPay float64 `json:"hifes_pay"`
  23127. HifmiPay float64 `json:"hifmi_pay"`
  23128. HifpPay float64 `json:"hifp_pay"`
  23129. HospPartAmt float64 `json:"hosp_part_amt"`
  23130. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23131. Insutype string `json:"insutype"`
  23132. MafPay float64 `json:"maf_pay"`
  23133. MdtrtCertType string `json:"mdtrt_cert_type"`
  23134. HifobPay float64 `json:"hifob_pay"`
  23135. MdtrtID string `json:"mdtrt_id"`
  23136. MedType string `json:"med_type"`
  23137. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23138. MedinsSetlID string `json:"medins_setl_id"`
  23139. Naty string `json:"naty"`
  23140. OthPay float64 `json:"oth_pay"`
  23141. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23142. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23143. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23144. PsnCashPay float64 `json:"psn_cash_pay"`
  23145. PsnCertType string `json:"psn_cert_type"`
  23146. PsnName string `json:"psn_name"`
  23147. PsnNo string `json:"psn_no"`
  23148. PsnPartAmt float64 `json:"psn_part_amt"`
  23149. PsnType string `json:"psn_type"`
  23150. SetlID string `json:"setl_id"`
  23151. SetlTime int64 `json:"setl_time"`
  23152. } `json:"setlinfo"`
  23153. Setldetail interface{} `json:"setldetail"`
  23154. } `json:"output"`
  23155. RefmsgTime string `json:"refmsg_time"`
  23156. RespondTime string `json:"respond_time"`
  23157. Signtype interface{} `json:"signtype"`
  23158. WarnMsg interface{} `json:"warn_msg"`
  23159. }
  23160. type ResultSeven10265 struct {
  23161. Cainfo string `json:"cainfo"`
  23162. ErrMsg string `json:"err_msg"`
  23163. InfRefmsgid string `json:"inf_refmsgid"`
  23164. Infcode string `json:"infcode"`
  23165. Output struct {
  23166. Setlinfo struct {
  23167. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23168. AcctPay float64 `json:"acct_pay"`
  23169. ActPayDedc float64 `json:"act_pay_dedc"`
  23170. Age float64 `json:"age"`
  23171. Balc float64 `json:"balc"`
  23172. Certno string `json:"certno"`
  23173. ClrOptins string `json:"clr_optins"`
  23174. ClrType string `json:"clr_type"`
  23175. ClrWay string `json:"clr_way"`
  23176. CvlservFlag string `json:"cvlserv_flag"`
  23177. CvlservPay float64 `json:"cvlserv_pay"`
  23178. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23179. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23180. Gend string `json:"gend"`
  23181. HifesPay float64 `json:"hifes_pay"`
  23182. HifmiPay float64 `json:"hifmi_pay"`
  23183. HifpPay float64 `json:"hifp_pay"`
  23184. HospPartAmt float64 `json:"hosp_part_amt"`
  23185. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23186. Insutype string `json:"insutype"`
  23187. MafPay float64 `json:"maf_pay"`
  23188. MdtrtCertType string `json:"mdtrt_cert_type"`
  23189. HifobPay float64 `json:"hifob_pay"`
  23190. MdtrtID string `json:"mdtrt_id"`
  23191. MedType string `json:"med_type"`
  23192. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23193. MedinsSetlID string `json:"medins_setl_id"`
  23194. Naty string `json:"naty"`
  23195. OthPay float64 `json:"oth_pay"`
  23196. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23197. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23198. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23199. PsnCashPay float64 `json:"psn_cash_pay"`
  23200. PsnCertType string `json:"psn_cert_type"`
  23201. PsnName string `json:"psn_name"`
  23202. PsnNo string `json:"psn_no"`
  23203. PsnPartAmt float64 `json:"psn_part_amt"`
  23204. PsnType string `json:"psn_type"`
  23205. SetlID string `json:"setl_id"`
  23206. SetlTime string `json:"setl_time"`
  23207. } `json:"setlinfo"`
  23208. Setldetail interface{} `json:"setldetail"`
  23209. } `json:"output"`
  23210. RefmsgTime string `json:"refmsg_time"`
  23211. RespondTime string `json:"respond_time"`
  23212. Signtype interface{} `json:"signtype"`
  23213. WarnMsg interface{} `json:"warn_msg"`
  23214. }
  23215. type ResultSeven10265Two struct {
  23216. Cainfo string `json:"cainfo"`
  23217. ErrMsg string `json:"err_msg"`
  23218. InfRefmsgid string `json:"inf_refmsgid"`
  23219. Infcode string `json:"infcode"`
  23220. Output struct {
  23221. Setlinfo struct {
  23222. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23223. AcctPay float64 `json:"acct_pay"`
  23224. ActPayDedc float64 `json:"act_pay_dedc"`
  23225. Age float64 `json:"age"`
  23226. Balc float64 `json:"balc"`
  23227. Certno string `json:"certno"`
  23228. ClrOptins string `json:"clr_optins"`
  23229. ClrType string `json:"clr_type"`
  23230. ClrWay string `json:"clr_way"`
  23231. CvlservFlag string `json:"cvlserv_flag"`
  23232. CvlservPay float64 `json:"cvlserv_pay"`
  23233. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23234. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23235. Gend string `json:"gend"`
  23236. HifesPay float64 `json:"hifes_pay"`
  23237. HifmiPay float64 `json:"hifmi_pay"`
  23238. HifpPay float64 `json:"hifp_pay"`
  23239. HospPartAmt string `json:"hosp_part_amt"`
  23240. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23241. Insutype string `json:"insutype"`
  23242. MafPay float64 `json:"maf_pay"`
  23243. MdtrtCertType string `json:"mdtrt_cert_type"`
  23244. HifobPay float64 `json:"hifob_pay"`
  23245. MdtrtID string `json:"mdtrt_id"`
  23246. MedType string `json:"med_type"`
  23247. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23248. MedinsSetlID string `json:"medins_setl_id"`
  23249. Naty string `json:"naty"`
  23250. OthPay float64 `json:"oth_pay"`
  23251. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23252. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23253. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23254. PsnCashPay float64 `json:"psn_cash_pay"`
  23255. PsnCertType string `json:"psn_cert_type"`
  23256. PsnName string `json:"psn_name"`
  23257. PsnNo string `json:"psn_no"`
  23258. PsnPartAmt float64 `json:"psn_part_amt"`
  23259. PsnType string `json:"psn_type"`
  23260. SetlID string `json:"setl_id"`
  23261. SetlTime string `json:"setl_time"`
  23262. } `json:"setlinfo"`
  23263. Setldetail interface{} `json:"setldetail"`
  23264. } `json:"output"`
  23265. RefmsgTime string `json:"refmsg_time"`
  23266. RespondTime string `json:"respond_time"`
  23267. Signtype interface{} `json:"signtype"`
  23268. WarnMsg interface{} `json:"warn_msg"`
  23269. }
  23270. type ResultSeven10633Two struct {
  23271. Cainfo string `json:"cainfo"`
  23272. ErrMsg string `json:"err_msg"`
  23273. InfRefmsgid string `json:"inf_refmsgid"`
  23274. Infcode string `json:"infcode"`
  23275. Output struct {
  23276. Setlinfo struct {
  23277. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23278. AcctPay float64 `json:"acct_pay"`
  23279. ActPayDedc float64 `json:"act_pay_dedc"`
  23280. Age float64 `json:"age"`
  23281. Balc float64 `json:"balc"`
  23282. Certno string `json:"certno"`
  23283. ClrOptins string `json:"clr_optins"`
  23284. ClrType string `json:"clr_type"`
  23285. ClrWay string `json:"clr_way"`
  23286. CvlservFlag string `json:"cvlserv_flag"`
  23287. CvlservPay float64 `json:"cvlserv_pay"`
  23288. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23289. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23290. Gend string `json:"gend"`
  23291. HifesPay float64 `json:"hifes_pay"`
  23292. HifmiPay float64 `json:"hifmi_pay"`
  23293. HifpPay float64 `json:"hifp_pay"`
  23294. HospPartAmt float64 `json:"hosp_part_amt"`
  23295. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23296. Insutype string `json:"insutype"`
  23297. MafPay float64 `json:"maf_pay"`
  23298. MdtrtCertType string `json:"mdtrt_cert_type"`
  23299. HifobPay float64 `json:"hifob_pay"`
  23300. MdtrtID string `json:"mdtrt_id"`
  23301. MedType string `json:"med_type"`
  23302. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23303. MedinsSetlID string `json:"medins_setl_id"`
  23304. Naty string `json:"naty"`
  23305. OthPay float64 `json:"oth_pay"`
  23306. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23307. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23308. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23309. PsnCashPay float64 `json:"psn_cash_pay"`
  23310. PsnCertType string `json:"psn_cert_type"`
  23311. PsnName string `json:"psn_name"`
  23312. PsnNo string `json:"psn_no"`
  23313. PsnPartAmt float64 `json:"psn_part_amt"`
  23314. PsnType string `json:"psn_type"`
  23315. SetlID string `json:"setl_id"`
  23316. SetlTime string `json:"setl_time"`
  23317. } `json:"setlinfo"`
  23318. Setldetail interface{} `json:"setldetail"`
  23319. } `json:"output"`
  23320. RefmsgTime string `json:"refmsg_time"`
  23321. RespondTime string `json:"respond_time"`
  23322. Signtype interface{} `json:"signtype"`
  23323. WarnMsg interface{} `json:"warn_msg"`
  23324. }
  23325. type FlexibleFloat float64
  23326. func (f *FlexibleFloat) UnmarshalJSON(data []byte) error {
  23327. var v interface{}
  23328. if err := json.Unmarshal(data, &v); err != nil {
  23329. return err
  23330. }
  23331. switch value := v.(type) {
  23332. case float64:
  23333. *f = FlexibleFloat(value)
  23334. case string:
  23335. if value == "" {
  23336. *f = 0 // 空字符串默认0
  23337. } else {
  23338. num, err := strconv.ParseFloat(value, 64)
  23339. if err != nil {
  23340. return fmt.Errorf("无法解析字符串为浮点数: %v", err)
  23341. }
  23342. *f = FlexibleFloat(num)
  23343. }
  23344. default:
  23345. return fmt.Errorf("不支持的字段类型: %T", value)
  23346. }
  23347. return nil
  23348. }
  23349. type ResultSeven10633Three struct {
  23350. Cainfo string `json:"cainfo"`
  23351. ErrMsg string `json:"err_msg"`
  23352. InfRefmsgid string `json:"inf_refmsgid"`
  23353. Infcode string `json:"infcode"`
  23354. Output struct {
  23355. Setlinfo struct {
  23356. AcctPay float64 `json:"acct_pay"`
  23357. ActPayDedc float64 `json:"act_pay_dedc"`
  23358. Age float64 `json:"age"`
  23359. Balc float64 `json:"balc"`
  23360. Certno string `json:"certno"`
  23361. ClrOptins string `json:"clr_optins"`
  23362. ClrType string `json:"clr_type"`
  23363. ClrWay string `json:"clr_way"`
  23364. CvlservFlag string `json:"cvlserv_flag"`
  23365. CvlservPay float64 `json:"cvlserv_pay"`
  23366. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23367. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23368. Gend string `json:"gend"`
  23369. HifesPay float64 `json:"hifes_pay"`
  23370. HifmiPay float64 `json:"hifmi_pay"`
  23371. HifpPay float64 `json:"hifp_pay"`
  23372. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23373. Insutype string `json:"insutype"`
  23374. MafPay float64 `json:"maf_pay"`
  23375. MdtrtCertType string `json:"mdtrt_cert_type"`
  23376. HifobPay float64 `json:"hifob_pay"`
  23377. MdtrtID string `json:"mdtrt_id"`
  23378. MedType string `json:"med_type"`
  23379. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23380. MedinsSetlID string `json:"medins_setl_id"`
  23381. Naty string `json:"naty"`
  23382. OthPay float64 `json:"oth_pay"`
  23383. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23384. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23385. PsnCashPay float64 `json:"psn_cash_pay"`
  23386. PsnCertType string `json:"psn_cert_type"`
  23387. PsnName string `json:"psn_name"`
  23388. PsnNo string `json:"psn_no"`
  23389. PsnPartAmt float64 `json:"psn_part_amt"`
  23390. PsnType string `json:"psn_type"`
  23391. SetlID string `json:"setl_id"`
  23392. SetlTime string `json:"setl_time"`
  23393. } `json:"setlinfo"`
  23394. Setldetail interface{} `json:"setldetail"`
  23395. } `json:"output"`
  23396. RefmsgTime string `json:"refmsg_time"`
  23397. RespondTime string `json:"respond_time"`
  23398. Signtype interface{} `json:"signtype"`
  23399. WarnMsg interface{} `json:"warn_msg"`
  23400. }
  23401. type GZResultSeven10265Two struct {
  23402. Cainfo string `json:"cainfo"`
  23403. ErrMsg string `json:"err_msg"`
  23404. InfRefmsgid string `json:"inf_refmsgid"`
  23405. Infcode int64 `json:"infcode"`
  23406. Output struct {
  23407. Setlinfo struct {
  23408. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23409. AcctPay float64 `json:"acct_pay"`
  23410. ActPayDedc float64 `json:"act_pay_dedc"`
  23411. Age float64 `json:"age"`
  23412. Balc float64 `json:"balc"`
  23413. Certno string `json:"certno"`
  23414. ClrOptins string `json:"clr_optins"`
  23415. ClrType string `json:"clr_type"`
  23416. ClrWay string `json:"clr_way"`
  23417. CvlservFlag string `json:"cvlserv_flag"`
  23418. CvlservPay float64 `json:"cvlserv_pay"`
  23419. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23420. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23421. Gend string `json:"gend"`
  23422. HifesPay float64 `json:"hifes_pay"`
  23423. HifmiPay float64 `json:"hifmi_pay"`
  23424. HifpPay float64 `json:"hifp_pay"`
  23425. HospPartAmt float64 `json:"hosp_part_amt"`
  23426. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23427. Insutype string `json:"insutype"`
  23428. MafPay float64 `json:"maf_pay"`
  23429. MdtrtCertType string `json:"mdtrt_cert_type"`
  23430. HifobPay float64 `json:"hifob_pay"`
  23431. MdtrtID string `json:"mdtrt_id"`
  23432. MedType string `json:"med_type"`
  23433. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23434. MedinsSetlID string `json:"medins_setl_id"`
  23435. Naty string `json:"naty"`
  23436. OthPay float64 `json:"oth_pay"`
  23437. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23438. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23439. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23440. PsnCashPay float64 `json:"psn_cash_pay"`
  23441. PsnCertType string `json:"psn_cert_type"`
  23442. PsnName string `json:"psn_name"`
  23443. PsnNo string `json:"psn_no"`
  23444. PsnPartAmt float64 `json:"psn_part_amt"`
  23445. PsnType string `json:"psn_type"`
  23446. SetlID string `json:"setl_id"`
  23447. SetlTime string `json:"setl_time"`
  23448. } `json:"setlinfo"`
  23449. Setldetail interface{} `json:"setldetail"`
  23450. } `json:"output"`
  23451. RefmsgTime string `json:"refmsg_time"`
  23452. RespondTime string `json:"respond_time"`
  23453. Signtype interface{} `json:"signtype"`
  23454. WarnMsg interface{} `json:"warn_msg"`
  23455. }
  23456. type ResultEight struct {
  23457. Cainfo string `json:"cainfo"`
  23458. ErrMsg string `json:"err_msg"`
  23459. InfRefmsgid string `json:"inf_refmsgid"`
  23460. Infcode int64 `json:"infcode"`
  23461. Output struct {
  23462. Stmtinfo struct {
  23463. SetlOptins string `json:"setl_optins"`
  23464. StmtRslt string `json:"stmt_rslt"`
  23465. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23466. } `json:"stmtinfo"`
  23467. } `json:"output"`
  23468. RefmsgTime string `json:"refmsg_time"`
  23469. RespondTime string `json:"respond_time"`
  23470. Signtype interface{} `json:"signtype"`
  23471. WarnMsg interface{} `json:"warn_msg"`
  23472. }
  23473. type ResultEightFor10188 struct {
  23474. Cainfo string `json:"cainfo"`
  23475. ErrMsg string `json:"err_msg"`
  23476. InfRefmsgid string `json:"inf_refmsgid"`
  23477. Infcode string `json:"infcode"`
  23478. Output struct {
  23479. Stmtinfo struct {
  23480. SetlOptins string `json:"setl_optins"`
  23481. StmtRslt string `json:"stmt_rslt"`
  23482. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23483. } `json:"stmtinfo"`
  23484. } `json:"output"`
  23485. RefmsgTime string `json:"refmsg_time"`
  23486. RespondTime string `json:"respond_time"`
  23487. Signtype interface{} `json:"signtype"`
  23488. WarnMsg interface{} `json:"warn_msg"`
  23489. }
  23490. type ResultNine struct {
  23491. Cainfo string `json:"cainfo"`
  23492. ErrMsg string `json:"err_msg"`
  23493. InfRefmsgid string `json:"inf_refmsgid"`
  23494. Infcode int64 `json:"infcode"`
  23495. Output struct {
  23496. FileQuryNo string `json:"file_qury_no"`
  23497. } `json:"output"`
  23498. RefmsgTime string `json:"refmsg_time"`
  23499. RespondTime string `json:"respond_time"`
  23500. Signtype interface{} `json:"signtype"`
  23501. WarnMsg interface{} `json:"warn_msg"`
  23502. }
  23503. type ResultTen struct {
  23504. Cainfo string `json:"cainfo"`
  23505. ErrMsg string `json:"err_msg"`
  23506. InfRefmsgid string `json:"inf_refmsgid"`
  23507. Infcode int64 `json:"infcode"`
  23508. Output struct {
  23509. Fileinfo struct {
  23510. DldEndtime string `json:"dld_endtime"`
  23511. FileQuryNo string `json:"file_qury_no"`
  23512. Filename string `json:"filename"`
  23513. } `json:"fileinfo"`
  23514. } `json:"output"`
  23515. RefmsgTime string `json:"refmsg_time"`
  23516. RespondTime string `json:"respond_time"`
  23517. Signtype interface{} `json:"signtype"`
  23518. WarnMsg interface{} `json:"warn_msg"`
  23519. }
  23520. type Result5262 struct {
  23521. ErrMsg string `json:"err_msg"`
  23522. InfRefmsgid string `json:"inf_refmsgid"`
  23523. Infcode int64 `json:"infcode"`
  23524. Output struct {
  23525. PageInfo struct {
  23526. Size int `json:"size"`
  23527. RecordCounts int `json:"record_counts"`
  23528. } `json:"page_info"`
  23529. Idetinfo []interface{} `json:"idetinfo"`
  23530. Result []struct {
  23531. SetlID string `json:"setl_id"`
  23532. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23533. MdtrtID string `json:"mdtrt_id"`
  23534. InitSetlID string `json:"init_setl_id,omitempty"`
  23535. PsnNo string `json:"psn_no"`
  23536. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23537. PsnName string `json:"psn_name"`
  23538. PsnCertType string `json:"psn_cert_type"`
  23539. Certno string `json:"certno"`
  23540. Gend string `json:"gend,omitempty"`
  23541. Naty string `json:"naty,omitempty"`
  23542. Brdy string `json:"brdy,omitempty"`
  23543. Age float64 `json:"age,omitempty"`
  23544. Insutype string `json:"insutype,omitempty"`
  23545. PsnType string `json:"psn_type"`
  23546. CvlservFlag string `json:"cvlserv_flag"`
  23547. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23548. SpPsnType string `json:"sp_psn_type,omitempty"`
  23549. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23550. ClctGrde string `json:"clct_grde,omitempty"`
  23551. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23552. NwbFlag string `json:"nwb_flag,omitempty"`
  23553. InsuAdmdvs string `json:"insu_admdvs"`
  23554. EmpNo string `json:"emp_no,omitempty"`
  23555. EmpName string `json:"emp_name,omitempty"`
  23556. EmpType string `json:"emp_type,omitempty"`
  23557. EconType string `json:"econ_type,omitempty"`
  23558. AfilIndu string `json:"afil_indu,omitempty"`
  23559. AfilRlts string `json:"afil_rlts,omitempty"`
  23560. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23561. PayLoc string `json:"pay_loc,omitempty"`
  23562. FixmedinsCode string `json:"fixmedins_code"`
  23563. FixmedinsName string `json:"fixmedins_name"`
  23564. HospLv string `json:"hosp_lv,omitempty"`
  23565. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23566. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23567. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23568. Begndate string `json:"begndate"`
  23569. Enddate string `json:"enddate"`
  23570. SetlTime string `json:"setl_time"`
  23571. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23572. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23573. MedType string `json:"med_type"`
  23574. SetlType string `json:"setl_type,omitempty"`
  23575. ClrType string `json:"clr_type,omitempty"`
  23576. ClrWay string `json:"clr_way,omitempty"`
  23577. PsnSetlway string `json:"psn_setlway,omitempty"`
  23578. ClrOptins string `json:"clr_optins,omitempty"`
  23579. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23580. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23581. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23582. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23583. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23584. DedcStd float64 `json:"dedc_std,omitempty"`
  23585. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23586. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23587. HifpPay float64 `json:"hifp_pay,omitempty"`
  23588. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23589. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23590. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23591. HifesPay float64 `json:"hifes_pay,omitempty"`
  23592. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23593. HifobPay float64 `json:"hifob_pay,omitempty"`
  23594. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23595. MafPay float64 `json:"maf_pay,omitempty"`
  23596. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23597. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23598. PsnPay float64 `json:"psn_pay,omitempty"`
  23599. AcctPay float64 `json:"acct_pay,omitempty"`
  23600. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23601. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23602. Balc float64 `json:"balc,omitempty"`
  23603. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23604. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23605. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23606. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23607. Year string `json:"year,omitempty"`
  23608. DiseNo string `json:"dise_no,omitempty"`
  23609. DiseName string `json:"dise_name,omitempty"`
  23610. Invono string `json:"invono,omitempty"`
  23611. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23612. ValiFlag string `json:"vali_flag,omitempty"`
  23613. Memo string `json:"memo,omitempty"`
  23614. Rid string `json:"rid"`
  23615. UpdtTime string `json:"updt_time,omitempty"`
  23616. CrterID string `json:"crter_id,omitempty"`
  23617. CrterName string `json:"crter_name,omitempty"`
  23618. CrteTime string `json:"crte_time,omitempty"`
  23619. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23620. OpterID string `json:"opter_id,omitempty"`
  23621. OpterName string `json:"opter_name,omitempty"`
  23622. OptTime string `json:"opt_time,omitempty"`
  23623. OptinsNo string `json:"optins_no,omitempty"`
  23624. PoolareaNo string `json:"poolarea_no,omitempty"`
  23625. } `json:"result"`
  23626. } `json:"output"`
  23627. RefmsgTime string `json:"refmsg_time"`
  23628. RespondTime string `json:"respond_time"`
  23629. Signtype interface{} `json:"signtype"`
  23630. WarnInfo interface{} `json:"warn_info"`
  23631. }
  23632. type Result5267 struct {
  23633. ErrMsg string `json:"err_msg"`
  23634. InfRefmsgid string `json:"inf_refmsgid"`
  23635. Infcode int64 `json:"infcode"`
  23636. Output struct {
  23637. PageInfo struct {
  23638. Size int `json:"size"`
  23639. RecordCounts int `json:"record_counts"`
  23640. } `json:"pageinfo"`
  23641. Result []struct {
  23642. SetlID string `json:"setl_id"`
  23643. ClrOptins string `json:"clr_optins"`
  23644. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23645. MdtrtID string `json:"mdtrt_id"`
  23646. InitSetlID string `json:"init_setl_id,omitempty"`
  23647. PsnNo string `json:"psn_no"`
  23648. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23649. PsnName string `json:"psn_name"`
  23650. PsnCertType string `json:"psn_cert_type"`
  23651. Certno string `json:"certno"`
  23652. Gend string `json:"gend,omitempty"`
  23653. Naty string `json:"naty,omitempty"`
  23654. Brdy string `json:"brdy,omitempty"`
  23655. Age float64 `json:"age,omitempty"`
  23656. Insutype string `json:"insutype,omitempty"`
  23657. PsnType string `json:"psn_type"`
  23658. CvlservFlag string `json:"cvlserv_flag"`
  23659. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23660. SpPsnType string `json:"sp_psn_type,omitempty"`
  23661. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23662. ClctGrde string `json:"clct_grde,omitempty"`
  23663. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23664. NwbFlag string `json:"nwb_flag,omitempty"`
  23665. InsuAdmdvs string `json:"insu_admdvs"`
  23666. EmpNo string `json:"emp_no,omitempty"`
  23667. EmpName string `json:"emp_name,omitempty"`
  23668. EmpType string `json:"emp_type,omitempty"`
  23669. EconType string `json:"econ_type,omitempty"`
  23670. AfilIndu string `json:"afil_indu,omitempty"`
  23671. AfilRlts string `json:"afil_rlts,omitempty"`
  23672. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23673. PayLoc string `json:"pay_loc,omitempty"`
  23674. FixmedinsCode string `json:"fixmedins_code"`
  23675. FixmedinsName string `json:"fixmedins_name"`
  23676. HospLv string `json:"hosp_lv,omitempty"`
  23677. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23678. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23679. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23680. Begndate string `json:"begndate,omitempty"`
  23681. Enddate string `json:"enddate,omitempty"`
  23682. SetlTime string `json:"setl_time,omitempty"`
  23683. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23684. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23685. MedType string `json:"med_type"`
  23686. SetlType string `json:"setl_type,omitempty"`
  23687. ClrType string `json:"clr_type,omitempty"`
  23688. ClrWay string `json:"clr_way,omitempty"`
  23689. PsnSetlway string `json:"psn_setlway,omitempty"`
  23690. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23691. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23692. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23693. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23694. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23695. DedcStd float64 `json:"dedc_std,omitempty"`
  23696. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23697. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23698. HifpPay float64 `json:"hifp_pay,omitempty"`
  23699. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23700. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23701. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23702. HifesPay float64 `json:"hifes_pay,omitempty"`
  23703. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23704. HifobPay float64 `json:"hifob_pay,omitempty"`
  23705. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23706. MafPay float64 `json:"maf_pay,omitempty"`
  23707. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23708. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23709. PsnPay float64 `json:"psn_pay,omitempty"`
  23710. AcctPay float64 `json:"acct_pay,omitempty"`
  23711. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23712. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23713. Balc float64 `json:"balc,omitempty"`
  23714. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23715. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23716. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23717. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23718. Year string `json:"year,omitempty"`
  23719. DiseNo string `json:"dise_no,omitempty"`
  23720. DiseName string `json:"dise_name,omitempty"`
  23721. Invono string `json:"invono,omitempty"`
  23722. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23723. Memo string `json:"memo,omitempty"`
  23724. UpdtTime string `json:"updt_time,omitempty"`
  23725. OpterID string `json:"opter_id,omitempty"`
  23726. OpterName string `json:"opter_name,omitempty"`
  23727. OptTime string `json:"opt_time,omitempty"`
  23728. OptinsNo string `json:"optins_no,omitempty"`
  23729. PoolareaNo string `json:"poolarea_no,omitempty"`
  23730. } `json:"result"`
  23731. } `json:"output"`
  23732. RefmsgTime string `json:"refmsg_time"`
  23733. RespondTime string `json:"respond_time"`
  23734. Signtype interface{} `json:"signtype"`
  23735. WarnInfo interface{} `json:"warn_info"`
  23736. }
  23737. // type Autogenerated struct {
  23738. // Output struct {
  23739. // Setlinfo struct {
  23740. // SetlTime string `json:"setl_time"`
  23741. // CvlservPay float64 `json:"cvlserv_pay"`
  23742. // Year string `json:"year"`
  23743. // MedType string `json:"med_type"`
  23744. // PsnPay float64 `json:"psn_pay"`
  23745. // OpterID string `json:"opter_id"`
  23746. // Begndate string `json:"begndate"`
  23747. // FlxempeFlag string `json:"flxempe_flag"`
  23748. // HifmiPay float64 `json:"hifmi_pay"`
  23749. // PsnNo string `json:"psn_no"`
  23750. // ActPayDedc float64 `json:"act_pay_dedc"`
  23751. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23752. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23753. // ClrWay string `json:"clr_way"`
  23754. // OthPay float64 `json:"oth_pay"`
  23755. // Gend string `json:"gend"`
  23756. // MdtrtID string `json:"mdtrt_id"`
  23757. // AcctPay float64 `json:"acct_pay"`
  23758. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23759. // Insutype string `json:"insutype"`
  23760. // Invono interface{} `json:"invono"`
  23761. // Enddate string `json:"enddate"`
  23762. // CashPayamt float64 `json:"cash_payamt"`
  23763. // PsnType string `json:"psn_type"`
  23764. // FixmedinsName string `json:"fixmedins_name"`
  23765. // HifpPay float64 `json:"hifp_pay"`
  23766. // NewFlag interface{} `json:"new_flag"`
  23767. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23768. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23769. // PayLoc string `json:"pay_loc"`
  23770. // ClrType string `json:"clr_type"`
  23771. // RefdSetlFlag string `json:"refd_setl_flag"`
  23772. // CvlservFlag string `json:"cvlserv_flag"`
  23773. // EmpName string `json:"emp_name"`
  23774. // Brdy string `json:"brdy"`
  23775. // Naty string `json:"naty"`
  23776. // Certno string `json:"certno"`
  23777. // DiseCode string `json:"dise_code"`
  23778. // FixmedinsCode string `json:"fixmedins_code"`
  23779. // DedcHospLv string `json:"dedc_hosp_lv"`
  23780. // OpterName string `json:"opter_name"`
  23781. // Balc float64 `json:"balc"`
  23782. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23783. // PsnCertType string `json:"psn_cert_type"`
  23784. // HifobPay float64 `json:"hifob_pay"`
  23785. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23786. // HifesPay float64 `json:"hifes_pay"`
  23787. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23788. // OptTime string `json:"opt_time"`
  23789. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23790. // SetlID string `json:"setl_id"`
  23791. // MafPay float64 `json:"maf_pay"`
  23792. // PsnName string `json:"psn_name"`
  23793. // InsuOptins interface{} `json:"insu_optins"`
  23794. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23795. // ClrOptins string `json:"clr_optins"`
  23796. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23797. // DiseName string `json:"dise_name"`
  23798. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23799. // Age float64 `json:"age"`
  23800. // DtrtCertType string `json:"dtrt_cert_type"`
  23801. // HospLv string `json:"hosp_lv"`
  23802. // } `json:"setlinfo"`
  23803. // Setldetail []struct {
  23804. // FundPayType string `json:"fund_pay_type"`
  23805. // FundPayamt float64 `json:"fund_payamt"`
  23806. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23807. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23808. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23809. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23810. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23811. // } `json:"setldetail"`
  23812. // } `json:"output"`
  23813. // Infcode int `json:"infcode"`
  23814. // WarnMsg interface{} `json:"warn_msg"`
  23815. // Cainfo interface{} `json:"cainfo"`
  23816. // ErrMsg interface{} `json:"err_msg"`
  23817. // RefmsgTime string `json:"refmsg_time"`
  23818. // Signtype interface{} `json:"signtype"`
  23819. // RespondTime string `json:"respond_time"`
  23820. // InfRefmsgid string `json:"inf_refmsgid"`
  23821. // }
  23822. type Result002 struct {
  23823. Cainfo interface{} `json:"cainfo"`
  23824. ErrMsg string `json:"err_msg"`
  23825. InfRefmsgid string `json:"inf_refmsgid"`
  23826. Infcode int64 `json:"infcode"`
  23827. Output struct {
  23828. RxFile string `json:"rx_file"`
  23829. SignDigest string `json:"sign_digest"`
  23830. SignCertSn string `json:"sign_cert_sn"`
  23831. SignCertDn string `json:"sign_cert_dn"`
  23832. } `json:"output"`
  23833. RefmsgTime string `json:"refmsg_time"`
  23834. RespondTime string `json:"respond_time"`
  23835. Signtype interface{} `json:"signtype"`
  23836. WarnMsg interface{} `json:"warn_msg"`
  23837. }
  23838. type AhResult002 struct {
  23839. RxFile string `json:"rxFile"`
  23840. SignDigest string `json:"signDigest"`
  23841. SignCertSn string `json:"signCertSn"`
  23842. SignCertDn string `json:"signCertDn"`
  23843. }
  23844. type Result003 struct {
  23845. Cainfo interface{} `json:"cainfo"`
  23846. ErrMsg string `json:"err_msg"`
  23847. InfRefmsgid string `json:"inf_refmsgid"`
  23848. Infcode int64 `json:"infcode"`
  23849. Output struct {
  23850. HiRxno string `json:"hi_rxno"`
  23851. RxStasCodg string `json:"rx_stas_codg"`
  23852. RxStasName string `json:"rx_stas_name"`
  23853. } `json:"output"`
  23854. RefmsgTime string `json:"refmsg_time"`
  23855. RespondTime string `json:"respond_time"`
  23856. Signtype interface{} `json:"signtype"`
  23857. WarnMsg interface{} `json:"warn_msg"`
  23858. }
  23859. type AHResult003 struct {
  23860. HiRxno string `json:"hiRxno"`
  23861. RxStasCodg string `json:"rxStasCodg"`
  23862. RxStasName string `json:"rxStasName"`
  23863. }
  23864. type ResultEleven struct {
  23865. Cainfo string `json:"cainfo"`
  23866. ErrMsg string `json:"err_msg"`
  23867. InfRefmsgid string `json:"inf_refmsgid"`
  23868. Infcode int64 `json:"infcode"`
  23869. Output struct {
  23870. Setlinfo struct {
  23871. SetlTime string `json:"setl_time"`
  23872. CvlservPay float64 `json:"cvlserv_pay"`
  23873. Year string `json:"year"`
  23874. MedType string `json:"med_type"`
  23875. PsnPay float64 `json:"psn_pay"`
  23876. OpterID string `json:"opter_id"`
  23877. Begndate string `json:"begndate"`
  23878. FlxempeFlag string `json:"flxempe_flag"`
  23879. HifmiPay float64 `json:"hifmi_pay"`
  23880. PsnNo string `json:"psn_no"`
  23881. ActPayDedc float64 `json:"act_pay_dedc"`
  23882. MedinsSetlID interface{} `json:"medins_setl_id"`
  23883. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23884. ClrWay string `json:"clr_way"`
  23885. OthPay float64 `json:"oth_pay"`
  23886. Gend string `json:"gend"`
  23887. MdtrtID string `json:"mdtrt_id"`
  23888. AcctPay float64 `json:"acct_pay"`
  23889. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23890. Insutype string `json:"insutype"`
  23891. Invono interface{} `json:"invono"`
  23892. Enddate string `json:"enddate"`
  23893. CashPayamt float64 `json:"cash_payamt"`
  23894. PsnType string `json:"psn_type"`
  23895. FixmedinsName string `json:"fixmedins_name"`
  23896. HifpPay float64 `json:"hifp_pay"`
  23897. NewFlag interface{} `json:"new_flag"`
  23898. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23899. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23900. PayLoc string `json:"pay_loc"`
  23901. ClrType string `json:"clr_type"`
  23902. RefdSetlFlag string `json:"refd_setl_flag"`
  23903. CvlservFlag string `json:"cvlserv_flag"`
  23904. EmpName string `json:"emp_name"`
  23905. Brdy string `json:"brdy"`
  23906. Naty string `json:"naty"`
  23907. Certno string `json:"certno"`
  23908. DiseCode string `json:"dise_code"`
  23909. FixmedinsCode string `json:"fixmedins_code"`
  23910. DedcHospLv string `json:"dedc_hosp_lv"`
  23911. OpterName string `json:"opter_name"`
  23912. Balc float64 `json:"balc"`
  23913. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23914. PsnCertType string `json:"psn_cert_type"`
  23915. HifobPay float64 `json:"hifob_pay"`
  23916. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23917. HifesPay float64 `json:"hifes_pay"`
  23918. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23919. OptTime string `json:"opt_time"`
  23920. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23921. SetlID string `json:"setl_id"`
  23922. MafPay float64 `json:"maf_pay"`
  23923. PsnName string `json:"psn_name"`
  23924. InsuOptins interface{} `json:"insu_optins"`
  23925. PrefFundPay interface{} `json:"pref_fund_pay"`
  23926. ClrOptins string `json:"clr_optins"`
  23927. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23928. DiseName string `json:"dise_name"`
  23929. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23930. Age float64 `json:"age"`
  23931. DtrtCertType string `json:"dtrt_cert_type"`
  23932. HospLv string `json:"hosp_lv"`
  23933. PsnCashPay float64 `json:"psn_cash_pay"`
  23934. } `json:"setlinfo"`
  23935. } `json:"output"`
  23936. RefmsgTime string `json:"refmsg_time"`
  23937. RespondTime string `json:"respond_time"`
  23938. Signtype interface{} `json:"signtype"`
  23939. WarnMsg interface{} `json:"warn_msg"`
  23940. }
  23941. type ResultElevenah struct {
  23942. Cainfo string `json:"cainfo"`
  23943. ErrMsg string `json:"err_msg"`
  23944. InfRefmsgid string `json:"inf_refmsgid"`
  23945. Infcode int64 `json:"infcode"`
  23946. Output struct {
  23947. Setlinfo struct {
  23948. SetlTime int64 `json:"setl_time"`
  23949. CvlservPay float64 `json:"cvlserv_pay"`
  23950. Year string `json:"year"`
  23951. MedType string `json:"med_type"`
  23952. PsnPay float64 `json:"psn_pay"`
  23953. OpterID string `json:"opter_id"`
  23954. Begndate int64 `json:"begndate"`
  23955. FlxempeFlag string `json:"flxempe_flag"`
  23956. HifmiPay float64 `json:"hifmi_pay"`
  23957. PsnNo string `json:"psn_no"`
  23958. ActPayDedc float64 `json:"act_pay_dedc"`
  23959. MedinsSetlID interface{} `json:"medins_setl_id"`
  23960. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23961. ClrWay string `json:"clr_way"`
  23962. OthPay float64 `json:"oth_pay"`
  23963. Gend string `json:"gend"`
  23964. MdtrtID string `json:"mdtrt_id"`
  23965. AcctPay float64 `json:"acct_pay"`
  23966. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23967. Insutype string `json:"insutype"`
  23968. Invono interface{} `json:"invono"`
  23969. Enddate int64 `json:"enddate"`
  23970. CashPayamt float64 `json:"cash_payamt"`
  23971. PsnType string `json:"psn_type"`
  23972. FixmedinsName string `json:"fixmedins_name"`
  23973. HifpPay float64 `json:"hifp_pay"`
  23974. NewFlag interface{} `json:"new_flag"`
  23975. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23976. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23977. PayLoc string `json:"pay_loc"`
  23978. ClrType string `json:"clr_type"`
  23979. RefdSetlFlag string `json:"refd_setl_flag"`
  23980. CvlservFlag string `json:"cvlserv_flag"`
  23981. EmpName string `json:"emp_name"`
  23982. Brdy int64 `json:"brdy"`
  23983. Naty string `json:"naty"`
  23984. Certno string `json:"certno"`
  23985. DiseCode string `json:"dise_code"`
  23986. FixmedinsCode string `json:"fixmedins_code"`
  23987. DedcHospLv string `json:"dedc_hosp_lv"`
  23988. OpterName string `json:"opter_name"`
  23989. Balc float64 `json:"balc"`
  23990. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23991. PsnCertType string `json:"psn_cert_type"`
  23992. HifobPay float64 `json:"hifob_pay"`
  23993. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23994. HifesPay float64 `json:"hifes_pay"`
  23995. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23996. OptTime int64 `json:"opt_time"`
  23997. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23998. SetlID string `json:"setl_id"`
  23999. MafPay float64 `json:"maf_pay"`
  24000. PsnName string `json:"psn_name"`
  24001. InsuOptins interface{} `json:"insu_optins"`
  24002. PrefFundPay interface{} `json:"pref_fund_pay"`
  24003. ClrOptins string `json:"clr_optins"`
  24004. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  24005. DiseName string `json:"dise_name"`
  24006. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  24007. Age float64 `json:"age"`
  24008. DtrtCertType string `json:"dtrt_cert_type"`
  24009. HospLv string `json:"hosp_lv"`
  24010. PsnCashPay float64 `json:"psn_cash_pay"`
  24011. } `json:"setlinfo"`
  24012. } `json:"output"`
  24013. RefmsgTime string `json:"refmsg_time"`
  24014. RespondTime string `json:"respond_time"`
  24015. Signtype interface{} `json:"signtype"`
  24016. WarnMsg interface{} `json:"warn_msg"`
  24017. }
  24018. type ResultEleven10265 struct {
  24019. Cainfo string `json:"cainfo"`
  24020. ErrMsg string `json:"err_msg"`
  24021. InfRefmsgid string `json:"inf_refmsgid"`
  24022. Infcode string `json:"infcode"`
  24023. Output struct {
  24024. Setlinfo struct {
  24025. SetlTime string `json:"setl_time"`
  24026. CvlservPay float64 `json:"cvlserv_pay"`
  24027. Year string `json:"year"`
  24028. MedType string `json:"med_type"`
  24029. PsnPay float64 `json:"psn_pay"`
  24030. OpterID string `json:"opter_id"`
  24031. Begndate string `json:"begndate"`
  24032. FlxempeFlag string `json:"flxempe_flag"`
  24033. HifmiPay float64 `json:"hifmi_pay"`
  24034. PsnNo string `json:"psn_no"`
  24035. ActPayDedc float64 `json:"act_pay_dedc"`
  24036. MedinsSetlID interface{} `json:"medins_setl_id"`
  24037. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  24038. ClrWay string `json:"clr_way"`
  24039. OthPay float64 `json:"oth_pay"`
  24040. Gend string `json:"gend"`
  24041. MdtrtID string `json:"mdtrt_id"`
  24042. AcctPay float64 `json:"acct_pay"`
  24043. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24044. Insutype string `json:"insutype"`
  24045. Invono interface{} `json:"invono"`
  24046. Enddate string `json:"enddate"`
  24047. CashPayamt float64 `json:"cash_payamt"`
  24048. PsnType string `json:"psn_type"`
  24049. FixmedinsName string `json:"fixmedins_name"`
  24050. HifpPay float64 `json:"hifp_pay"`
  24051. NewFlag interface{} `json:"new_flag"`
  24052. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24053. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24054. PayLoc string `json:"pay_loc"`
  24055. ClrType string `json:"clr_type"`
  24056. RefdSetlFlag string `json:"refd_setl_flag"`
  24057. CvlservFlag string `json:"cvlserv_flag"`
  24058. EmpName string `json:"emp_name"`
  24059. Brdy string `json:"brdy"`
  24060. Naty string `json:"naty"`
  24061. Certno string `json:"certno"`
  24062. DiseCode string `json:"dise_code"`
  24063. FixmedinsCode string `json:"fixmedins_code"`
  24064. DedcHospLv string `json:"dedc_hosp_lv"`
  24065. OpterName string `json:"opter_name"`
  24066. Balc float64 `json:"balc"`
  24067. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  24068. PsnCertType string `json:"psn_cert_type"`
  24069. HifobPay float64 `json:"hifob_pay"`
  24070. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24071. HifesPay float64 `json:"hifes_pay"`
  24072. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24073. OptTime string `json:"opt_time"`
  24074. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24075. SetlID string `json:"setl_id"`
  24076. MafPay float64 `json:"maf_pay"`
  24077. PsnName string `json:"psn_name"`
  24078. InsuOptins interface{} `json:"insu_optins"`
  24079. PrefFundPay interface{} `json:"pref_fund_pay"`
  24080. ClrOptins string `json:"clr_optins"`
  24081. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  24082. DiseName string `json:"dise_name"`
  24083. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  24084. Age float64 `json:"age"`
  24085. DtrtCertType string `json:"dtrt_cert_type"`
  24086. HospLv string `json:"hosp_lv"`
  24087. PsnCashPay float64 `json:"psn_cash_pay"`
  24088. } `json:"setlinfo"`
  24089. } `json:"output"`
  24090. RefmsgTime string `json:"refmsg_time"`
  24091. RespondTime string `json:"respond_time"`
  24092. Signtype interface{} `json:"signtype"`
  24093. WarnMsg interface{} `json:"warn_msg"`
  24094. }
  24095. type ResultTwelve struct {
  24096. Cainfo string `json:"cainfo"`
  24097. ErrMsg string `json:"err_msg"`
  24098. InfRefmsgid string `json:"inf_refmsgid"`
  24099. Infcode int64 `json:"infcode"`
  24100. Output struct {
  24101. MdtrtId string `json:"mdtrt_id"`
  24102. ChrgBchno string `json:"chrg_bchno"`
  24103. PsnNo string `json:"psn_no"`
  24104. } `json:"output"`
  24105. RefmsgTime string `json:"refmsg_time"`
  24106. RespondTime string `json:"respond_time"`
  24107. Signtype interface{} `json:"signtype"`
  24108. WarnMsg interface{} `json:"warn_msg"`
  24109. }
  24110. type ResultThirteen struct {
  24111. ErrMsg string `json:"err_msg"`
  24112. InfRefmsgid string `json:"inf_refmsgid"`
  24113. Infcode int64 `json:"infcode"`
  24114. Output struct {
  24115. Result struct {
  24116. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24117. } `json:"result"`
  24118. } `json:"output"`
  24119. RefmsgTime string `json:"refmsg_time"`
  24120. RespondTime string `json:"respond_time"`
  24121. Signtype interface{} `json:"signtype"`
  24122. WarnInfo interface{} `json:"warn_info"`
  24123. }
  24124. type ResultThirteen10265 struct {
  24125. ErrMsg string `json:"err_msg"`
  24126. InfRefmsgid string `json:"inf_refmsgid"`
  24127. Infcode string `json:"infcode"`
  24128. Output struct {
  24129. Result struct {
  24130. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24131. } `json:"result"`
  24132. } `json:"output"`
  24133. RefmsgTime string `json:"refmsg_time"`
  24134. RespondTime string `json:"respond_time"`
  24135. Signtype interface{} `json:"signtype"`
  24136. WarnInfo interface{} `json:"warn_info"`
  24137. }
  24138. type ResultFourteen struct {
  24139. ErrMsg string `json:"err_msg"`
  24140. InfRefmsgid string `json:"inf_refmsgid"`
  24141. Infcode int64 `json:"infcode"`
  24142. Output struct {
  24143. } `json:"output"`
  24144. RefmsgTime string `json:"refmsg_time"`
  24145. RespondTime string `json:"respond_time"`
  24146. Signtype interface{} `json:"signtype"`
  24147. WarnInfo interface{} `json:"warn_info"`
  24148. }
  24149. type ResultCFYLJG001 struct {
  24150. ErrMsg string `json:"err_msg"`
  24151. InfRefmsgid string `json:"inf_refmsgid"`
  24152. Infcode int64 `json:"infcode"`
  24153. Output struct {
  24154. RxTraceCode string `json:"rx_trace_code"`
  24155. HiRxno string `json:"hi_rxno"`
  24156. } `json:"output"`
  24157. RefmsgTime string `json:"refmsg_time"`
  24158. RespondTime string `json:"respond_time"`
  24159. Signtype interface{} `json:"signtype"`
  24160. WarnInfo interface{} `json:"warn_info"`
  24161. }
  24162. type ResultCFYLJG001AH struct {
  24163. RxTraceCode string `json:"rxTraceCode"`
  24164. HiRxno string `json:"hiRxno"`
  24165. }
  24166. type ResultCFYLJG007 struct {
  24167. ErrMsg string `json:"err_msg"`
  24168. InfRefmsgid string `json:"inf_refmsgid"`
  24169. Infcode int64 `json:"infcode"`
  24170. Output struct {
  24171. HiRxno string `json:"hi_rxno"`
  24172. RxStasName string `json:"rx_stas_name"`
  24173. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  24174. Seltdelts []interface{} `json:"seltdelts"`
  24175. RxUsedStasName string `json:"rx_used_stas_name"`
  24176. RxStasCodg string `json:"rx_stas_codg"`
  24177. } `json:"output"`
  24178. RefmsgTime string `json:"refmsg_time"`
  24179. RespondTime string `json:"respond_time"`
  24180. Signtype interface{} `json:"signtype"`
  24181. WarnInfo interface{} `json:"warn_info"`
  24182. }
  24183. type ResultCFYLJG002 struct {
  24184. ErrMsg string `json:"err_msg"`
  24185. InfRefmsgid string `json:"inf_refmsgid"`
  24186. Infcode int64 `json:"infcode"`
  24187. Output struct {
  24188. RxFile string `json:"rx_file"`
  24189. SignDigest string `json:"sign_digest"`
  24190. SignCertSn string `json:"sign_cert_sn"`
  24191. SignCertDn string `json:"sign_cert_dn"`
  24192. } `json:"output"`
  24193. RefmsgTime string `json:"refmsg_time"`
  24194. RespondTime string `json:"respond_time"`
  24195. Signtype interface{} `json:"signtype"`
  24196. WarnInfo interface{} `json:"warn_info"`
  24197. }
  24198. type ResultCFYLJG003 struct {
  24199. ErrMsg string `json:"err_msg"`
  24200. InfRefmsgid string `json:"inf_refmsgid"`
  24201. Infcode int64 `json:"infcode"`
  24202. Output struct {
  24203. HiRxno string `json:"hi_rxno"`
  24204. RxStasCodg string `json:"rx_stas_codg"`
  24205. RxStasName string `json:"rx_stas_name"`
  24206. } `json:"output"`
  24207. RefmsgTime string `json:"refmsg_time"`
  24208. RespondTime string `json:"respond_time"`
  24209. Signtype interface{} `json:"signtype"`
  24210. WarnInfo interface{} `json:"warn_info"`
  24211. }
  24212. type ResultCFYLJG004 struct {
  24213. ErrMsg string `json:"err_msg"`
  24214. InfRefmsgid string `json:"inf_refmsgid"`
  24215. Infcode int64 `json:"infcode"`
  24216. Output struct {
  24217. HiRxno string `json:"hi_rxno"`
  24218. RxStasCodg string `json:"rx_stas_codg"`
  24219. RxStasName string `json:"rx_stas_name"`
  24220. } `json:"output"`
  24221. RefmsgTime string `json:"refmsg_time"`
  24222. RespondTime string `json:"respond_time"`
  24223. Signtype interface{} `json:"signtype"`
  24224. WarnInfo interface{} `json:"warn_info"`
  24225. }
  24226. type ResultCFYLJG008 struct {
  24227. ErrMsg string `json:"err_msg"`
  24228. InfRefmsgid string `json:"inf_refmsgid"`
  24229. Infcode int64 `json:"infcode"`
  24230. Output struct {
  24231. PoolareaNo string `json:"poolareaNo"`
  24232. AdmdvsName string `json:"admdvsName"`
  24233. Count string `json:"count"`
  24234. } `json:"output"`
  24235. RefmsgTime string `json:"refmsg_time"`
  24236. RespondTime string `json:"respond_time"`
  24237. Signtype interface{} `json:"signtype"`
  24238. WarnInfo interface{} `json:"warn_info"`
  24239. }
  24240. type ResultCFYLJG005 struct {
  24241. ErrMsg string `json:"err_msg"`
  24242. InfRefmsgid string `json:"inf_refmsgid"`
  24243. Infcode int64 `json:"infcode"`
  24244. Output struct {
  24245. HiRxNo string `json:"hi_rxno"`
  24246. FixMedinsCode string `json:"fixmedins_code"`
  24247. FixMedinsName string `json:"fixmedins_name"`
  24248. RxStasCodg string `json:"rx_stas_codg"`
  24249. RxStasName string `json:"rx_stas_name"`
  24250. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  24251. RxUserdStasName string `json:"rx_userd_stas_name"`
  24252. PrscTime string `json:"prsc_time"`
  24253. RxDrugCnt float64 `json:"rx_drug_cnt"`
  24254. RxUsedWayCodg string `json:"rx_used_way_codg"`
  24255. RxUsedWayName string `json:"rx_used_way_name"`
  24256. RxFrquCodg string `json:"rx_frqu_codg"`
  24257. RxFrquName string `json:"rx_frqu_name"`
  24258. RxDosunt string `json:"rx_dosunt"`
  24259. RxDoscnt float64 `json:"rx_doscnt"`
  24260. RxDrordDscr string `json:"rx_drord_dscr"`
  24261. ValiDays int64 `json:"vali_days"`
  24262. ValiEndTime string `json:"vali_end_time"`
  24263. ReptFlag string `json:"rept_flag"`
  24264. MaxReptCnt int64 `json:"max_rept_cnt"`
  24265. ReptdCnt int64 `json:"reptd_cnt"`
  24266. MinInrvDays int64 `json:"min_inrv_days"`
  24267. RxTypeCode string `json:"rx_type_code"`
  24268. RxTypeName string `json:"rx_type_name"`
  24269. LongRxFlag string `json:"long_rx_flag"`
  24270. RxDetlList []struct {
  24271. MedListCodg string `json:"med_list_codg"`
  24272. MedinsListCodg string `json:"medins_list_codg"`
  24273. HospPrepFlag string `json:"hosp_prep_flag"`
  24274. RxItemTypeCode string `json:"rx_item_type_code"`
  24275. RxItemTypeName string `json:"rx_item_type_name"`
  24276. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24277. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24278. TcmHerbFoote string `json:"tcmherb_foote"`
  24279. MednTypeCode string `json:"medn_type_code"`
  24280. MednTypeName string `json:"medn_type_name"`
  24281. MainMedcFlag string `json:"main_medc_flag"`
  24282. UrgtFlag string `json:"urgt_flag"`
  24283. BasMednFlag string `json:"bas_medn_flag"`
  24284. ImpDrugFlag string `json:"imp_drug_flag"`
  24285. ProdBarc string `json:"prod_barc"`
  24286. DrugProdname string `json:"drug_prodname"`
  24287. GennameCodg string `json:"genname_codg"`
  24288. DrugGenname string `json:"drug_genname"`
  24289. DrugDosform string `json:"drug_dosform"`
  24290. DrugSpec string `json:"drug_spec"`
  24291. PrdrName string `json:"prdr_name"`
  24292. MedcWayCodg string `json:"medc_way_codg"`
  24293. MedcWayDscr string `json:"medc_way_dscr"`
  24294. MedcBegntime string `json:"medc_begntime"`
  24295. MedcEndtime string `json:"medc_endtime"`
  24296. MedcDays float64 `json:"medc_days"`
  24297. DrugPric float64 `json:"drug_pric"`
  24298. DrugSumamt float64 `json:"drug_sumamt"`
  24299. DrugCnt float64 `json:"drug_cnt"`
  24300. DrugDosunt string `json:"drug_dosunt"`
  24301. SinDoscnt float64 `json:"sin_doscnt"`
  24302. SinDosunt string `json:"sin_dosunt"`
  24303. UsedFrquCodg string `json:"used_frqu_codg"`
  24304. UsedFrquName string `json:"used_frqu_name"`
  24305. DrugTotlcnt string `json:"drug_totlcnt"`
  24306. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24307. DiseCodg string `json:"dise_codg"`
  24308. HospApprFlag string `json:"hosp_appr_flag"`
  24309. } `json:"rx_detl_list"`
  24310. RxOtpinfo struct {
  24311. MedType string `json:"med_type"`
  24312. IptOtpNo string `json:"ipt_otp_no"`
  24313. OtpIptFlag string `json:"otp_ipt_flag"`
  24314. PatnName string `json:"patn_name"`
  24315. PatnAge float64 `json:"patn_age"`
  24316. PatnHgt float64 `json:"patn_hgt"`
  24317. PatnWt float64 `json:"patn_wt"`
  24318. Gend string `json:"gend"`
  24319. GesoVal float64 `json:"geso_val"`
  24320. NwbFlag string `json:"nwb_flag"`
  24321. NwbAge string `json:"nwb_age"`
  24322. SuckPrdFlag string `json:"suck_prd_flag"`
  24323. AlgsHis string `json:"algs_his"`
  24324. Insutype string `json:"insutype"`
  24325. PrscDeptName string `json:"prsc_dept_name"`
  24326. PrscDrName string `json:"prsc_dr_name"`
  24327. PharName string `json:"phar_name"`
  24328. PharChkTime string `json:"phar_chk_time"`
  24329. MdtrtTime string `json:"mdtrt_time"`
  24330. DiseCodg string `json:"dise_codg"`
  24331. DiseName string `json:"dise_name"`
  24332. SpDiseFlag string `json:"sp_dise_flag"`
  24333. MaindiagCode string `json:"maindiag_code"`
  24334. MaindiagName string `json:"maindiag_name"`
  24335. DiseCondDscr string `json:"dise_cond_dscr"`
  24336. FstdiagFlag string `json:"fstdiag_flag"`
  24337. } `json:"rx_otpinfo"`
  24338. RxDiseList []struct {
  24339. DiagType string `json:"diag_type"`
  24340. MaindiagFlag string `json:"maindiag_flag"`
  24341. DiagSrtNo string `json:"diag_srt_no"`
  24342. DiagCode string `json:"diag_code"`
  24343. DiagName string `json:"diag_name"`
  24344. DiagDept string `json:"diag_dept"`
  24345. DiagDrNo string `json:"diag_dr_no"`
  24346. DiagDrName string `json:"diag_dr_name"`
  24347. DiagTime string `json:"diag_time"`
  24348. TcmDiseCode string `json:"tcm_dise_code"`
  24349. TcmDiseName string `json:"tcm_dise_name"`
  24350. TcmSympCode string `json:"tcmsymp_code"`
  24351. TcmSymp string `json:"tcmsymp"`
  24352. } `json:"rx_dise_list"`
  24353. } `json:"output"`
  24354. RefmsgTime string `json:"refmsg_time"`
  24355. RespondTime string `json:"respond_time"`
  24356. Signtype interface{} `json:"signtype"`
  24357. WarnInfo interface{} `json:"warn_info"`
  24358. }
  24359. type ResultCFYLJG006 struct {
  24360. ErrMsg string `json:"err_msg"`
  24361. InfRefmsgid string `json:"inf_refmsgid"`
  24362. Infcode int64 `json:"infcode"`
  24363. Output struct {
  24364. HiRxNo string `json:"hi_rxno"`
  24365. PharCode string `json:"phar_code"`
  24366. PharName string `json:"phar_name"`
  24367. RxChkOpnn string `json:"rx_chk_opnn"`
  24368. RxChkTime string `json:"rx_chk_time"`
  24369. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24370. RxChkStasName string `json:"rx_chk_stas_name"`
  24371. RxStasCodg string `json:"rx_stas_codg"`
  24372. RxStasName string `json:"rx_stas_name"`
  24373. } `json:"output"`
  24374. RefmsgTime string `json:"refmsg_time"`
  24375. RespondTime string `json:"respond_time"`
  24376. Signtype interface{} `json:"signtype"`
  24377. WarnInfo interface{} `json:"warn_info"`
  24378. }
  24379. type ResultFourteen10265 struct {
  24380. ErrMsg string `json:"err_msg"`
  24381. InfRefmsgid string `json:"inf_refmsgid"`
  24382. Infcode string `json:"infcode"`
  24383. Output struct {
  24384. } `json:"output"`
  24385. RefmsgTime string `json:"refmsg_time"`
  24386. RespondTime string `json:"respond_time"`
  24387. Signtype interface{} `json:"signtype"`
  24388. WarnInfo interface{} `json:"warn_info"`
  24389. }
  24390. type ResultSixteen struct {
  24391. Cainfo string `json:"cainfo"`
  24392. ErrMsg string `json:"err_msg"`
  24393. InfRefmsgid string `json:"inf_refmsgid"`
  24394. Infcode int64 `json:"infcode"`
  24395. Output struct {
  24396. Setlinfo struct {
  24397. MdtrtID string `json:"mdtrt_id"`
  24398. SetlID string `json:"setl_id"`
  24399. ClrOptins string `json:"clr_optins"`
  24400. SetlTime string `json:"setl_time"`
  24401. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24402. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24403. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24404. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24405. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24406. ActPayDedc float64 `json:"act_pay_dedc"`
  24407. HifpPay float64 `json:"hifp_pay"`
  24408. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24409. Lfpay float64 `json:"selfpay"`
  24410. CvlservPay float64 `json:"cvlserv_pay"`
  24411. HifesPay float64 `json:"hifes_pay"`
  24412. HifmiPay float64 `json:"hifmi_pay"`
  24413. HifobPay float64 `json:"hifob_pay"`
  24414. MafPay float64 `json:"maf_pay"`
  24415. OthPay float64 `json:"oth_pay"`
  24416. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24417. PsnPartAmt float64 `json:"psn_part_amt"`
  24418. AcctPay float64 `json:"acct_pay"`
  24419. Balc float64 `json:"balc"`
  24420. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24421. HospPartAmt float64 `json:"hosp_part_amt"`
  24422. MedinsSetlID string `json:"medins_setl_id"`
  24423. PdnCashPay string `json:"pdn_cash_pay"`
  24424. } `json:"setlinfo"`
  24425. } `json:"output"`
  24426. RefmsgTime string `json:"refmsg_time"`
  24427. RespondTime string `json:"respond_time"`
  24428. Signtype interface{} `json:"signtype"`
  24429. WarnMsg interface{} `json:"warn_msg"`
  24430. }
  24431. type ResultSixteen10265 struct {
  24432. Cainfo string `json:"cainfo"`
  24433. ErrMsg string `json:"err_msg"`
  24434. InfRefmsgid string `json:"inf_refmsgid"`
  24435. Infcode string `json:"infcode"`
  24436. Output struct {
  24437. Setlinfo struct {
  24438. MdtrtID string `json:"mdtrt_id"`
  24439. SetlID string `json:"setl_id"`
  24440. ClrOptins string `json:"clr_optins"`
  24441. SetlTime string `json:"setl_time"`
  24442. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24443. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24444. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24445. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24446. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24447. ActPayDedc float64 `json:"act_pay_dedc"`
  24448. HifpPay float64 `json:"hifp_pay"`
  24449. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24450. Lfpay float64 `json:"selfpay"`
  24451. CvlservPay float64 `json:"cvlserv_pay"`
  24452. HifesPay float64 `json:"hifes_pay"`
  24453. HifmiPay float64 `json:"hifmi_pay"`
  24454. HifobPay float64 `json:"hifob_pay"`
  24455. MafPay float64 `json:"maf_pay"`
  24456. OthPay float64 `json:"oth_pay"`
  24457. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24458. PsnPartAmt float64 `json:"psn_part_amt"`
  24459. AcctPay float64 `json:"acct_pay"`
  24460. Balc float64 `json:"balc"`
  24461. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24462. HospPartAmt float64 `json:"hosp_part_amt"`
  24463. MedinsSetlID string `json:"medins_setl_id"`
  24464. PdnCashPay string `json:"pdn_cash_pay"`
  24465. } `json:"setlinfo"`
  24466. } `json:"output"`
  24467. RefmsgTime string `json:"refmsg_time"`
  24468. RespondTime string `json:"respond_time"`
  24469. Signtype interface{} `json:"signtype"`
  24470. WarnMsg interface{} `json:"warn_msg"`
  24471. }
  24472. type ResultSixteen10265Two struct {
  24473. Cainfo string `json:"cainfo"`
  24474. ErrMsg string `json:"err_msg"`
  24475. InfRefmsgid string `json:"inf_refmsgid"`
  24476. Infcode string `json:"infcode"`
  24477. Output struct {
  24478. Setlinfo interface{} `json:"setlinfo"`
  24479. } `json:"output"`
  24480. RefmsgTime string `json:"refmsg_time"`
  24481. RespondTime string `json:"respond_time"`
  24482. Signtype interface{} `json:"signtype"`
  24483. WarnMsg interface{} `json:"warn_msg"`
  24484. }
  24485. type ResultgzSixteen10265Two struct {
  24486. Cainfo string `json:"cainfo"`
  24487. ErrMsg string `json:"err_msg"`
  24488. InfRefmsgid string `json:"inf_refmsgid"`
  24489. Infcode int64 `json:"infcode"`
  24490. Output struct {
  24491. Setlinfo interface{} `json:"setlinfo"`
  24492. } `json:"output"`
  24493. RefmsgTime string `json:"refmsg_time"`
  24494. RespondTime string `json:"respond_time"`
  24495. Signtype interface{} `json:"signtype"`
  24496. WarnMsg interface{} `json:"warn_msg"`
  24497. }
  24498. type ResultSeventeen struct {
  24499. ErrMsg string `json:"err_msg"`
  24500. InfRefmsgid string `json:"inf_refmsgid"`
  24501. Infcode int64 `json:"infcode"`
  24502. Output struct {
  24503. SetlListId string `json:"setl_list_id"`
  24504. } `json:"output"`
  24505. RefmsgTime string `json:"refmsg_time"`
  24506. RespondTime string `json:"respond_time"`
  24507. Signtype string `json:"signtype"`
  24508. WarnInfo string `json:"warn_info"`
  24509. }
  24510. type ResultSeventeenOther struct {
  24511. ErrMsg string `json:"err_msg"`
  24512. InfRefmsgid string `json:"inf_refmsgid"`
  24513. Infcode string `json:"infcode"`
  24514. Output struct {
  24515. SetlListId string `json:"setl_list_id"`
  24516. } `json:"output"`
  24517. RefmsgTime string `json:"refmsg_time"`
  24518. RespondTime string `json:"respond_time"`
  24519. Signtype string `json:"signtype"`
  24520. WarnInfo string `json:"warn_info"`
  24521. }
  24522. type Result90991 struct {
  24523. ErrMsg string `json:"err_msg"`
  24524. InfRefmsgid string `json:"inf_refmsgid"`
  24525. Infcode int64 `json:"infcode"`
  24526. Output struct {
  24527. Result struct {
  24528. PsnNo string `json:"psn_no"`
  24529. CardStat string `json:"card_stat"`
  24530. Certno string `json:"certno"`
  24531. PsnName string `json:"psn_name"`
  24532. CheckStat string `json:"check_stat"`
  24533. SscnoCheckStat string `json:"sscno_check_stat"`
  24534. } `json:"result"`
  24535. } `json:"output"`
  24536. RefmsgTime string `json:"refmsg_time"`
  24537. RespondTime string `json:"respond_time"`
  24538. Signtype interface{} `json:"signtype"`
  24539. WarnInfo interface{} `json:"warn_info"`
  24540. }
  24541. type Result90100 struct {
  24542. ErrMsg string `json:"err_msg"`
  24543. InfRefmsgid string `json:"inf_refmsgid"`
  24544. Infcode int64 `json:"infcode"`
  24545. Output struct {
  24546. PoolareaNo string `json:"poolarea_no"`
  24547. PoolareaNoName string `json:"poolarea_no_name"`
  24548. Insutype string `json:"insutype"`
  24549. InsutypeName string `json:"insutype_name"`
  24550. ClctType string `json:"clct_type"`
  24551. ClctTypeName string `json:"clct_type_name"`
  24552. ClctFlag string `json:"clct_flag"`
  24553. ClctFlagName string `json:"clct_flag_name"`
  24554. AccrymBegn string `json:"accrym_begn"`
  24555. AccrymEnd string `json:"accrym_end"`
  24556. ClctTime string `json:"clct_time"`
  24557. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24558. } `json:"output"`
  24559. RefmsgTime string `json:"refmsg_time"`
  24560. RespondTime string `json:"respond_time"`
  24561. Signtype interface{} `json:"signtype"`
  24562. WarnInfo interface{} `json:"warn_info"`
  24563. }
  24564. type Custom struct {
  24565. DetItemFeeSumamt string
  24566. Cut string
  24567. FeedetlSn string
  24568. Price string
  24569. MedListCodg string
  24570. Type int64
  24571. AdviceId int64
  24572. ProjectId int64
  24573. ItemId int64
  24574. }
  24575. type Result5301 struct {
  24576. ErrMsg string `json:"err_msg"`
  24577. InfRefmsgid string `json:"inf_refmsgid"`
  24578. Infcode int64 `json:"infcode"`
  24579. Output struct {
  24580. Result []struct {
  24581. OpspDiseCode string `json:"opsp_dise_code"`
  24582. OpspDiseName string `json:"opsp_dise_name"`
  24583. Begndate string `json:"begndate"`
  24584. Enddate string `json:"enddate"`
  24585. } `json:"feedetail"`
  24586. } `json:"output"`
  24587. RefmsgTime string `json:"refmsg_time"`
  24588. RespondTime string `json:"respond_time"`
  24589. Signtype interface{} `json:"signtype"`
  24590. WarnInfo interface{} `json:"warn_info"`
  24591. }
  24592. type Result5301For10265 struct {
  24593. ErrMsg string `json:"err_msg"`
  24594. InfRefmsgid string `json:"inf_refmsgid"`
  24595. Infcode string `json:"infcode"`
  24596. Output struct {
  24597. Result []struct {
  24598. OpspDiseCode string `json:"opsp_dise_code"`
  24599. OpspDiseName string `json:"opsp_dise_name"`
  24600. Begndate string `json:"begndate"`
  24601. Enddate string `json:"enddate"`
  24602. } `json:"feedetail"`
  24603. } `json:"output"`
  24604. RefmsgTime string `json:"refmsg_time"`
  24605. RespondTime string `json:"respond_time"`
  24606. Signtype interface{} `json:"signtype"`
  24607. WarnInfo interface{} `json:"warn_info"`
  24608. }
  24609. //获取个人信息----挂号-----上传就诊信息
  24610. func (c *HisApiController) GetRegisterInfo() {
  24611. id, _ := c.GetInt64("id")
  24612. record_time := c.GetString("record_time")
  24613. settlementValue, _ := c.GetInt64("settlement_value")
  24614. medical_insurance_card := c.GetString("medical_insurance_card")
  24615. name := c.GetString("name")
  24616. id_card_type, _ := c.GetInt64("id_card_type")
  24617. certificates, _ := c.GetInt64("certificates")
  24618. medical_care, _ := c.GetInt64("medical_care")
  24619. birthday := c.GetString("birthday")
  24620. id_card := c.GetString("id_card")
  24621. register_type, _ := c.GetInt64("register")
  24622. doctor, _ := c.GetInt64("doctor")
  24623. department, _ := c.GetInt64("department")
  24624. gender, _ := c.GetInt64("sex")
  24625. registration_fee, _ := c.GetFloat("registration_fee")
  24626. medical_expenses, _ := c.GetFloat("medical_expenses")
  24627. social_type, _ := c.GetInt64("social_type")
  24628. admin_user_id, _ := c.GetInt64("admin_user_id")
  24629. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24630. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24631. mdtrt_type := c.GetString("mdtrt_type")
  24632. if id_card_type == 5 {
  24633. id_card_type = 4
  24634. }
  24635. timeLayout := "2006-01-02"
  24636. loc, _ := time.LoadLocation("Local")
  24637. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24638. birthUnix := birthdays.Unix()
  24639. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24640. if err != nil {
  24641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24642. return
  24643. }
  24644. recordDateTime := theTime.Unix()
  24645. adminInfo := c.GetAdminUserInfo()
  24646. var patient service.Patients
  24647. if id == 0 {
  24648. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24649. } else {
  24650. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24651. }
  24652. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24653. if patientPrescription.ID == 0 {
  24654. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24655. }
  24656. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24657. if patient.ID == 0 {
  24658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24659. return
  24660. }
  24661. if len(patient.IdCardNo) == 0 {
  24662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24663. return
  24664. }
  24665. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24666. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24667. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24668. //就诊结算未完成,不能进行二次挂号
  24669. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24670. if len(his) >= 1 {
  24671. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24672. if len(his) >= 1 && order.ID == 0 {
  24673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24674. return
  24675. }
  24676. }
  24677. var aaaa string
  24678. //var register_log string
  24679. if config.IsOpen == 1 {
  24680. var res ResultTwo
  24681. var res10265 ResultTwo10265
  24682. var PsnNo string
  24683. var PsnCertType string
  24684. var Certno string
  24685. var PsnName string
  24686. var Gend string
  24687. var Naty string
  24688. var Brdy string
  24689. var Age float64
  24690. var infoStr string
  24691. var idetinfoStr string
  24692. var infocode int64
  24693. var verify_number string
  24694. fmt.Println(verify_number)
  24695. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24696. psn_info, _ := service.GetPsnByPatientId(id)
  24697. PsnNo = psn_info.PsnNo
  24698. PsnCertType = psn_info.PsnCertType
  24699. Certno = psn_info.Certno
  24700. PsnName = psn_info.PsnName
  24701. Gend = psn_info.Gend
  24702. Naty = psn_info.Naty
  24703. Brdy = psn_info.Brdy
  24704. Age = psn_info.Age
  24705. infoStr = psn_info.Insuinfo
  24706. idetinfoStr = psn_info.Idetinfo
  24707. infocode = 0
  24708. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24709. psn_info, _ := service.GetPsnByPatientId(id)
  24710. PsnNo = psn_info.PsnNo
  24711. PsnCertType = psn_info.PsnCertType
  24712. Certno = psn_info.Certno
  24713. PsnName = psn_info.PsnName
  24714. Gend = psn_info.Gend
  24715. Naty = psn_info.Naty
  24716. Brdy = psn_info.Brdy
  24717. Age = psn_info.Age
  24718. infoStr = psn_info.Insuinfo
  24719. idetinfoStr = psn_info.Idetinfo
  24720. infocode = 0
  24721. verify_number = psn_info.VerifyNumber
  24722. } else if miConfig.MdtrtareaAdmvs == "150404" {
  24723. if id_card_type == 2 {
  24724. //请求内网数据
  24725. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24726. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24727. "&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
  24728. resp, requestErr := http.Get(api)
  24729. if requestErr != nil {
  24730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24731. return
  24732. }
  24733. body, ioErr := ioutil.ReadAll(resp.Body)
  24734. if ioErr != nil {
  24735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24737. return
  24738. }
  24739. var respJSON map[string]interface{}
  24740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24743. return
  24744. }
  24745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24746. result_byte, _ := json.Marshal(respJSON)
  24747. result := string(result_byte)
  24748. var dat map[string]interface{}
  24749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24750. fmt.Println(dat)
  24751. } else {
  24752. fmt.Println(err)
  24753. }
  24754. userJSONBytes, _ := json.Marshal(dat)
  24755. var res ResultTwo
  24756. var resTwo10265 ResultTwo10265
  24757. if miConfig.Code == "H15049901371" {
  24758. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24759. utils.ErrorLog("解析失败:%v", err)
  24760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24761. return
  24762. }
  24763. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24764. res.Infcode = Infcode
  24765. res.ErrMsg = resTwo10265.ErrMsg
  24766. res.Output = resTwo10265.Output
  24767. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24768. res.RespondTime = resTwo10265.RespondTime
  24769. res.WarnInfo = resTwo10265.WarnInfo
  24770. } else {
  24771. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24772. utils.ErrorLog("解析失败:%v", err)
  24773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24774. return
  24775. }
  24776. }
  24777. //var insutypes []string
  24778. //var insutype string
  24779. //var is390 int = 0
  24780. //var is310 int = 0
  24781. //for _, item := range res.Output.Iinfo {
  24782. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24783. // insutypes = append(insutypes, item.Insutype)
  24784. // }
  24785. //}
  24786. //if len(insutypes) == 1 {
  24787. // insutype = insutypes[0]
  24788. //} else {
  24789. // for _, i := range insutypes {
  24790. // if i == "390" {
  24791. // is390 = 1
  24792. // }
  24793. //
  24794. // if i == "310" {
  24795. // is310 = 1
  24796. // }
  24797. // }
  24798. //}
  24799. //if is390 == 1 {
  24800. // insutype = "390"
  24801. //}
  24802. //if is310 == 1 {
  24803. // insutype = "310"
  24804. //}
  24805. //if len(insutypes) == 0 {
  24806. // insutype = "310"
  24807. //}
  24808. PsnNo = res.Output.Baseinfo.PsnNo
  24809. PsnCertType = res.Output.Baseinfo.PsnCertType
  24810. Certno = res.Output.Baseinfo.Certno
  24811. PsnName = res.Output.Baseinfo.PsnName
  24812. Gend = res.Output.Baseinfo.Gend
  24813. Naty = res.Output.Baseinfo.Naty
  24814. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24815. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24816. infoStr = string(Iinfos)
  24817. idetinfoStr = string(Idetinfos)
  24818. infocode = res.Infcode
  24819. //infocode = 0
  24820. //verify_number = psn_info.VerifyNumber
  24821. } else {
  24822. psn_info, _ := service.GetPsnByPatientId(id)
  24823. PsnNo = psn_info.PsnNo
  24824. PsnCertType = psn_info.PsnCertType
  24825. Certno = psn_info.Certno
  24826. PsnName = psn_info.PsnName
  24827. Gend = psn_info.Gend
  24828. Naty = psn_info.Naty
  24829. Brdy = psn_info.Brdy
  24830. Age = psn_info.Age
  24831. infoStr = psn_info.Insuinfo
  24832. idetinfoStr = psn_info.Idetinfo
  24833. infocode = 0
  24834. verify_number = psn_info.VerifyNumber
  24835. }
  24836. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24837. if id_card_type == 1 {
  24838. psn_info, _ := service.GetPsnByPatientId(id)
  24839. PsnNo = psn_info.PsnNo
  24840. PsnCertType = psn_info.PsnCertType
  24841. Certno = psn_info.Certno
  24842. PsnName = psn_info.PsnName
  24843. Gend = psn_info.Gend
  24844. Naty = psn_info.Naty
  24845. Brdy = psn_info.Brdy
  24846. Age = psn_info.Age
  24847. infoStr = psn_info.Insuinfo
  24848. idetinfoStr = psn_info.Idetinfo
  24849. infocode = 0
  24850. verify_number = psn_info.VerifyNumber
  24851. } else if id_card_type == 2 {
  24852. 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)
  24853. fmt.Println(errMsgLog)
  24854. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24855. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24856. utils.ErrorLog("解析失败:%v", err)
  24857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24858. return
  24859. }
  24860. PsnNo = res.Output.Baseinfo.PsnNo
  24861. PsnCertType = res.Output.Baseinfo.PsnCertType
  24862. Certno = res.Output.Baseinfo.Certno
  24863. PsnName = res.Output.Baseinfo.PsnName
  24864. Gend = res.Output.Baseinfo.Gend
  24865. Naty = res.Output.Baseinfo.Naty
  24866. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24867. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24868. infoStr = string(Iinfos)
  24869. idetinfoStr = string(Idetinfos)
  24870. infocode = res.Infcode
  24871. }
  24872. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24873. if id_card_type == 1 {
  24874. psn_info, _ := service.GetPsnByPatientId(id)
  24875. PsnNo = psn_info.PsnNo
  24876. PsnCertType = psn_info.PsnCertType
  24877. Certno = psn_info.Certno
  24878. PsnName = psn_info.PsnName
  24879. Gend = psn_info.Gend
  24880. Naty = psn_info.Naty
  24881. Brdy = psn_info.Brdy
  24882. Age = psn_info.Age
  24883. infoStr = psn_info.Insuinfo
  24884. idetinfoStr = psn_info.Idetinfo
  24885. infocode = 0
  24886. verify_number = psn_info.VerifyNumber
  24887. } else if id_card_type == 2 {
  24888. 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, "")
  24889. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24890. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24891. utils.ErrorLog("解析失败:%v", err)
  24892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24893. return
  24894. }
  24895. PsnNo = res.Output.Baseinfo.PsnNo
  24896. PsnCertType = res.Output.Baseinfo.PsnCertType
  24897. Certno = res.Output.Baseinfo.Certno
  24898. PsnName = res.Output.Baseinfo.PsnName
  24899. Gend = res.Output.Baseinfo.Gend
  24900. Naty = res.Output.Baseinfo.Naty
  24901. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24902. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24903. infoStr = string(Iinfos)
  24904. idetinfoStr = string(Idetinfos)
  24905. infocode = res.Infcode
  24906. } else {
  24907. psn_info, _ := service.GetPsnByPatientId(id)
  24908. PsnNo = psn_info.PsnNo
  24909. PsnCertType = psn_info.PsnCertType
  24910. Certno = psn_info.Certno
  24911. PsnName = psn_info.PsnName
  24912. Gend = psn_info.Gend
  24913. Naty = psn_info.Naty
  24914. Brdy = psn_info.Brdy
  24915. Age = psn_info.Age
  24916. infoStr = psn_info.Insuinfo
  24917. idetinfoStr = psn_info.Idetinfo
  24918. infocode = 0
  24919. verify_number = psn_info.VerifyNumber
  24920. }
  24921. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24922. if id_card_type == 1 {
  24923. psn_info, _ := service.GetPsnByPatientId(id)
  24924. PsnNo = psn_info.PsnNo
  24925. PsnCertType = psn_info.PsnCertType
  24926. Certno = psn_info.Certno
  24927. PsnName = psn_info.PsnName
  24928. Gend = psn_info.Gend
  24929. Naty = psn_info.Naty
  24930. Brdy = psn_info.Brdy
  24931. Age = psn_info.Age
  24932. infoStr = psn_info.Insuinfo
  24933. idetinfoStr = psn_info.Idetinfo
  24934. infocode = 0
  24935. verify_number = psn_info.VerifyNumber
  24936. } else if id_card_type == 2 {
  24937. psn_info, _ := service.GetPsnByPatientId(id)
  24938. PsnNo = psn_info.PsnNo
  24939. PsnCertType = psn_info.PsnCertType
  24940. Certno = psn_info.Certno
  24941. PsnName = psn_info.PsnName
  24942. Gend = psn_info.Gend
  24943. Naty = psn_info.Naty
  24944. Brdy = psn_info.Brdy
  24945. Age = psn_info.Age
  24946. infoStr = psn_info.Insuinfo
  24947. idetinfoStr = psn_info.Idetinfo
  24948. infocode = 0
  24949. verify_number = psn_info.VerifyNumber
  24950. } else {
  24951. psn_info, _ := service.GetPsnByPatientId(id)
  24952. PsnNo = psn_info.PsnNo
  24953. PsnCertType = psn_info.PsnCertType
  24954. Certno = psn_info.Certno
  24955. PsnName = psn_info.PsnName
  24956. Gend = psn_info.Gend
  24957. Naty = psn_info.Naty
  24958. Brdy = psn_info.Brdy
  24959. Age = psn_info.Age
  24960. infoStr = psn_info.Insuinfo
  24961. idetinfoStr = psn_info.Idetinfo
  24962. infocode = 0
  24963. verify_number = psn_info.VerifyNumber
  24964. }
  24965. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24966. if id_card_type == 1 {
  24967. psn_info, _ := service.GetPsnByPatientId(id)
  24968. PsnNo = psn_info.PsnNo
  24969. PsnCertType = psn_info.PsnCertType
  24970. Certno = psn_info.Certno
  24971. PsnName = psn_info.PsnName
  24972. Gend = psn_info.Gend
  24973. Naty = psn_info.Naty
  24974. Brdy = psn_info.Brdy
  24975. Age = psn_info.Age
  24976. infoStr = psn_info.Insuinfo
  24977. idetinfoStr = psn_info.Idetinfo
  24978. infocode = 0
  24979. verify_number = psn_info.VerifyNumber
  24980. } else if id_card_type == 2 {
  24981. psn_info, _ := service.GetPsnByPatientId(id)
  24982. PsnNo = psn_info.PsnNo
  24983. PsnCertType = psn_info.PsnCertType
  24984. Certno = psn_info.Certno
  24985. PsnName = psn_info.PsnName
  24986. Gend = psn_info.Gend
  24987. Naty = psn_info.Naty
  24988. Brdy = psn_info.Brdy
  24989. Age = psn_info.Age
  24990. infoStr = psn_info.Insuinfo
  24991. idetinfoStr = psn_info.Idetinfo
  24992. infocode = 0
  24993. verify_number = psn_info.VerifyNumber
  24994. } else {
  24995. psn_info, _ := service.GetPsnByPatientId(id)
  24996. PsnNo = psn_info.PsnNo
  24997. PsnCertType = psn_info.PsnCertType
  24998. Certno = psn_info.Certno
  24999. PsnName = psn_info.PsnName
  25000. Gend = psn_info.Gend
  25001. Naty = psn_info.Naty
  25002. Brdy = psn_info.Brdy
  25003. Age = psn_info.Age
  25004. infoStr = psn_info.Insuinfo
  25005. idetinfoStr = psn_info.Idetinfo
  25006. infocode = 0
  25007. verify_number = psn_info.VerifyNumber
  25008. }
  25009. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  25010. psn_info, _ := service.GetPsnByPatientId(id)
  25011. PsnNo = psn_info.PsnNo
  25012. PsnCertType = psn_info.PsnCertType
  25013. Certno = psn_info.Certno
  25014. PsnName = psn_info.PsnName
  25015. Gend = psn_info.Gend
  25016. Naty = psn_info.Naty
  25017. Brdy = psn_info.Brdy
  25018. Age = psn_info.Age
  25019. infoStr = psn_info.Insuinfo
  25020. idetinfoStr = psn_info.Idetinfo
  25021. infocode = 0
  25022. verify_number = psn_info.VerifyNumber
  25023. idetinfoStr = psn_info.Idetinfo
  25024. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25025. if id_card_type == 1 {
  25026. psn_info, _ := service.GetPsnByPatientId(id)
  25027. PsnNo = psn_info.PsnNo
  25028. PsnCertType = psn_info.PsnCertType
  25029. Certno = psn_info.Certno
  25030. PsnName = psn_info.PsnName
  25031. Gend = psn_info.Gend
  25032. Naty = psn_info.Naty
  25033. Brdy = psn_info.Brdy
  25034. Age = psn_info.Age
  25035. infoStr = psn_info.Insuinfo
  25036. idetinfoStr = psn_info.Idetinfo
  25037. infocode = 0
  25038. verify_number = psn_info.VerifyNumber
  25039. } else if id_card_type == 2 {
  25040. 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)
  25041. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25042. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25043. utils.ErrorLog("解析失败:%v", err)
  25044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25045. return
  25046. }
  25047. PsnNo = res.Output.Baseinfo.PsnNo
  25048. PsnCertType = res.Output.Baseinfo.PsnCertType
  25049. Certno = res.Output.Baseinfo.Certno
  25050. PsnName = res.Output.Baseinfo.PsnName
  25051. Gend = res.Output.Baseinfo.Gend
  25052. Naty = res.Output.Baseinfo.Naty
  25053. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25054. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25055. infoStr = string(Iinfos)
  25056. idetinfoStr = string(Idetinfos)
  25057. infocode = res.Infcode
  25058. } else if id_card_type == 4 {
  25059. psn_info, _ := service.GetPsnByPatientId(id)
  25060. PsnNo = psn_info.PsnNo
  25061. PsnCertType = psn_info.PsnCertType
  25062. Certno = psn_info.Certno
  25063. PsnName = psn_info.PsnName
  25064. Gend = psn_info.Gend
  25065. Naty = psn_info.Naty
  25066. Brdy = psn_info.Brdy
  25067. Age = psn_info.Age
  25068. infoStr = psn_info.Insuinfo
  25069. idetinfoStr = psn_info.Idetinfo
  25070. infocode = 0
  25071. verify_number = psn_info.VerifyNumber
  25072. }
  25073. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25074. var result string
  25075. var requestLog string
  25076. 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), "")
  25077. if id_card_type == 4 {
  25078. psn_info, _ := service.GetPsnByPatientId(id)
  25079. PsnNo = psn_info.PsnNo
  25080. PsnCertType = psn_info.PsnCertType
  25081. Certno = psn_info.Certno
  25082. PsnName = psn_info.PsnName
  25083. Gend = psn_info.Gend
  25084. Naty = psn_info.Naty
  25085. Brdy = psn_info.Brdy
  25086. Age = psn_info.Age
  25087. infoStr = psn_info.Insuinfo
  25088. idetinfoStr = psn_info.Idetinfo
  25089. infocode = 0
  25090. verify_number = psn_info.VerifyNumber
  25091. } else {
  25092. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25093. if miConfig.Code == "H15049901371" {
  25094. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25095. utils.ErrorLog("解析失败:%v", err)
  25096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25097. return
  25098. }
  25099. res.ErrMsg = res10265.ErrMsg
  25100. res.Output = res10265.Output
  25101. res.InfRefmsgid = res10265.InfRefmsgid
  25102. } else {
  25103. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25104. utils.ErrorLog("解析失败:%v", err)
  25105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25106. return
  25107. }
  25108. }
  25109. PsnNo = res.Output.Baseinfo.PsnNo
  25110. PsnCertType = res.Output.Baseinfo.PsnCertType
  25111. Certno = res.Output.Baseinfo.Certno
  25112. PsnName = res.Output.Baseinfo.PsnName
  25113. Gend = res.Output.Baseinfo.Gend
  25114. Naty = res.Output.Baseinfo.Naty
  25115. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25116. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25117. infoStr = string(Iinfos)
  25118. idetinfoStr = string(Idetinfos)
  25119. if miConfig.Code == "H15049901371" {
  25120. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25121. } else {
  25122. infocode = res.Infcode
  25123. }
  25124. }
  25125. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25126. psn_info, _ := service.GetPsnByPatientId(id)
  25127. PsnNo = psn_info.PsnNo
  25128. PsnCertType = psn_info.PsnCertType
  25129. Certno = psn_info.Certno
  25130. PsnName = psn_info.PsnName
  25131. Gend = psn_info.Gend
  25132. Naty = psn_info.Naty
  25133. Brdy = psn_info.Brdy
  25134. Age = psn_info.Age
  25135. infoStr = psn_info.Insuinfo
  25136. idetinfoStr = psn_info.Idetinfo
  25137. infocode = 0
  25138. verify_number = psn_info.VerifyNumber
  25139. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25140. psn_info, _ := service.GetPsnByPatientId(id)
  25141. PsnNo = psn_info.PsnNo
  25142. PsnCertType = psn_info.PsnCertType
  25143. Certno = psn_info.Certno
  25144. PsnName = psn_info.PsnName
  25145. Gend = psn_info.Gend
  25146. Naty = psn_info.Naty
  25147. Brdy = psn_info.Brdy
  25148. Age = psn_info.Age
  25149. infoStr = psn_info.Insuinfo
  25150. idetinfoStr = psn_info.Idetinfo
  25151. infocode = 0
  25152. verify_number = psn_info.VerifyNumber
  25153. } else {
  25154. var result string
  25155. var requestLog string
  25156. //if miConfig.UserOrgId == 10138 {
  25157. if id_card_type != 4 || id_card_type != 1 {
  25158. var insa string
  25159. if len(patient.InsuplcAdmdvs) > 0 {
  25160. insa = patient.InsuplcAdmdvs
  25161. } else {
  25162. insa = miConfig.InsuplcAdmdvs
  25163. }
  25164. //psn_info, _ := service.GetPsnByPatientId(id)
  25165. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  25166. 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)
  25167. }
  25168. //}
  25169. //else {
  25170. // var insa string
  25171. // if len(patient.InsuplcAdmdvs) > 0 {
  25172. // insa = patient.InsuplcAdmdvs
  25173. // } else {
  25174. // insa = miConfig.InsuplcAdmdvs
  25175. // }
  25176. // 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)
  25177. //}
  25178. if id_card_type == 4 || id_card_type == 1 {
  25179. psn_info, _ := service.GetPsnByPatientId(id)
  25180. PsnNo = psn_info.PsnNo
  25181. PsnCertType = psn_info.PsnCertType
  25182. Certno = psn_info.Certno
  25183. PsnName = psn_info.PsnName
  25184. Gend = psn_info.Gend
  25185. Naty = psn_info.Naty
  25186. Brdy = psn_info.Brdy
  25187. Age = psn_info.Age
  25188. infoStr = psn_info.Insuinfo
  25189. idetinfoStr = psn_info.Idetinfo
  25190. infocode = 0
  25191. verify_number = psn_info.VerifyNumber
  25192. } else {
  25193. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25194. if miConfig.Code == "H15049901371" {
  25195. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25196. utils.ErrorLog("解析失败:%v", err)
  25197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25198. return
  25199. }
  25200. res.ErrMsg = res10265.ErrMsg
  25201. res.Output = res10265.Output
  25202. res.InfRefmsgid = res10265.InfRefmsgid
  25203. } else {
  25204. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25205. utils.ErrorLog("解析失败:%v", err)
  25206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25207. return
  25208. }
  25209. }
  25210. PsnNo = res.Output.Baseinfo.PsnNo
  25211. PsnCertType = res.Output.Baseinfo.PsnCertType
  25212. Certno = res.Output.Baseinfo.Certno
  25213. PsnName = res.Output.Baseinfo.PsnName
  25214. Gend = res.Output.Baseinfo.Gend
  25215. Naty = res.Output.Baseinfo.Naty
  25216. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25217. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25218. infoStr = string(Iinfos)
  25219. idetinfoStr = string(Idetinfos)
  25220. if miConfig.Code == "H15049901371" {
  25221. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25222. } else {
  25223. infocode = res.Infcode
  25224. }
  25225. }
  25226. }
  25227. if infocode == 0 {
  25228. his := models.VMHisPatient{
  25229. Name: name,
  25230. Gender: gender,
  25231. Birthday: birthUnix,
  25232. MedicalTreatmentType: medical_care,
  25233. IdType: certificates,
  25234. IdCardNo: id_card,
  25235. BalanceAccountsType: settlementValue,
  25236. SocialType: social_type,
  25237. MedicalInsuranceNumber: medical_insurance_card,
  25238. RegisterType: register_type,
  25239. RegisterCost: registration_fee,
  25240. TreatmentCost: medical_expenses,
  25241. Status: 1,
  25242. Ctime: time.Now().Unix(),
  25243. Mtime: time.Now().Unix(),
  25244. PsnNo: PsnNo,
  25245. PsnCertType: PsnCertType,
  25246. Certno: Certno,
  25247. PsnName: PsnName,
  25248. Gend: Gend,
  25249. Naty: Naty,
  25250. Brdy: Brdy,
  25251. Age: Age,
  25252. Iinfo: infoStr,
  25253. Idetinfo: idetinfoStr,
  25254. PatientId: patient.ID,
  25255. RecordDate: theTime.Unix(),
  25256. UserOrgId: adminInfo.CurrentOrgId,
  25257. AdminUserId: admin_user_id,
  25258. IsReturn: 1,
  25259. IdCardType: id_card_type,
  25260. Doctor: doctor,
  25261. Departments: department,
  25262. MdtrtGrpType: mdtrt_type,
  25263. }
  25264. timestamp := time.Now().Unix()
  25265. tempTime := time.Unix(timestamp, 0)
  25266. timeFormat := tempTime.Format("20060102150405")
  25267. chrgBchno := rand.Intn(100000) + 10000
  25268. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25269. his.Number = ipt_otp_no
  25270. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25271. department, _ := service.GetDepartMentDetail(department)
  25272. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25273. IdCardNo := ""
  25274. if id_card_type == 1 {
  25275. // IdCardNo = medical_insurance_card
  25276. IdCardNo = patient.IdCardNo
  25277. } else {
  25278. IdCardNo = patient.IdCardNo
  25279. }
  25280. var rf []*ResultFive
  25281. json.Unmarshal([]byte(his.Iinfo), &rf)
  25282. var insutypes []*ResultFive
  25283. var insutype string
  25284. var insuplc_admdvs_temp string
  25285. var is390 int = 0
  25286. var is310 int = 0
  25287. for _, item := range rf {
  25288. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25289. insutypes = append(insutypes, item)
  25290. }
  25291. }
  25292. if len(insutypes) == 1 {
  25293. insutype = insutypes[0].Insutype
  25294. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25295. if insutype == "390" {
  25296. is390 = 1
  25297. }
  25298. if insutype == "310" {
  25299. is310 = 1
  25300. }
  25301. } else {
  25302. for _, i := range insutypes {
  25303. if i.Insutype == "390" {
  25304. is390 = 1
  25305. }
  25306. if i.Insutype == "310" {
  25307. is310 = 1
  25308. }
  25309. }
  25310. }
  25311. if is390 == 1 {
  25312. insutype = "390"
  25313. }
  25314. if is310 == 1 {
  25315. insutype = "310"
  25316. }
  25317. fmt.Println(social_type)
  25318. if social_type > 0 {
  25319. insutype = strconv.FormatInt(social_type, 10)
  25320. }
  25321. var infocode int64
  25322. var resThree ResultThree
  25323. var resThree10265 ResultThree10265
  25324. if len(insuplc_admdvs) == 0 {
  25325. psn_info, _ := service.GetPsnByPatientId(id)
  25326. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25327. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25328. //}
  25329. } else {
  25330. insuplc_admdvs_temp = insuplc_admdvs
  25331. }
  25332. if miConfig.MdtrtareaAdmvs == "421300" {
  25333. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25334. psn_info, _ := service.GetPsnByPatientId(id)
  25335. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25336. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25337. "&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
  25338. resp, requestErr := http.Get(api)
  25339. if requestErr != nil {
  25340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25341. return
  25342. }
  25343. body, ioErr := ioutil.ReadAll(resp.Body)
  25344. if ioErr != nil {
  25345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25347. return
  25348. }
  25349. var respJSON map[string]interface{}
  25350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25353. return
  25354. }
  25355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25356. result, _ := json.Marshal(respJSON)
  25357. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25358. utils.ErrorLog("解析失败:%v", err)
  25359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25360. return
  25361. }
  25362. infocode = resThree.Infcode
  25363. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25364. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25365. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25366. // insuplc_admdvs_temp =
  25367. //}
  25368. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25369. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25370. //}
  25371. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25372. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25373. "&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
  25374. resp, requestErr := http.Get(api)
  25375. if requestErr != nil {
  25376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25377. return
  25378. }
  25379. body, ioErr := ioutil.ReadAll(resp.Body)
  25380. if ioErr != nil {
  25381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25383. return
  25384. }
  25385. var respJSON map[string]interface{}
  25386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25389. return
  25390. }
  25391. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25392. result, _ := json.Marshal(respJSON)
  25393. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25394. utils.ErrorLog("解析失败:%v", err)
  25395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25396. return
  25397. }
  25398. infocode = resThree.Infcode
  25399. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25400. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25401. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25402. // insuplc_admdvs_temp =
  25403. //}
  25404. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25405. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25406. //}
  25407. utils.ErrorLog("解析失败:%v", insutype)
  25408. utils.ErrorLog("解析失败:%v", PsnNo)
  25409. utils.ErrorLog("解析失败:%v", Certno)
  25410. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25411. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25412. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25413. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25414. utils.ErrorLog("解析失败:%v", PsnNo)
  25415. utils.ErrorLog("解析失败:%v", department.Number)
  25416. utils.ErrorLog("解析失败:%v", department.Name)
  25417. utils.ErrorLog("解析失败:%v", roles.UserName)
  25418. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25419. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25420. "&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
  25421. resp, requestErr := http.Get(api)
  25422. if requestErr != nil {
  25423. utils.ErrorLog("解析失败:%v", requestErr)
  25424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25425. return
  25426. }
  25427. body, ioErr := ioutil.ReadAll(resp.Body)
  25428. if ioErr != nil {
  25429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25431. return
  25432. }
  25433. var respJSON map[string]interface{}
  25434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25437. return
  25438. }
  25439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25440. result, _ := json.Marshal(respJSON)
  25441. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25442. utils.ErrorLog("解析失败:%v", err)
  25443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25444. return
  25445. }
  25446. infocode = resThree.Infcode
  25447. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25448. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25449. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25450. // insuplc_admdvs_temp =
  25451. //}
  25452. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25453. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25454. //}
  25455. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25456. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25457. "&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
  25458. resp, requestErr := http.Get(api)
  25459. if requestErr != nil {
  25460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25461. return
  25462. }
  25463. body, ioErr := ioutil.ReadAll(resp.Body)
  25464. if ioErr != nil {
  25465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25467. return
  25468. }
  25469. var respJSON map[string]interface{}
  25470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25473. return
  25474. }
  25475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25476. result, _ := json.Marshal(respJSON)
  25477. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25478. utils.ErrorLog("解析失败:%v", err)
  25479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25480. return
  25481. }
  25482. infocode = resThree.Infcode
  25483. } else if miConfig.MdtrtareaAdmvs == "150404" {
  25484. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25485. psn_info, _ := service.GetPsnByPatientId(id)
  25486. var verify_number string
  25487. if id_card_type == 4 {
  25488. verify_number = psn_info.VerifyNumber
  25489. } else if id_card_type == 1 {
  25490. bas := strings.Split(psn_info.CardInfo, "|")
  25491. cardNumber := bas[2]
  25492. verify_number = cardNumber
  25493. }
  25494. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25495. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25496. "&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
  25497. resp, requestErr := http.Get(api)
  25498. if requestErr != nil {
  25499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25500. return
  25501. }
  25502. body, ioErr := ioutil.ReadAll(resp.Body)
  25503. if ioErr != nil {
  25504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25506. return
  25507. }
  25508. var respJSON map[string]interface{}
  25509. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25512. return
  25513. }
  25514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25515. result, _ := json.Marshal(respJSON)
  25516. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25517. // utils.ErrorLog("解析失败:%v", err)
  25518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25519. // return
  25520. //}
  25521. //infocode = resThree.Infcode
  25522. //result, _ := json.Marshal(respJSON)
  25523. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25524. utils.ErrorLog("解析失败:%v", err)
  25525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25526. return
  25527. }
  25528. resThree.ErrMsg = resThree10265.ErrMsg
  25529. resThree.Output = resThree10265.Output
  25530. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25531. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25532. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25533. psn_info, _ := service.GetPsnByPatientId(id)
  25534. his.PsnNo = psn_info.PsnNo
  25535. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25536. var cert_no string
  25537. if id_card_type == 3 {
  25538. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25539. cert_no = IdCardNo
  25540. } else if id_card_type == 4 {
  25541. cert_no = IdCardNo
  25542. psn_info.VerifyNumber = psn_info.VerifyNumber
  25543. } else {
  25544. bas := strings.Split(psn_info.CardInfo, "|")
  25545. cert_no = bas[2]
  25546. }
  25547. var hisPrescription []*models.HisPrescription
  25548. fmt.Println(hisPrescription)
  25549. for _, item := range rf {
  25550. if item.Insutype == insutype {
  25551. //insuplc_admdvs = item.InsuplcAdmdvs
  25552. his.InsuplcAdmdvs = insuplc_admdvs
  25553. }
  25554. }
  25555. his.Insutype = insutype
  25556. var res3101 Result3101
  25557. res3101.Infcode = "0"
  25558. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25559. if res3101.Infcode == "0" {
  25560. fmt.Println("33333333")
  25561. if len(res3101.Output.Result) > 0 {
  25562. fmt.Println("222222")
  25563. for _, item := range res3101.Output.Result {
  25564. if len(res3101.ErrMsg) == 0 {
  25565. res3101.ErrMsg = item.VolaCont
  25566. } else {
  25567. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25568. }
  25569. }
  25570. c.ServeSuccessJSON(map[string]interface{}{
  25571. "failed_code": -10,
  25572. "msg": res3101.ErrMsg,
  25573. })
  25574. return
  25575. } else {
  25576. fmt.Println("11111")
  25577. var api string
  25578. if miConfig.MdtrtareaAdmvs == "320830" {
  25579. ipt_otp_no = timeFormat
  25580. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25581. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25582. "&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
  25583. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25584. ipt_otp_no = timeFormat
  25585. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25586. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25587. "&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
  25588. } else {
  25589. ipt_otp_no = timeFormat
  25590. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25591. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25592. "&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
  25593. }
  25594. resp, requestErr := http.Get(api)
  25595. if requestErr != nil {
  25596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25597. return
  25598. }
  25599. body, ioErr := ioutil.ReadAll(resp.Body)
  25600. if ioErr != nil {
  25601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25603. return
  25604. }
  25605. var respJSON map[string]interface{}
  25606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25609. return
  25610. }
  25611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25612. result, _ := json.Marshal(respJSON)
  25613. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25614. utils.ErrorLog("解析失败:%v", err)
  25615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25616. return
  25617. }
  25618. resThree.ErrMsg = resThree10265.ErrMsg
  25619. resThree.Output = resThree10265.Output
  25620. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25621. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25622. }
  25623. } else if res3101.Infcode != "0" {
  25624. c.ServeSuccessJSON(map[string]interface{}{
  25625. "failed_code": -10,
  25626. "msg": res3101.ErrMsg,
  25627. })
  25628. return
  25629. }
  25630. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25631. psn_info, _ := service.GetPsnByPatientId(id)
  25632. var cert_no string
  25633. if id_card_type == 1 {
  25634. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25635. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25636. } else if id_card_type == 4 {
  25637. cert_no = psn_info.VerifyNumber
  25638. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25639. } else {
  25640. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25641. cert_no = psn_info.VerifyNumber
  25642. }
  25643. 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)
  25644. saveLog(result, requestLog, "2201", "挂号")
  25645. if miConfig.Code == "H15049901371" {
  25646. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25647. utils.ErrorLog("解析失败:%v", err)
  25648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25649. return
  25650. }
  25651. resThree.ErrMsg = resThree10265.ErrMsg
  25652. resThree.Output = resThree10265.Output
  25653. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25654. } else {
  25655. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25656. utils.ErrorLog("解析失败:%v", err)
  25657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25658. return
  25659. }
  25660. }
  25661. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25662. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25663. psn_info, _ := service.GetPsnByPatientId(id)
  25664. var result string
  25665. var requestLog string
  25666. if id_card_type == 1 {
  25667. bas := strings.Split(psn_info.CardInfo, "|")
  25668. basNumber := bas[2]
  25669. card_sn := bas[3]
  25670. 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)
  25671. saveLog(result, requestLog, "2201A", "挂号")
  25672. } else if id_card_type == 2 {
  25673. 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, "", "", "", "", "", "")
  25674. saveLog(result, requestLog, "2201A", "挂号")
  25675. } else {
  25676. 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)
  25677. saveLog(result, requestLog, "2201A", "挂号")
  25678. }
  25679. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25680. utils.ErrorLog("解析失败:%v", err)
  25681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25682. return
  25683. }
  25684. infocode = resThree.Infcode
  25685. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25686. psn_info, _ := service.GetPsnByPatientId(id)
  25687. var result string
  25688. var requestLog string
  25689. if id_card_type == 1 {
  25690. bas := strings.Split(psn_info.CardInfo, "|")
  25691. basNumber := bas[2]
  25692. card_sn := ""
  25693. 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)
  25694. saveLog(result, requestLog, "2201A", "挂号")
  25695. } else if id_card_type == 2 {
  25696. 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, "", "", "", "", "", "")
  25697. saveLog(result, requestLog, "2201A", "挂号")
  25698. } else {
  25699. 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)
  25700. saveLog(result, requestLog, "2201A", "挂号")
  25701. }
  25702. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25703. utils.ErrorLog("解析失败:%v", err)
  25704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25705. return
  25706. }
  25707. infocode = resThree.Infcode
  25708. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25709. psn_info, _ := service.GetPsnByPatientId(id)
  25710. var result string
  25711. var requestLog string
  25712. if id_card_type == 1 {
  25713. bas := strings.Split(psn_info.CardInfo, "|")
  25714. basNumber := bas[2]
  25715. card_sn := ""
  25716. 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)
  25717. saveLog(result, requestLog, "2201A", "挂号")
  25718. } else if id_card_type == 2 {
  25719. 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, "", "", "", "", "", "")
  25720. saveLog(result, requestLog, "2201A", "挂号")
  25721. } else {
  25722. 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)
  25723. saveLog(result, requestLog, "2201A", "挂号")
  25724. }
  25725. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25726. utils.ErrorLog("解析失败:%v", err)
  25727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25728. return
  25729. }
  25730. infocode = resThree.Infcode
  25731. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25732. psn_info, _ := service.GetPsnByPatientId(id)
  25733. his.PsnNo = psn_info.PsnNo
  25734. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25735. var cert_no string
  25736. if id_card_type == 1 {
  25737. bas := strings.Split(psn_info.CardInfo, "|")
  25738. cert_no = bas[2]
  25739. } else if id_card_type == 4 {
  25740. cert_no = psn_info.VerifyNumber
  25741. psn_info.VerifyNumber = psn_info.VerifyNumber
  25742. IdCardNo = psn_info.VerifyNumber
  25743. } else {
  25744. cert_no = IdCardNo
  25745. psn_info.VerifyNumber = cert_no
  25746. }
  25747. for _, item := range rf {
  25748. if item.Insutype == insutype {
  25749. his.InsuplcAdmdvs = insuplc_admdvs
  25750. }
  25751. }
  25752. his.Insutype = insutype
  25753. var api string
  25754. ipt_otp_no = timeFormat
  25755. 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 +
  25756. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25757. "&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
  25758. resp, requestErr := http.Get(api)
  25759. if requestErr != nil {
  25760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25761. return
  25762. }
  25763. body, ioErr := ioutil.ReadAll(resp.Body)
  25764. if ioErr != nil {
  25765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25767. return
  25768. }
  25769. var respJSON map[string]interface{}
  25770. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25773. return
  25774. }
  25775. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25776. if status == "0" {
  25777. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25778. c.ServeSuccessJSON(map[string]interface{}{
  25779. "failed_code": -10,
  25780. "msg": err_msg,
  25781. })
  25782. return
  25783. }
  25784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25785. result, _ := json.Marshal(respJSON)
  25786. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25787. utils.ErrorLog("解析失败:%v", err)
  25788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25789. return
  25790. }
  25791. infocode = resThree.Infcode
  25792. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25793. psn_info, _ := service.GetPsnByPatientId(id)
  25794. his.PsnNo = psn_info.PsnNo
  25795. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25796. var cert_no string
  25797. if id_card_type == 1 {
  25798. bas := strings.Split(psn_info.CardInfo, "|")
  25799. cert_no = bas[2]
  25800. } else if id_card_type == 4 {
  25801. cert_no = psn_info.VerifyNumber
  25802. psn_info.VerifyNumber = psn_info.VerifyNumber
  25803. IdCardNo = psn_info.VerifyNumber
  25804. } else {
  25805. cert_no = IdCardNo
  25806. psn_info.VerifyNumber = cert_no
  25807. }
  25808. for _, item := range rf {
  25809. if item.Insutype == insutype {
  25810. his.InsuplcAdmdvs = insuplc_admdvs
  25811. patient.InsuplcAdmdvs = insuplc_admdvs
  25812. }
  25813. }
  25814. his.Insutype = insutype
  25815. var api string
  25816. ipt_otp_no = timeFormat
  25817. 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 +
  25818. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25819. "&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
  25820. resp, requestErr := http.Get(api)
  25821. if requestErr != nil {
  25822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25823. return
  25824. }
  25825. body, ioErr := ioutil.ReadAll(resp.Body)
  25826. if ioErr != nil {
  25827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25829. return
  25830. }
  25831. var respJSON map[string]interface{}
  25832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25835. return
  25836. }
  25837. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25838. if status == "0" {
  25839. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25840. c.ServeSuccessJSON(map[string]interface{}{
  25841. "failed_code": -10,
  25842. "msg": err_msg,
  25843. })
  25844. return
  25845. }
  25846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25847. result, _ := json.Marshal(respJSON)
  25848. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25849. utils.ErrorLog("解析失败:%v", err)
  25850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25851. return
  25852. }
  25853. infocode = resThree.Infcode
  25854. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25855. hour := time.Now().Format("15")
  25856. min := time.Now().Format("04")
  25857. sec := time.Now().Format("05")
  25858. begin := record_time + " " + hour + ":" + min + ":" + sec
  25859. psn_info, _ := service.GetPsnByPatientId(id)
  25860. var result string
  25861. var requestLog string
  25862. if id_card_type == 1 {
  25863. bas := strings.Split(psn_info.CardInfo, "|")
  25864. basNumber := bas[2]
  25865. card_sn := bas[3]
  25866. 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, begin)
  25867. saveLog(result, requestLog, "2201A", "挂号")
  25868. } else if id_card_type == 2 {
  25869. 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, "", "", begin)
  25870. saveLog(result, requestLog, "2201A", "挂号")
  25871. } else {
  25872. 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, "", "", begin)
  25873. saveLog(result, requestLog, "2201A", "挂号")
  25874. }
  25875. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25876. utils.ErrorLog("解析失败:%v", err)
  25877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25878. return
  25879. }
  25880. infocode = resThree.Infcode
  25881. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25882. psn_info, _ := service.GetPsnByPatientId(id)
  25883. 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)
  25884. saveLog(result, requestLog, "2201A", "挂号")
  25885. if miConfig.Code == "H15049901371" {
  25886. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25887. utils.ErrorLog("解析失败:%v", err)
  25888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25889. return
  25890. }
  25891. resThree.ErrMsg = resThree10265.ErrMsg
  25892. resThree.Output = resThree10265.Output
  25893. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25894. } else {
  25895. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25896. utils.ErrorLog("解析失败:%v", err)
  25897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25898. return
  25899. }
  25900. }
  25901. if miConfig.Code == "H15049901371" {
  25902. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25903. } else {
  25904. infocode = resThree.Infcode
  25905. }
  25906. } else {
  25907. psn_info, _ := service.GetPsnByPatientId(id)
  25908. if id_card_type == 4 || id_card_type == 1 {
  25909. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25910. }
  25911. var rf []*ResultFive
  25912. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25913. var insutypes []*ResultFive
  25914. var insutype string
  25915. var is390 int = 0
  25916. var is310 int = 0
  25917. for _, item := range rf {
  25918. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25919. insutypes = append(insutypes, item)
  25920. }
  25921. }
  25922. if len(insutypes) == 1 {
  25923. insutype = insutypes[0].Insutype
  25924. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25925. } else {
  25926. for _, i := range insutypes {
  25927. if i.Insutype == "390" {
  25928. is390 = 1
  25929. }
  25930. if i.Insutype == "310" {
  25931. is310 = 1
  25932. }
  25933. }
  25934. }
  25935. if is390 == 1 {
  25936. insutype = "390"
  25937. }
  25938. if is310 == 1 {
  25939. insutype = "310"
  25940. }
  25941. fmt.Println(len(insutypes))
  25942. if len(insutypes) == 0 {
  25943. for index, item := range rf {
  25944. if index == 0 {
  25945. insutype = item.Insutype
  25946. insuplc_admdvs = item.InsuplcAdmdvs
  25947. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25948. }
  25949. }
  25950. fmt.Println(insutype)
  25951. fmt.Println(insuplc_admdvs)
  25952. }
  25953. if social_type > 0 {
  25954. insutype = strconv.FormatInt(social_type, 10)
  25955. }
  25956. fmt.Println("--------")
  25957. fmt.Println(psn_info)
  25958. fmt.Println(psn_info.PsnNo)
  25959. for _, item := range rf {
  25960. if item.Insutype == insutype {
  25961. insutype = item.Insutype
  25962. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25963. }
  25964. }
  25965. if miConfig.MdtrtareaAdmvs == "441202" {
  25966. var hisPrescription []*models.HisPrescription
  25967. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25968. if res3101.Infcode == 0 {
  25969. fmt.Println("33333333")
  25970. if len(res3101.Output.Result) > 0 {
  25971. fmt.Println("222222")
  25972. for _, item := range res3101.Output.Result {
  25973. if len(res3101.ErrMsg) == 0 {
  25974. res3101.ErrMsg = item.VolaCont
  25975. } else {
  25976. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25977. }
  25978. }
  25979. c.ServeSuccessJSON(map[string]interface{}{
  25980. "failed_code": -10,
  25981. "msg": res3101.ErrMsg,
  25982. })
  25983. return
  25984. } else {
  25985. hour := time.Now().Format("15")
  25986. min := time.Now().Format("04")
  25987. sec := time.Now().Format("05")
  25988. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25989. fmt.Println(record_time_two)
  25990. 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)
  25991. saveLog(result, requestLog, "2201A", "挂号")
  25992. if miConfig.Code == "H15049901371" {
  25993. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25994. utils.ErrorLog("解析失败:%v", err)
  25995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25996. return
  25997. }
  25998. resThree.ErrMsg = resThree10265.ErrMsg
  25999. resThree.Output = resThree10265.Output
  26000. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26001. } else {
  26002. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26003. utils.ErrorLog("解析失败:%v", err)
  26004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26005. return
  26006. }
  26007. }
  26008. if miConfig.Code == "H15049901371" {
  26009. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26010. } else {
  26011. infocode = resThree.Infcode
  26012. }
  26013. }
  26014. } else if res3101.Infcode != 0 {
  26015. c.ServeSuccessJSON(map[string]interface{}{
  26016. "failed_code": -10,
  26017. "msg": res3101.ErrMsg,
  26018. })
  26019. return
  26020. }
  26021. } else if miConfig.MdtrtareaAdmvs == "440205" {
  26022. var hisPrescription []*models.HisPrescription
  26023. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  26024. if res3101.Infcode == 0 {
  26025. fmt.Println("33333333")
  26026. if len(res3101.Output.Result) > 0 {
  26027. fmt.Println("222222")
  26028. for _, item := range res3101.Output.Result {
  26029. if len(res3101.ErrMsg) == 0 {
  26030. res3101.ErrMsg = item.VolaCont
  26031. } else {
  26032. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  26033. }
  26034. }
  26035. c.ServeSuccessJSON(map[string]interface{}{
  26036. "failed_code": -10,
  26037. "msg": res3101.ErrMsg,
  26038. })
  26039. return
  26040. } else {
  26041. hour := time.Now().Format("15")
  26042. min := time.Now().Format("04")
  26043. sec := time.Now().Format("05")
  26044. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26045. fmt.Println(record_time_two)
  26046. 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)
  26047. saveLog(result, requestLog, "2201A", "挂号")
  26048. if miConfig.Code == "H15049901371" {
  26049. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26050. utils.ErrorLog("解析失败:%v", err)
  26051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26052. return
  26053. }
  26054. resThree.ErrMsg = resThree10265.ErrMsg
  26055. resThree.Output = resThree10265.Output
  26056. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26057. } else {
  26058. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26059. utils.ErrorLog("解析失败:%v", err)
  26060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26061. return
  26062. }
  26063. }
  26064. if miConfig.Code == "H15049901371" {
  26065. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26066. } else {
  26067. infocode = resThree.Infcode
  26068. }
  26069. }
  26070. } else if res3101.Infcode != 0 {
  26071. c.ServeSuccessJSON(map[string]interface{}{
  26072. "failed_code": -10,
  26073. "msg": res3101.ErrMsg,
  26074. })
  26075. return
  26076. }
  26077. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26078. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  26079. psn_info, _ := service.GetPsnByPatientId(id)
  26080. var verify_number string
  26081. if id_card_type == 4 {
  26082. verify_number = psn_info.VerifyNumber
  26083. } else if id_card_type == 1 {
  26084. bas := strings.Split(psn_info.CardInfo, "|")
  26085. cardNumber := bas[2]
  26086. verify_number = cardNumber
  26087. } else {
  26088. verify_number = psn_info.Certno
  26089. }
  26090. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  26091. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  26092. "&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
  26093. resp, requestErr := http.Get(api)
  26094. if requestErr != nil {
  26095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26096. return
  26097. }
  26098. body, ioErr := ioutil.ReadAll(resp.Body)
  26099. if ioErr != nil {
  26100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26102. return
  26103. }
  26104. var respJSON map[string]interface{}
  26105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26108. return
  26109. }
  26110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26111. result, _ := json.Marshal(respJSON)
  26112. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26113. utils.ErrorLog("解析失败:%v", err)
  26114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26115. return
  26116. }
  26117. infocode = resThree.Infcode
  26118. } else {
  26119. hour := time.Now().Format("15")
  26120. min := time.Now().Format("04")
  26121. sec := time.Now().Format("05")
  26122. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26123. if id_card_type == 1 {
  26124. for _, item := range rf {
  26125. if item.Insutype == strconv.FormatInt(social_type, 10) {
  26126. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  26127. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26128. } else if strconv.FormatInt(social_type, 10) == "390" {
  26129. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26130. } else {
  26131. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26132. }
  26133. }
  26134. }
  26135. }
  26136. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  26137. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26138. }
  26139. if id_card_type == 1 {
  26140. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  26141. bas := strings.Split(psn_info.CardInfo, "|")
  26142. basNumber := bas[1]
  26143. IdCardNo = basNumber
  26144. }
  26145. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  26146. IdCardNo = psn_info.VerifyNumber
  26147. }
  26148. if len(insuplc_admdvs_temp) == 0 {
  26149. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26150. }
  26151. var result string
  26152. var requestLog string
  26153. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  26154. var hisPrescription []*models.HisPrescription
  26155. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  26156. if res3101.Infcode == 0 {
  26157. if len(res3101.Output.Result) > 0 {
  26158. if len(res3101.Output.Result) > 0 {
  26159. c.ServeSuccessJSON(map[string]interface{}{
  26160. "failed_code": -10,
  26161. "failed_type": 100,
  26162. "warm_type": 1,
  26163. "msg": res3101,
  26164. })
  26165. return
  26166. } else {
  26167. c.ServeSuccessJSON(map[string]interface{}{
  26168. "failed_code": -10,
  26169. "msg": res3101.ErrMsg,
  26170. })
  26171. return
  26172. }
  26173. } else {
  26174. hour := time.Now().Format("15")
  26175. min := time.Now().Format("04")
  26176. sec := time.Now().Format("05")
  26177. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26178. fmt.Println(record_time_two)
  26179. if his.IdCardType == 2 {
  26180. IdCardNo = psn_info.Certno
  26181. psn_info.VerifyNumber = psn_info.Certno
  26182. } else if his.IdCardType == 4 {
  26183. IdCardNo = psn_info.Certno
  26184. } else {
  26185. bas := strings.Split(psn_info.CardInfo, "|")
  26186. IdCardNo = bas[2]
  26187. }
  26188. aaaa = insutype
  26189. 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)
  26190. saveLog(result, requestLog, "2201A", "挂号")
  26191. if miConfig.Code == "H15049901371" {
  26192. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26193. utils.ErrorLog("解析失败:%v", err)
  26194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26195. return
  26196. }
  26197. resThree.ErrMsg = resThree10265.ErrMsg
  26198. resThree.Output = resThree10265.Output
  26199. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26200. } else {
  26201. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26202. utils.ErrorLog("解析失败:%v", err)
  26203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26204. return
  26205. }
  26206. }
  26207. if miConfig.Code == "H15049901371" {
  26208. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26209. } else {
  26210. infocode = resThree.Infcode
  26211. }
  26212. }
  26213. } else if res3101.Infcode != 0 {
  26214. c.ServeSuccessJSON(map[string]interface{}{
  26215. "failed_code": -10,
  26216. "msg": res3101.ErrMsg,
  26217. })
  26218. return
  26219. }
  26220. } else {
  26221. psn_info, _ := service.GetPsnByPatientId(id)
  26222. var rf []*ResultFive
  26223. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  26224. //var insutypes []*ResultFive
  26225. var insutype string
  26226. var insutypes []*ResultFive
  26227. var is390 int = 0
  26228. var is310 int = 0
  26229. for _, item := range rf {
  26230. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26231. insutypes = append(insutypes, item)
  26232. }
  26233. }
  26234. if len(insutypes) == 1 {
  26235. insutype = insutypes[0].Insutype
  26236. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26237. } else {
  26238. for _, i := range insutypes {
  26239. if i.Insutype == "390" {
  26240. is390 = 1
  26241. }
  26242. if i.Insutype == "310" {
  26243. is310 = 1
  26244. }
  26245. }
  26246. }
  26247. if is390 == 1 {
  26248. insutype = "390"
  26249. }
  26250. if is310 == 1 {
  26251. insutype = "310"
  26252. }
  26253. if len(insutypes) == 0 {
  26254. insutype = "310"
  26255. }
  26256. if social_type > 0 {
  26257. insutype = strconv.FormatInt(social_type, 10)
  26258. }
  26259. for _, item := range rf {
  26260. if item.Insutype == insutype {
  26261. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26262. }
  26263. }
  26264. if len(insuplc_admdvs_tt) > 0 {
  26265. insuplc_admdvs_temp = insuplc_admdvs_tt
  26266. }
  26267. 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)
  26268. saveLog(result, requestLog, "2201A", "挂号")
  26269. }
  26270. if miConfig.Code == "H15049901371" {
  26271. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26272. utils.ErrorLog("解析失败:%v", err)
  26273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26274. return
  26275. }
  26276. resThree.ErrMsg = resThree10265.ErrMsg
  26277. resThree.Output = resThree10265.Output
  26278. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26279. } else {
  26280. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26281. utils.ErrorLog("解析失败:%v", err)
  26282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26283. return
  26284. }
  26285. }
  26286. if miConfig.Code == "H15049901371" {
  26287. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26288. } else {
  26289. infocode = resThree.Infcode
  26290. }
  26291. }
  26292. }
  26293. if infocode == -1 {
  26294. adminUser := c.GetAdminUserInfo()
  26295. errlog := &models.HisOrderError{
  26296. UserOrgId: adminUser.CurrentOrgId,
  26297. Ctime: time.Now().Unix(),
  26298. Mtime: time.Now().Unix(),
  26299. ErrMsg: resThree.ErrMsg,
  26300. Status: 1,
  26301. PatientId: id,
  26302. RecordTime: recordDateTime,
  26303. Stage: 2,
  26304. }
  26305. service.CreateErrMsgLog(errlog)
  26306. c.ServeSuccessJSON(map[string]interface{}{
  26307. "failed_code": -10,
  26308. "msg": resThree.ErrMsg,
  26309. })
  26310. return
  26311. }
  26312. utils.ErrorLog("解析失败:%v", insutype)
  26313. his.Number = resThree.Output.Data.MdtrtID
  26314. his.PsnNo = resThree.Output.Data.PsnNo
  26315. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26316. his.IdCardNo = patient.IdCardNo
  26317. his.PhoneNumber = patient.Phone
  26318. his.UserOrgId = adminInfo.CurrentOrgId
  26319. his.Insutype = insutype
  26320. if miConfig.Code == "H44030500255" {
  26321. his.Insutype = aaaa
  26322. }
  26323. his.Ctime = time.Now().Unix()
  26324. his.Mtime = time.Now().Unix()
  26325. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26326. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26327. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26328. }
  26329. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26330. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26331. }
  26332. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26333. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26334. }
  26335. his.Status = 1
  26336. his.MdtrtGrpType = mdtrt_type
  26337. service.UpdateHisPatientStatus(&his)
  26338. service.UpdateHisPatient123(&patient)
  26339. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26340. c.ServeSuccessJSON(map[string]interface{}{
  26341. "his_info": his,
  26342. })
  26343. } else {
  26344. adminUser := c.GetAdminUserInfo()
  26345. errlog := &models.HisOrderError{
  26346. UserOrgId: adminUser.CurrentOrgId,
  26347. Ctime: time.Now().Unix(),
  26348. Mtime: time.Now().Unix(),
  26349. ErrMsg: res.ErrMsg,
  26350. Status: 1,
  26351. PatientId: id,
  26352. RecordTime: recordDateTime,
  26353. Stage: 1,
  26354. }
  26355. service.CreateErrMsgLog(errlog)
  26356. c.ServeSuccessJSON(map[string]interface{}{
  26357. "failed_code": -10,
  26358. "msg": res.ErrMsg,
  26359. })
  26360. return
  26361. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26362. }
  26363. }
  26364. }
  26365. func (c *HisApiController) GetUploadInfo() {
  26366. id, _ := c.GetInt64("id")
  26367. record_time := c.GetString("record_time")
  26368. his_patient_id, _ := c.GetInt64("his_patient_id")
  26369. order_id, _ := c.GetInt64("order_id")
  26370. pay_way, _ := c.GetInt64("pay_way")
  26371. pay_ways := c.GetString("pay_ways")
  26372. oth_desc := c.GetString("oth_desc")
  26373. pack_num, _ := c.GetInt64("pack_num")
  26374. good_pack_num, _ := c.GetInt64("good_pack_num")
  26375. pay_price, _ := c.GetFloat("pay_price")
  26376. pay_card_no := c.GetString("pay_card_no")
  26377. discount_price, _ := c.GetFloat("discount_price")
  26378. preferential_price, _ := c.GetFloat("preferential_price")
  26379. reality_price, _ := c.GetFloat("reality_price")
  26380. found_price, _ := c.GetFloat("found_price")
  26381. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26382. private_price, _ := c.GetFloat("private_price")
  26383. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26384. admin_user_id, _ := c.GetInt64("admin_user_id")
  26385. fapiao_code := c.GetString("fapiao_code")
  26386. fapiao_number := c.GetString("fapiao_number")
  26387. diagnosis_id := c.GetString("diagnosis")
  26388. sick_type, _ := c.GetInt64("sick_type")
  26389. reg_type, _ := c.GetInt64("p_type")
  26390. begin_time := c.GetString("begin_time")
  26391. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26392. cash_pay := c.GetString("cash_pay")
  26393. band_card_pay := c.GetString("band_card_pay")
  26394. wechat_pay := c.GetString("wechat_pay")
  26395. ali_pay := c.GetString("ali_pay")
  26396. jifen_pay := c.GetString("jifen_pay")
  26397. //jifen_pay := c.GetString("jifen_pay")
  26398. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26399. fmt.Println(acct_used_flag)
  26400. id_str := c.GetString("ids")
  26401. ids_arr := strings.Split(id_str, ",")
  26402. timeLayout := "2006-01-02"
  26403. loc, _ := time.LoadLocation("Local")
  26404. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26405. if err != nil {
  26406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26407. return
  26408. }
  26409. recordDateTime := theTime.Unix()
  26410. adminUser := c.GetAdminUserInfo()
  26411. var tempOrder models.HisOrder
  26412. tempOrder, _ = service.GetHisOrderByID(order_id)
  26413. var prescriptions []*models.HisPrescription
  26414. var start_time int64
  26415. var end_time int64
  26416. //押金模块
  26417. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26418. tmp_decimal := c.GetString("tmp_decimal")
  26419. var decimal float64 //本次使用的押金
  26420. var errmsg error
  26421. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26422. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26423. return
  26424. }
  26425. if len(tmp_decimal) > 0 {
  26426. if tmp_decimal[0] == 45 {
  26427. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26428. return
  26429. }
  26430. }
  26431. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26432. fmt.Println(errs)
  26433. decimal = tt
  26434. //if adminUser.CurrentOrgId == 10106{
  26435. // if len(fapiao_code) == 0{
  26436. // fapiao_code = "144072080589"
  26437. // }
  26438. // if len(fapiao_number) == 0{
  26439. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26440. // if order.ID == 0{
  26441. // fapiao_number = "00001520"
  26442. // }else{
  26443. // //fapiao_code = "00001520"
  26444. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26445. // var zero string
  26446. // if fpNumber >= 1000{
  26447. // zero = "0000" + strconv.Itoa(fpNumber)
  26448. // }else if fpNumber >= 10000{
  26449. // zero = "000" + strconv.Itoa(fpNumber)
  26450. // } else if fpNumber >= 100000{
  26451. // zero = "00" + strconv.Itoa(fpNumber)
  26452. // } else if fpNumber >= 1000000{
  26453. // zero = "0" + strconv.Itoa(fpNumber)
  26454. // }else {
  26455. // zero = strconv.Itoa(fpNumber)
  26456. // }
  26457. // fapiao_number = zero
  26458. // }
  26459. // }
  26460. //}
  26461. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26462. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26463. var patientPrescription models.HisPrescriptionInfo
  26464. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26465. if patientPrescription.ID == 0 {
  26466. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26467. }
  26468. //if patientPrescription.Do
  26469. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26470. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26471. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26472. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26473. var config []*models.HisXtDiagnoseConfig
  26474. for _, item := range diagnosis_ids {
  26475. id, _ := strconv.ParseInt(item, 10, 64)
  26476. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26477. config = append(config, &diagnosisConfig)
  26478. }
  26479. sickConfig, _ := service.FindSickById(sick_type)
  26480. //if tempOrder.ID == 0 {
  26481. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26482. //}
  26483. if tempOrder.ID == 0 {
  26484. var result string
  26485. var requestLog string
  26486. var res2 ResultSix
  26487. var res3 GZResultSix
  26488. var ressix10265 ResultSix10265
  26489. if miConfig.MdtrtareaAdmvs == "421300" {
  26490. data := make(map[string]interface{})
  26491. client := &http.Client{}
  26492. data["psn_no"] = his.PsnNo
  26493. data["mdtrt_id"] = his.Number
  26494. data["opter"] = roles.UserName
  26495. data["org_name"] = miConfig.OrgName
  26496. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26497. data["doctor_id"] = doctor_info.DoctorNumber
  26498. data["doctor_name"] = doctor_info.UserName
  26499. data["department"] = department.Name
  26500. data["fixmedins_code"] = miConfig.Code
  26501. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26502. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26503. data["secret_key"] = miConfig.SecretKey
  26504. data["sick_code"] = sickConfig.CountryCode
  26505. data["sick_name"] = sickConfig.ClassName
  26506. data["dept"] = strconv.FormatInt(department.ID, 10)
  26507. data["config"] = config
  26508. data["begin_time"] = begin_time
  26509. bytesData, _ := json.Marshal(data)
  26510. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26511. resp, _ := client.Do(req)
  26512. defer resp.Body.Close()
  26513. body, ioErr := ioutil.ReadAll(resp.Body)
  26514. if ioErr != nil {
  26515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26517. return
  26518. }
  26519. var respJSON map[string]interface{}
  26520. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26523. return
  26524. }
  26525. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26526. userJSONBytes, _ := json.Marshal(respJSON)
  26527. fmt.Println("log")
  26528. fmt.Println(string(userJSONBytes))
  26529. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26530. utils.ErrorLog("解析失败:%v", err)
  26531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26532. return
  26533. }
  26534. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26535. data := make(map[string]interface{})
  26536. client := &http.Client{}
  26537. data["psn_no"] = his.PsnNo
  26538. data["mdtrt_id"] = his.Number
  26539. data["opter"] = roles.UserName
  26540. data["org_name"] = miConfig.OrgName
  26541. if reg_type == 11 && his.Insutype == "390" {
  26542. data["med_type"] = "110104"
  26543. } else {
  26544. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26545. }
  26546. data["doctor_id"] = doctor_info.DoctorNumber
  26547. data["doctor_name"] = doctor_info.UserName
  26548. data["department"] = department.Name
  26549. data["fixmedins_code"] = miConfig.Code
  26550. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26551. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26552. data["secret_key"] = miConfig.SecretKey
  26553. data["sick_code"] = sickConfig.CountryCode
  26554. data["sick_name"] = sickConfig.ClassName
  26555. data["dept"] = strconv.FormatInt(department.ID, 10)
  26556. data["config"] = config
  26557. data["begin_time"] = begin_time
  26558. bytesData, _ := json.Marshal(data)
  26559. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26560. resp, _ := client.Do(req)
  26561. defer resp.Body.Close()
  26562. body, ioErr := ioutil.ReadAll(resp.Body)
  26563. if ioErr != nil {
  26564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26566. return
  26567. }
  26568. var respJSON map[string]interface{}
  26569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26572. return
  26573. }
  26574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26575. userJSONBytes, _ := json.Marshal(respJSON)
  26576. fmt.Println("log")
  26577. fmt.Println(string(userJSONBytes))
  26578. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26579. utils.ErrorLog("解析失败:%v", err)
  26580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26581. return
  26582. }
  26583. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26584. data := make(map[string]interface{})
  26585. client := &http.Client{}
  26586. data["psn_no"] = his.PsnNo
  26587. data["mdtrt_id"] = his.Number
  26588. data["opter"] = roles.UserName
  26589. data["org_name"] = miConfig.OrgName
  26590. if reg_type == 11 && his.Insutype == "390" {
  26591. data["med_type"] = "110104"
  26592. } else {
  26593. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26594. }
  26595. data["doctor_id"] = doctor_info.DoctorNumber
  26596. data["doctor_name"] = doctor_info.UserName
  26597. data["department"] = department.Name
  26598. data["fixmedins_code"] = miConfig.Code
  26599. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26600. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26601. data["secret_key"] = miConfig.SecretKey
  26602. data["sick_code"] = sickConfig.CountryCode
  26603. data["sick_name"] = sickConfig.ClassName
  26604. data["dept"] = strconv.FormatInt(department.ID, 10)
  26605. data["config"] = config
  26606. data["begin_time"] = begin_time
  26607. bytesData, _ := json.Marshal(data)
  26608. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26609. resp, _ := client.Do(req)
  26610. defer resp.Body.Close()
  26611. body, ioErr := ioutil.ReadAll(resp.Body)
  26612. if ioErr != nil {
  26613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26615. return
  26616. }
  26617. var respJSON map[string]interface{}
  26618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26621. return
  26622. }
  26623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26624. userJSONBytes, _ := json.Marshal(respJSON)
  26625. fmt.Println("log")
  26626. fmt.Println(string(userJSONBytes))
  26627. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26628. utils.ErrorLog("解析失败:%v", err)
  26629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26630. return
  26631. }
  26632. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26633. data := make(map[string]interface{})
  26634. client := &http.Client{}
  26635. data["psn_no"] = his.PsnNo
  26636. data["mdtrt_id"] = his.Number
  26637. data["opter"] = roles.UserName
  26638. data["org_name"] = miConfig.OrgName
  26639. if reg_type == 11 && his.Insutype == "390" {
  26640. data["med_type"] = "110104"
  26641. } else {
  26642. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26643. }
  26644. data["doctor_id"] = doctor_info.DoctorNumber
  26645. data["doctor_name"] = doctor_info.UserName
  26646. data["department"] = department.Name
  26647. data["fixmedins_code"] = miConfig.Code
  26648. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26649. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26650. data["secret_key"] = miConfig.SecretKey
  26651. data["sick_code"] = sickConfig.CountryCode
  26652. data["sick_name"] = sickConfig.ClassName
  26653. data["dept"] = strconv.FormatInt(department.ID, 10)
  26654. data["config"] = config
  26655. data["begin_time"] = begin_time
  26656. bytesData, _ := json.Marshal(data)
  26657. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26658. resp, _ := client.Do(req)
  26659. defer resp.Body.Close()
  26660. body, ioErr := ioutil.ReadAll(resp.Body)
  26661. if ioErr != nil {
  26662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26664. return
  26665. }
  26666. var respJSON map[string]interface{}
  26667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26670. return
  26671. }
  26672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26673. userJSONBytes, _ := json.Marshal(respJSON)
  26674. fmt.Println("log")
  26675. fmt.Println(string(userJSONBytes))
  26676. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26677. utils.ErrorLog("解析失败:%v", err)
  26678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26679. return
  26680. }
  26681. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26682. utils.ErrorLog("解析失败:%v", doctor_info)
  26683. data := make(map[string]interface{})
  26684. client := &http.Client{}
  26685. data["psn_no"] = his.PsnNo
  26686. data["mdtrt_id"] = his.Number
  26687. data["doctor"] = roles.UserName
  26688. data["department"] = department.Name
  26689. data["org_name"] = miConfig.OrgName
  26690. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26691. data["doctor_id"] = doctor_info.DoctorNumber
  26692. data["new_doctor_name"] = doctor_info.UserName
  26693. data["fixmedins_code"] = miConfig.Code
  26694. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26695. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26696. data["secret_key"] = miConfig.SecretKey
  26697. data["sick_code"] = sickConfig.CountryCode
  26698. data["sick_name"] = sickConfig.ClassName
  26699. data["url"] = miConfig.Url
  26700. data["ak"] = miConfig.AccessKey
  26701. data["begin_time"] = begin_time
  26702. data["cainfo"] = miConfig.Cainfo
  26703. data["dept"] = strconv.FormatInt(department.ID, 10)
  26704. data["config"] = config
  26705. bytesData, _ := json.Marshal(data)
  26706. var req *http.Request
  26707. if miConfig.MdtrtareaAdmvs == "320830" {
  26708. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26709. //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 +
  26710. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26711. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26712. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26713. //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 +
  26714. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26715. } else {
  26716. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26717. }
  26718. resp, _ := client.Do(req)
  26719. defer resp.Body.Close()
  26720. body, ioErr := ioutil.ReadAll(resp.Body)
  26721. if ioErr != nil {
  26722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26724. return
  26725. }
  26726. var respJSON map[string]interface{}
  26727. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26730. return
  26731. }
  26732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26733. userJSONBytes, _ := json.Marshal(respJSON)
  26734. fmt.Println("log")
  26735. fmt.Println(string(userJSONBytes))
  26736. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26737. utils.ErrorLog("解析失败:%v", err)
  26738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26739. return
  26740. }
  26741. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26742. res2.Output = ressix10265.Output
  26743. res2.ErrMsg = ressix10265.ErrMsg
  26744. res2.Cainfo = ressix10265.Cainfo
  26745. res2.WarnMsg = ressix10265.WarnMsg
  26746. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26747. res2.Infcode = infocode
  26748. } else if miConfig.MdtrtareaAdmvs == "150404" {
  26749. data := make(map[string]interface{})
  26750. client := &http.Client{}
  26751. data["psn_no"] = his.PsnNo
  26752. data["mdtrt_id"] = his.Number
  26753. data["doctor"] = roles.UserName
  26754. data["department"] = department.Name
  26755. data["org_name"] = miConfig.OrgName
  26756. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26757. data["doctor_id"] = doctor_info.DoctorNumber
  26758. data["new_doctor_name"] = doctor_info.UserName
  26759. data["fixmedins_code"] = miConfig.Code
  26760. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26761. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26762. data["secret_key"] = miConfig.SecretKey
  26763. data["sick_code"] = sickConfig.CountryCode
  26764. data["sick_name"] = sickConfig.ClassName
  26765. data["url"] = miConfig.Url
  26766. data["ak"] = miConfig.AccessKey
  26767. data["begin_time"] = begin_time
  26768. data["cainfo"] = miConfig.Cainfo
  26769. data["dept"] = strconv.FormatInt(department.ID, 10)
  26770. data["config"] = config
  26771. bytesData, _ := json.Marshal(data)
  26772. var req *http.Request
  26773. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26774. resp, _ := client.Do(req)
  26775. defer resp.Body.Close()
  26776. body, ioErr := ioutil.ReadAll(resp.Body)
  26777. if ioErr != nil {
  26778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26780. return
  26781. }
  26782. var respJSON map[string]interface{}
  26783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26786. return
  26787. }
  26788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26789. userJSONBytes, _ := json.Marshal(respJSON)
  26790. fmt.Println("log")
  26791. fmt.Println(string(userJSONBytes))
  26792. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26793. utils.ErrorLog("解析失败:%v", err)
  26794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26795. return
  26796. }
  26797. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26798. res2.Output = ressix10265.Output
  26799. res2.ErrMsg = ressix10265.ErrMsg
  26800. res2.Cainfo = ressix10265.Cainfo
  26801. res2.WarnMsg = ressix10265.WarnMsg
  26802. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26803. res2.Infcode = infocode
  26804. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26805. 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)
  26806. saveLog(result, requestLog, "2203", "上传就诊信息")
  26807. var respJSON2 map[string]interface{}
  26808. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26811. return
  26812. }
  26813. userJSONBytes2, _ := json.Marshal(respJSON2)
  26814. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26815. utils.ErrorLog("解析失败:%v", err)
  26816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26817. return
  26818. }
  26819. 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)
  26820. fmt.Println(result2)
  26821. fmt.Println(src_request)
  26822. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26823. data := make(map[string]interface{})
  26824. client := &http.Client{}
  26825. data["psn_no"] = his.PsnNo
  26826. data["mdtrt_id"] = his.Number
  26827. data["doctor"] = roles.UserName
  26828. data["department"] = department.Name
  26829. data["org_name"] = miConfig.OrgName
  26830. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26831. data["doctor_id"] = doctor_info.DoctorNumber
  26832. data["new_doctor_name"] = doctor_info.UserName
  26833. data["fixmedins_code"] = miConfig.Code
  26834. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26835. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26836. data["secret_key"] = miConfig.SecretKey
  26837. data["sick_code"] = sickConfig.CountryCode
  26838. data["sick_name"] = sickConfig.ClassName
  26839. data["url"] = miConfig.Url
  26840. data["ak"] = miConfig.AccessKey
  26841. data["begin_time"] = begin_time
  26842. data["cainfo"] = miConfig.Cainfo
  26843. data["dept"] = strconv.FormatInt(department.ID, 10)
  26844. data["config"] = config
  26845. bytesData, _ := json.Marshal(data)
  26846. var req *http.Request
  26847. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26848. resp, _ := client.Do(req)
  26849. defer resp.Body.Close()
  26850. body, ioErr := ioutil.ReadAll(resp.Body)
  26851. if ioErr != nil {
  26852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26854. return
  26855. }
  26856. var respJSON map[string]interface{}
  26857. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26860. return
  26861. }
  26862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26863. userJSONBytes, _ := json.Marshal(respJSON)
  26864. fmt.Println("log")
  26865. fmt.Println(string(userJSONBytes))
  26866. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26867. utils.ErrorLog("解析失败:%v", err)
  26868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26869. return
  26870. }
  26871. } else {
  26872. if miConfig.MdtrtareaAdmvs == "440781" { //
  26873. 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)
  26874. } else {
  26875. if miConfig.Code == "H15049901371" {
  26876. //赤峰地区国家医保医疗类别
  26877. //职工透析:医疗类别选特殊情况门诊990502
  26878. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26879. var med_type string
  26880. if his.Insutype == "390" {
  26881. if reg_type == 14 {
  26882. med_type = "9933"
  26883. } else if reg_type == 11 {
  26884. med_type = "11"
  26885. }
  26886. } else if his.Insutype == "310" {
  26887. if reg_type == 14 {
  26888. med_type = "990502"
  26889. } else if reg_type == 11 {
  26890. med_type = "11"
  26891. }
  26892. }
  26893. 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)
  26894. } else {
  26895. 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)
  26896. }
  26897. }
  26898. saveLog(result, requestLog, "2203", "上传就诊信息")
  26899. var respJSON2 map[string]interface{}
  26900. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26903. return
  26904. }
  26905. userJSONBytes2, _ := json.Marshal(respJSON2)
  26906. if miConfig.Code == "H15049901371" {
  26907. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26908. utils.ErrorLog("解析失败:%v", err)
  26909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26910. return
  26911. }
  26912. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26913. res2.Output = ressix10265.Output
  26914. res2.ErrMsg = ressix10265.ErrMsg
  26915. res2.Cainfo = ressix10265.Cainfo
  26916. res2.WarnMsg = ressix10265.WarnMsg
  26917. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26918. res2.Infcode = infocode
  26919. } else {
  26920. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26921. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26922. utils.ErrorLog("解析失败:%v", err)
  26923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26924. return
  26925. }
  26926. res2.Infcode = res3.Infcode
  26927. } else {
  26928. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26929. utils.ErrorLog("解析失败:%v", err)
  26930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26931. return
  26932. }
  26933. }
  26934. }
  26935. }
  26936. if res2.Infcode == -1 {
  26937. adminUser := c.GetAdminUserInfo()
  26938. errlog := &models.HisOrderError{
  26939. UserOrgId: adminUser.CurrentOrgId,
  26940. Ctime: time.Now().Unix(),
  26941. Mtime: time.Now().Unix(),
  26942. ErrMsg: res2.ErrMsg,
  26943. Status: 1,
  26944. PatientId: id,
  26945. RecordTime: recordDateTime,
  26946. Stage: 3,
  26947. }
  26948. service.CreateErrMsgLog(errlog)
  26949. c.ServeSuccessJSON(map[string]interface{}{
  26950. "failed_code": -10,
  26951. "msg": res2.ErrMsg,
  26952. })
  26953. return
  26954. } else {
  26955. his.Diagnosis = diagnosis_id
  26956. his.SickType = sickConfig.ID
  26957. //var p_type int64
  26958. //if reg_type == 1111 || reg_type == 1112 {
  26959. // p_type = 11
  26960. //
  26961. //}
  26962. his.PType = fmt.Sprintf("%d", reg_type)
  26963. service.UpdateHisPatientThree(&his)
  26964. data := make(map[string]interface{})
  26965. if settle_accounts_type == 1 { //日结
  26966. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26967. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26968. } else {
  26969. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26970. }
  26971. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26972. data["pre"] = prescriptions
  26973. } else { //月结
  26974. start_time_str := c.GetString("start_time")
  26975. end_time_str := c.GetString("end_time")
  26976. timeLayout := "2006-01-02"
  26977. loc, _ := time.LoadLocation("Local")
  26978. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26979. if err != nil {
  26980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26981. return
  26982. }
  26983. recordStartTime := theStartTime.Unix()
  26984. start_time = recordStartTime
  26985. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26986. if err != nil {
  26987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26988. return
  26989. }
  26990. recordEndTime := theEndTime.Unix()
  26991. end_time = recordEndTime
  26992. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26993. data["pre"] = prescriptions
  26994. }
  26995. timestamp := time.Now().Unix()
  26996. tempTime := time.Unix(timestamp, 0)
  26997. timeFormat := tempTime.Format("20060102150405")
  26998. chrgBchno := rand.Intn(100000) + 10000
  26999. new_chrg_bchno := ""
  27000. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  27001. new_chrg_bchno = chrg_bchno
  27002. strconv.FormatInt(his.PatientId, 10)
  27003. client := &http.Client{}
  27004. if adminUser.CurrentOrgId == 10265 {
  27005. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27006. new_chrg_bchno = "0000"
  27007. }
  27008. }
  27009. data["psn_no"] = his.PsnNo
  27010. data["mdtrt_id"] = his.Number
  27011. data["chrg_bchno"] = new_chrg_bchno
  27012. data["org_name"] = miConfig.OrgName
  27013. data["doctor"] = doctor_info.UserName
  27014. data["doctor_id"] = doctor_info.DoctorNumber
  27015. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  27016. data["fixmedins_code"] = miConfig.Code
  27017. data["dept_code"] = department.Number
  27018. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27019. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27020. data["secret_key"] = miConfig.SecretKey
  27021. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  27022. data["url"] = miConfig.Url
  27023. data["ak"] = miConfig.AccessKey
  27024. data["new_doctor_name"] = patientPrescription.Doctor
  27025. data["diag_code"] = sickConfig.CountryCode
  27026. data["cainfo"] = miConfig.Cainfo
  27027. data["opter"] = roles.UserName
  27028. var ids []int64
  27029. for _, item := range prescriptions {
  27030. ids = append(ids, item.ID)
  27031. }
  27032. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27033. if config.IsOpen == 1 { //对接了医保,走医保流程
  27034. var res ResultFour
  27035. var resFour10265 ResultFour10265
  27036. if miConfig.MdtrtareaAdmvs == "421300" {
  27037. bytesData, _ := json.Marshal(data)
  27038. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  27039. resp, _ := client.Do(req)
  27040. defer resp.Body.Close()
  27041. body, ioErr := ioutil.ReadAll(resp.Body)
  27042. if ioErr != nil {
  27043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27045. return
  27046. }
  27047. var respJSON map[string]interface{}
  27048. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27051. return
  27052. }
  27053. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27054. userJSONBytes, _ := json.Marshal(respJSON)
  27055. fmt.Println("log")
  27056. fmt.Println(string(userJSONBytes))
  27057. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27058. utils.ErrorLog("解析失败:%v", err)
  27059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27060. return
  27061. }
  27062. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27063. bytesData, _ := json.Marshal(data)
  27064. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  27065. resp, _ := client.Do(req)
  27066. defer resp.Body.Close()
  27067. body, ioErr := ioutil.ReadAll(resp.Body)
  27068. if ioErr != nil {
  27069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27071. return
  27072. }
  27073. var respJSON map[string]interface{}
  27074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27077. return
  27078. }
  27079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27080. userJSONBytes, _ := json.Marshal(respJSON)
  27081. fmt.Println("log")
  27082. fmt.Println(string(userJSONBytes))
  27083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27084. utils.ErrorLog("解析失败:%v", err)
  27085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27086. return
  27087. }
  27088. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27089. bytesData, _ := json.Marshal(data)
  27090. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27091. resp, _ := client.Do(req)
  27092. defer resp.Body.Close()
  27093. body, ioErr := ioutil.ReadAll(resp.Body)
  27094. if ioErr != nil {
  27095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. var respJSON map[string]interface{}
  27100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27103. return
  27104. }
  27105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27106. userJSONBytes, _ := json.Marshal(respJSON)
  27107. fmt.Println("log")
  27108. fmt.Println(string(userJSONBytes))
  27109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27110. utils.ErrorLog("解析失败:%v", err)
  27111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27112. return
  27113. }
  27114. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27115. bytesData, _ := json.Marshal(data)
  27116. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27117. resp, _ := client.Do(req)
  27118. defer resp.Body.Close()
  27119. body, ioErr := ioutil.ReadAll(resp.Body)
  27120. if ioErr != nil {
  27121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27123. return
  27124. }
  27125. var respJSON map[string]interface{}
  27126. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27129. return
  27130. }
  27131. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27132. userJSONBytes, _ := json.Marshal(respJSON)
  27133. fmt.Println("log")
  27134. fmt.Println(string(userJSONBytes))
  27135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27136. utils.ErrorLog("解析失败:%v", err)
  27137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27138. return
  27139. }
  27140. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27141. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27142. var result3101 Result3101
  27143. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27144. result3101.Infcode = "0"
  27145. if result3101.Infcode == "0" {
  27146. if len(result3101.Output.Result) > 0 {
  27147. var errMsgs []string
  27148. for _, item := range result3101.Output.Result {
  27149. errMsgs = append(errMsgs, item.VolaCont)
  27150. }
  27151. c.ServeSuccessJSON(map[string]interface{}{
  27152. "failed_code": -10,
  27153. "msg": errMsgs,
  27154. })
  27155. return
  27156. }
  27157. }
  27158. bytesData, _ := json.Marshal(data)
  27159. var req *http.Request
  27160. if miConfig.MdtrtareaAdmvs == "320830" {
  27161. data["diag_code"] = sickConfig.CountryCode
  27162. fmt.Println(data)
  27163. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  27164. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27165. data["diag_code"] = sickConfig.CountryCode
  27166. fmt.Println(data)
  27167. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27168. } else {
  27169. data["diag_code"] = sickConfig.CountryCode
  27170. fmt.Println(data)
  27171. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27172. }
  27173. resp, _ := client.Do(req)
  27174. defer resp.Body.Close()
  27175. body, ioErr := ioutil.ReadAll(resp.Body)
  27176. if ioErr != nil {
  27177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27179. return
  27180. }
  27181. var respJSON map[string]interface{}
  27182. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27185. return
  27186. }
  27187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27188. userJSONBytes, _ := json.Marshal(respJSON)
  27189. fmt.Println("log")
  27190. fmt.Println(string(userJSONBytes))
  27191. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27192. utils.ErrorLog("解析失败:%v", err)
  27193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27194. return
  27195. }
  27196. res.InfRefmsgid = resFour10265.InfRefmsgid
  27197. res.Output = resFour10265.Output
  27198. res.ErrMsg = resFour10265.ErrMsg
  27199. res.Cainfo = resFour10265.Cainfo
  27200. res.WarnMsg = resFour10265.WarnMsg
  27201. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27202. res.Infcode = infocode
  27203. } else if miConfig.MdtrtareaAdmvs == "150404" {
  27204. var pagesize int = 2
  27205. var start int = 1
  27206. var stop int
  27207. var pagecount int
  27208. var curpage int
  27209. var isSuccess bool = true
  27210. data["doctor_id"] = doctor_info.DoctorNumber
  27211. //总页数,向上取整,注意除之前要先转换类型为float64
  27212. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  27213. for curpage = 1; curpage <= pagecount; curpage++ {
  27214. if curpage == 1 {
  27215. start = 1
  27216. } else {
  27217. start = (curpage-1)*pagesize + 1
  27218. }
  27219. stop = curpage * pagesize
  27220. if stop > len(prescriptions) {
  27221. stop = len(prescriptions)
  27222. }
  27223. //var requestLog string
  27224. data["pre"] = prescriptions[start-1 : stop]
  27225. fmt.Println(data["pre"])
  27226. bytesData, _ := json.Marshal(data)
  27227. var req *http.Request
  27228. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27229. resp, _ := client.Do(req)
  27230. defer resp.Body.Close()
  27231. body, ioErr := ioutil.ReadAll(resp.Body)
  27232. if ioErr != nil {
  27233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27235. return
  27236. }
  27237. var respJSON map[string]interface{}
  27238. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27241. return
  27242. }
  27243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27244. userJSONBytes, _ := json.Marshal(respJSON)
  27245. fmt.Println("log")
  27246. fmt.Println(string(userJSONBytes))
  27247. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27248. utils.ErrorLog("解析失败:%v", err)
  27249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27250. return
  27251. }
  27252. res.InfRefmsgid = resFour10265.InfRefmsgid
  27253. res.Output = resFour10265.Output
  27254. res.ErrMsg = resFour10265.ErrMsg
  27255. res.Cainfo = resFour10265.Cainfo
  27256. res.WarnMsg = resFour10265.WarnMsg
  27257. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27258. res.Infcode = infocode
  27259. if infocode == 0 {
  27260. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  27261. } else {
  27262. isSuccess = false
  27263. errlog := &models.HisOrderError{
  27264. UserOrgId: adminUser.CurrentOrgId,
  27265. Ctime: time.Now().Unix(),
  27266. Mtime: time.Now().Unix(),
  27267. Number: chrg_bchno,
  27268. ErrMsg: "",
  27269. Status: 1,
  27270. PatientId: id,
  27271. RecordTime: recordDateTime,
  27272. Stage: 4,
  27273. }
  27274. service.CreateErrMsgLog(errlog)
  27275. c.ServeSuccessJSON(map[string]interface{}{
  27276. "failed_code": -10,
  27277. "msg": res.ErrMsg,
  27278. })
  27279. return
  27280. }
  27281. }
  27282. if isSuccess {
  27283. res.Infcode = 0
  27284. }
  27285. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27286. 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)
  27287. var dat map[string]interface{}
  27288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27289. fmt.Println(dat)
  27290. } else {
  27291. fmt.Println(err)
  27292. }
  27293. saveLog(result, request_log, "2204", "上传费用明细")
  27294. userJSONBytes, _ := json.Marshal(dat)
  27295. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27296. utils.ErrorLog("解析失败:%v", err)
  27297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27298. return
  27299. }
  27300. res.InfRefmsgid = resFour10265.InfRefmsgid
  27301. res.Output = resFour10265.Output
  27302. res.ErrMsg = resFour10265.ErrMsg
  27303. res.Cainfo = resFour10265.Cainfo
  27304. res.WarnMsg = resFour10265.WarnMsg
  27305. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27306. res.Infcode = infocode
  27307. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27308. bytesData, _ := json.Marshal(data)
  27309. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27310. resp, _ := client.Do(req)
  27311. defer resp.Body.Close()
  27312. body, ioErr := ioutil.ReadAll(resp.Body)
  27313. if ioErr != nil {
  27314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27316. return
  27317. }
  27318. var respJSON map[string]interface{}
  27319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27322. return
  27323. }
  27324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27325. userJSONBytes, _ := json.Marshal(respJSON)
  27326. fmt.Println("log")
  27327. fmt.Println(string(userJSONBytes))
  27328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27329. utils.ErrorLog("解析失败:%v", err)
  27330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27331. return
  27332. }
  27333. } else {
  27334. if miConfig.Code == "H15049901371" {
  27335. 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)
  27336. var dat map[string]interface{}
  27337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27338. fmt.Println(dat)
  27339. } else {
  27340. fmt.Println(err)
  27341. }
  27342. saveLog(result, request_log, "2204", "上传费用明细")
  27343. userJSONBytes, _ := json.Marshal(dat)
  27344. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27345. utils.ErrorLog("解析失败:%v", err)
  27346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27347. return
  27348. }
  27349. res.InfRefmsgid = resFour10265.InfRefmsgid
  27350. res.Output = resFour10265.Output
  27351. res.ErrMsg = resFour10265.ErrMsg
  27352. res.Cainfo = resFour10265.Cainfo
  27353. res.WarnMsg = resFour10265.WarnMsg
  27354. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27355. res.Infcode = infocode
  27356. } else {
  27357. 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)
  27358. var dat map[string]interface{}
  27359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27360. fmt.Println(dat)
  27361. } else {
  27362. fmt.Println(err)
  27363. }
  27364. saveLog(result, request_log, "2204", "上传费用明细")
  27365. userJSONBytes, _ := json.Marshal(dat)
  27366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27367. utils.ErrorLog("解析失败:%v", err)
  27368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27369. return
  27370. }
  27371. }
  27372. }
  27373. if res.Infcode == 0 {
  27374. order := &models.HisOrder{
  27375. UserOrgId: adminUser.CurrentOrgId,
  27376. HisPatientId: his.ID,
  27377. PatientId: his.PatientId,
  27378. SettleAccountsDate: recordDateTime,
  27379. MdtrtId: his.Number,
  27380. PsnNo: his.PsnNo,
  27381. MedType: strconv.FormatInt(reg_type, 10),
  27382. Ctime: time.Now().Unix(),
  27383. Mtime: time.Now().Unix(),
  27384. Status: 1,
  27385. Number: chrg_bchno,
  27386. Infcode: res.Infcode,
  27387. WarnMsg: res.WarnMsg,
  27388. Cainfo: res.Cainfo,
  27389. ErrMsg: res.ErrMsg,
  27390. RespondTime: res.RefmsgTime,
  27391. InfRefmsgid: res.InfRefmsgid,
  27392. OrderStatus: 1,
  27393. PayWay: pay_way,
  27394. PayWays: pay_ways,
  27395. OthDesc: oth_desc,
  27396. PayPrice: pay_price,
  27397. PayCardNo: pay_card_no,
  27398. DiscountPrice: discount_price,
  27399. PreferentialPrice: preferential_price,
  27400. RealityPrice: reality_price,
  27401. FoundPrice: found_price,
  27402. MedicalInsurancePrice: medical_insurance_price,
  27403. PrivatePrice: private_price,
  27404. IsMedicineInsurance: 1,
  27405. SettleType: settle_accounts_type,
  27406. SettleStartTime: start_time,
  27407. SettleEndTime: end_time,
  27408. Creator: roles.AdminUserId,
  27409. Modify: roles.AdminUserId,
  27410. FaPiaoNumber: fapiao_number,
  27411. FaPiaoCode: fapiao_code,
  27412. PType: 2,
  27413. Diagnosis: diagnosis_id,
  27414. CashPay: cash_pay,
  27415. WechatPay: wechat_pay,
  27416. AliPay: ali_pay,
  27417. JifenPay: jifen_pay,
  27418. BandCardPay: band_card_pay,
  27419. }
  27420. err = service.CreateOrder(order)
  27421. if err != nil {
  27422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27423. return
  27424. }
  27425. for _, item := range res.Output.Result {
  27426. temp := strings.Split(item.FeedetlSn, "-")
  27427. var advice_id int64 = 0
  27428. var project_id int64 = 0
  27429. var types int64 = 0
  27430. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27431. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27432. if temp[1] == "1" {
  27433. advice_id = id
  27434. project_id = 0
  27435. } else if temp[1] == "2" {
  27436. advice_id = 0
  27437. project_id = id
  27438. }
  27439. if item.MedChrgitmType == "9" {
  27440. item.MedChrgitmType = "09"
  27441. }
  27442. info := &models.HisOrderInfo{
  27443. OrderNumber: order.Number,
  27444. FeedetlSn: item.FeedetlSn,
  27445. UploadDate: time.Now().Unix(),
  27446. AdviceId: advice_id,
  27447. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27448. Cnt: item.Cnt,
  27449. Pric: float64(item.Pric),
  27450. PatientId: his.PatientId,
  27451. PricUplmtAmt: item.PricUplmtAmt,
  27452. SelfpayProp: item.SelfpayProp,
  27453. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27454. OverlmtAmt: item.OverlmtAmt,
  27455. PreselfpayAmt: item.PreselfpayAmt,
  27456. BasMednFlag: item.BasMednFlag,
  27457. MedChrgitmType: item.MedChrgitmType,
  27458. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27459. Status: 1,
  27460. Memo: item.Memo,
  27461. Mtime: time.Now().Unix(),
  27462. InscpScpAmt: item.InscpScpAmt,
  27463. DrtReimFlag: item.DrtReimFlag,
  27464. Ctime: time.Now().Unix(),
  27465. ListSpItemFlag: item.ListSpItemFlag,
  27466. ChldMedcFlag: item.ChldMedcFlag,
  27467. LmtUsedFlag: item.LmtUsedFlag,
  27468. ChrgitmLv: item.ChrgitmLv,
  27469. UserOrgId: adminUser.CurrentOrgId,
  27470. HisPatientId: his.ID,
  27471. OrderId: order.ID,
  27472. ProjectId: project_id,
  27473. Type: types,
  27474. }
  27475. service.CreateOrderInfo(info)
  27476. }
  27477. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27478. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27479. var total float64
  27480. for _, item := range prescriptions {
  27481. if item.Type == 1 { //药品
  27482. for _, subItem := range item.HisDoctorAdviceInfo {
  27483. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27484. total_one := price * subItem.PrescribingNumber
  27485. total = total + total_one
  27486. }
  27487. }
  27488. if item.Type == 2 { //项目
  27489. for _, subItem := range item.HisPrescriptionProject {
  27490. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27491. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27492. total_one := price * cnt
  27493. total = total + total_one
  27494. }
  27495. }
  27496. }
  27497. allTotal := fmt.Sprintf("%.2f", total)
  27498. //if adminUser.CurrentOrgId == 9919 {
  27499. //
  27500. // allTotal = fmt.Sprintf("%.2f", total)
  27501. //
  27502. //} else {
  27503. //
  27504. // allTotal = fmt.Sprintf("%.2f", total)
  27505. //
  27506. //}
  27507. if res.Infcode == 0 {
  27508. var rf []*ResultFive
  27509. json.Unmarshal([]byte(his.Iinfo), &rf)
  27510. chrg_bchno := chrg_bchno
  27511. cert_no := his.Certno
  27512. var insutypes []string
  27513. var insutype string
  27514. var is390 int = 0
  27515. var is310 int = 0
  27516. for _, item := range rf {
  27517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27518. insutypes = append(insutypes, item.Insutype)
  27519. }
  27520. }
  27521. if len(insutypes) == 1 {
  27522. insutype = insutypes[0]
  27523. } else {
  27524. for _, i := range insutypes {
  27525. if i == "390" {
  27526. is390 = 1
  27527. }
  27528. if i == "310" {
  27529. is310 = 1
  27530. }
  27531. }
  27532. }
  27533. if is390 == 1 {
  27534. insutype = "390"
  27535. }
  27536. if is310 == 1 {
  27537. insutype = "310"
  27538. }
  27539. if len(insutypes) == 0 {
  27540. insutype = "310"
  27541. }
  27542. if len(insutypes) == 2 {
  27543. insutype = strconv.FormatInt(his.SocialType, 10)
  27544. }
  27545. insutype = strconv.FormatInt(his.SocialType, 10)
  27546. //insutype = "390"
  27547. if his.IdCardType == 1 {
  27548. // cert_no = his.MedicalInsuranceNumber
  27549. cert_no = his.Certno
  27550. } else {
  27551. cert_no = his.Certno
  27552. }
  27553. var res ResultSeven
  27554. var resSeven10265 ResultSeven10265
  27555. var gzresSeven10265Two GZResultSeven10265Two
  27556. var src_resquest string
  27557. var result2 string
  27558. if miConfig.MdtrtareaAdmvs == "421300" {
  27559. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27560. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27561. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27562. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27563. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27564. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27565. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&pack_num=" + strconv.FormatInt(pack_num, 10)+ "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  27566. resp, requestErr := http.Get(api)
  27567. if requestErr != nil {
  27568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27569. return
  27570. }
  27571. body, ioErr := ioutil.ReadAll(resp.Body)
  27572. if ioErr != nil {
  27573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27575. return
  27576. }
  27577. var respJSON map[string]interface{}
  27578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27581. return
  27582. }
  27583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27584. result, _ := json.Marshal(respJSON)
  27585. if miConfig.Code == "H15049901371" {
  27586. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27587. utils.ErrorLog("解析失败:%v", err)
  27588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27589. return
  27590. }
  27591. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27592. res.Output = resSeven10265.Output
  27593. res.ErrMsg = resSeven10265.ErrMsg
  27594. res.Cainfo = resSeven10265.Cainfo
  27595. res.WarnMsg = resSeven10265.WarnMsg
  27596. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27597. res.Infcode = infocode
  27598. } else {
  27599. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27600. utils.ErrorLog("解析失败:%v", err)
  27601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27602. return
  27603. }
  27604. }
  27605. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27606. if reg_type == 11 && his.Insutype == "390" {
  27607. reg_type = 110104
  27608. }
  27609. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27610. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27611. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27612. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27613. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27614. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27615. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag+ "&pack_num=" + strconv.FormatInt(pack_num, 10)+ "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  27616. resp, requestErr := http.Get(api)
  27617. if requestErr != nil {
  27618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27619. return
  27620. }
  27621. body, ioErr := ioutil.ReadAll(resp.Body)
  27622. if ioErr != nil {
  27623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27625. return
  27626. }
  27627. var respJSON map[string]interface{}
  27628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27631. return
  27632. }
  27633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27634. result, _ := json.Marshal(respJSON)
  27635. if miConfig.Code == "H15049901371" {
  27636. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27637. utils.ErrorLog("解析失败:%v", err)
  27638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27639. return
  27640. }
  27641. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27642. res.Output = resSeven10265.Output
  27643. res.ErrMsg = resSeven10265.ErrMsg
  27644. res.Cainfo = resSeven10265.Cainfo
  27645. res.WarnMsg = resSeven10265.WarnMsg
  27646. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27647. res.Infcode = infocode
  27648. } else {
  27649. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27650. utils.ErrorLog("解析失败:%v", err)
  27651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27652. return
  27653. }
  27654. }
  27655. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27656. if reg_type == 11 && his.Insutype == "390" {
  27657. reg_type = 110104
  27658. }
  27659. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27660. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27661. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27662. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27663. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27664. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27665. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag+ "&pack_num=" + strconv.FormatInt(pack_num, 10)+ "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  27666. resp, requestErr := http.Get(api)
  27667. if requestErr != nil {
  27668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27669. return
  27670. }
  27671. body, ioErr := ioutil.ReadAll(resp.Body)
  27672. if ioErr != nil {
  27673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27675. return
  27676. }
  27677. var respJSON map[string]interface{}
  27678. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27681. return
  27682. }
  27683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27684. result, _ := json.Marshal(respJSON)
  27685. if miConfig.Code == "H15049901371" {
  27686. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27687. utils.ErrorLog("解析失败:%v", err)
  27688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27689. return
  27690. }
  27691. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27692. res.Output = resSeven10265.Output
  27693. res.ErrMsg = resSeven10265.ErrMsg
  27694. res.Cainfo = resSeven10265.Cainfo
  27695. res.WarnMsg = resSeven10265.WarnMsg
  27696. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27697. res.Infcode = infocode
  27698. } else {
  27699. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27700. utils.ErrorLog("解析失败:%v", err)
  27701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27702. return
  27703. }
  27704. }
  27705. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27706. if reg_type == 11 && his.Insutype == "390" {
  27707. reg_type = 110104
  27708. }
  27709. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27710. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27711. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27712. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27713. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27714. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27715. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag+ "&pack_num=" + strconv.FormatInt(pack_num, 10)+ "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  27716. resp, requestErr := http.Get(api)
  27717. if requestErr != nil {
  27718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27719. return
  27720. }
  27721. body, ioErr := ioutil.ReadAll(resp.Body)
  27722. if ioErr != nil {
  27723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27725. return
  27726. }
  27727. var respJSON map[string]interface{}
  27728. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27731. return
  27732. }
  27733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27734. result, _ := json.Marshal(respJSON)
  27735. if miConfig.Code == "H15049901371" {
  27736. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27737. utils.ErrorLog("解析失败:%v", err)
  27738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27739. return
  27740. }
  27741. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27742. res.Output = resSeven10265.Output
  27743. res.ErrMsg = resSeven10265.ErrMsg
  27744. res.Cainfo = resSeven10265.Cainfo
  27745. res.WarnMsg = resSeven10265.WarnMsg
  27746. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27747. res.Infcode = infocode
  27748. } else {
  27749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27750. utils.ErrorLog("解析失败:%v", err)
  27751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27752. return
  27753. }
  27754. }
  27755. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27756. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27757. var result3101 Result3101
  27758. //utils.ErrorLog("解析失败:%v", result3101)
  27759. result3101.Infcode = "0"
  27760. if result3101.Infcode == "0" {
  27761. if len(result3101.Output.Result) > 0 {
  27762. var errMsgs []string
  27763. for _, item := range result3101.Output.Result {
  27764. errMsgs = append(errMsgs, item.VolaCont)
  27765. }
  27766. c.ServeSuccessJSON(map[string]interface{}{
  27767. "failed_code": -10,
  27768. "msg": errMsgs,
  27769. })
  27770. return
  27771. } else {
  27772. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27773. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27774. bas := strings.Split(psn_info.CardInfo, "|")
  27775. if his.IdCardType == 1 {
  27776. cert_no = bas[2]
  27777. } else if his.IdCardType == 3 {
  27778. cert_no = his.Certno
  27779. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27780. } else if his.IdCardType == 4 {
  27781. cert_no = his.Certno
  27782. psn_info.VerifyNumber = psn_info.VerifyNumber
  27783. }
  27784. var api string
  27785. if miConfig.MdtrtareaAdmvs == "320830" {
  27786. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27787. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27788. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27790. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27791. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27792. "&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+ "&pack_num=" + strconv.FormatInt(pack_num, 10)+ "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  27793. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27794. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27795. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27796. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27798. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27799. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27800. "&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+ "&pack_num=" + strconv.FormatInt(pack_num, 10)+ "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  27801. } else {
  27802. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27803. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27804. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27805. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27806. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27807. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27808. "&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+ "&pack_num=" + strconv.FormatInt(pack_num, 10)+ "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  27809. }
  27810. resp, requestErr := http.Get(api)
  27811. if requestErr != nil {
  27812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27813. return
  27814. }
  27815. body, ioErr := ioutil.ReadAll(resp.Body)
  27816. if ioErr != nil {
  27817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27819. return
  27820. }
  27821. var respJSON map[string]interface{}
  27822. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27825. return
  27826. }
  27827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27828. result, _ := json.Marshal(respJSON)
  27829. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27830. utils.ErrorLog("解析失败:%v", err)
  27831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27832. return
  27833. }
  27834. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27835. res.Output = resSeven10265.Output
  27836. res.ErrMsg = resSeven10265.ErrMsg
  27837. res.Cainfo = resSeven10265.Cainfo
  27838. res.WarnMsg = resSeven10265.WarnMsg
  27839. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27840. res.Infcode = infocode
  27841. }
  27842. }
  27843. } else if miConfig.MdtrtareaAdmvs == "150404" {
  27844. psn_info, _ := service.GetPsnByPatientId(id)
  27845. var verify_number string
  27846. if psn_info.IdCardType == 4 {
  27847. verify_number = psn_info.VerifyNumber
  27848. } else if psn_info.IdCardType == 1 {
  27849. bas := strings.Split(psn_info.CardInfo, "|")
  27850. cardNumber := bas[2]
  27851. verify_number = cardNumber
  27852. } else {
  27853. psn_info.IdCardType = 2
  27854. verify_number = psn_info.Certno
  27855. }
  27856. var api string
  27857. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27858. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27859. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27860. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27861. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27862. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27863. "&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 + "&pack_num=" + strconv.FormatInt(pack_num, 10)+ "&good_pack_num=" + strconv.FormatInt(good_pack_num, 10)
  27864. resp, requestErr := http.Get(api)
  27865. if requestErr != nil {
  27866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27867. return
  27868. }
  27869. body, ioErr := ioutil.ReadAll(resp.Body)
  27870. if ioErr != nil {
  27871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27873. return
  27874. }
  27875. var respJSON map[string]interface{}
  27876. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27879. return
  27880. }
  27881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27882. result, _ := json.Marshal(respJSON)
  27883. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27884. utils.ErrorLog("解析失败:%v", err)
  27885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27886. return
  27887. }
  27888. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27889. res.Output = resSeven10265.Output
  27890. res.ErrMsg = resSeven10265.ErrMsg
  27891. res.Cainfo = resSeven10265.Cainfo
  27892. res.WarnMsg = resSeven10265.WarnMsg
  27893. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27894. res.Infcode = infocode
  27895. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27896. var cert_no string
  27897. if his.IdCardType == 4 {
  27898. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27899. cert_no = psn_info.VerifyNumber
  27900. 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,tempOrder.PackNum,tempOrder.GoodPackNum)
  27901. } else if his.IdCardType == 1 {
  27902. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27903. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27904. 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,tempOrder.PackNum,tempOrder.GoodPackNum)
  27905. }
  27906. //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)
  27907. var dat map[string]interface{}
  27908. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27909. fmt.Println(dat)
  27910. } else {
  27911. fmt.Println(err)
  27912. }
  27913. saveLog(result2, src_resquest, "2207", "结算")
  27914. userJSONBytes, _ := json.Marshal(dat)
  27915. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27916. utils.ErrorLog("解析失败:%v", err)
  27917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27918. return
  27919. }
  27920. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27921. res.Output = resSeven10265.Output
  27922. res.ErrMsg = resSeven10265.ErrMsg
  27923. res.Cainfo = resSeven10265.Cainfo
  27924. res.WarnMsg = resSeven10265.WarnMsg
  27925. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27926. res.Infcode = infocode
  27927. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27928. res2 := c.GetoleInfo()
  27929. if res2.Infcode == 0 {
  27930. var result string
  27931. var request_log string
  27932. var result_log string
  27933. if res2.Output.MdtrtCertType == "02" {
  27934. 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)
  27935. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27936. } else if res2.Output.MdtrtCertType == "01" {
  27937. 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)
  27938. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27939. } else {
  27940. 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)
  27941. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27942. }
  27943. var dat map[string]interface{}
  27944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27945. fmt.Println(dat)
  27946. } else {
  27947. fmt.Println(err)
  27948. }
  27949. userJSONBytes, _ := json.Marshal(dat)
  27950. var res5 ResultTwo
  27951. //var resTwo10265 ResultTwo10265
  27952. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27953. utils.ErrorLog("解析失败:%v", err)
  27954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27955. return
  27956. }
  27957. if res5.Infcode == -1 {
  27958. c.ServeSuccessJSON(map[string]interface{}{
  27959. "failed_code": -10,
  27960. "msg": res5.ErrMsg,
  27961. })
  27962. return
  27963. }
  27964. var insutypes []string
  27965. var insutype string
  27966. var is390 int = 0
  27967. var is310 int = 0
  27968. for _, item := range res5.Output.Iinfo {
  27969. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27970. insutypes = append(insutypes, item.Insutype)
  27971. }
  27972. }
  27973. if len(insutypes) == 1 {
  27974. insutype = insutypes[0]
  27975. } else {
  27976. for _, i := range insutypes {
  27977. if i == "390" {
  27978. is390 = 1
  27979. }
  27980. if i == "310" {
  27981. is310 = 1
  27982. }
  27983. }
  27984. }
  27985. if is390 == 1 {
  27986. insutype = "390"
  27987. }
  27988. if is310 == 1 {
  27989. insutype = "310"
  27990. }
  27991. if len(insutypes) == 0 {
  27992. insutype = "310"
  27993. }
  27994. fmt.Println(insutype)
  27995. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27996. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27997. infoStr := string(Iinfos)
  27998. idetinfoStr := string(Idetinfos)
  27999. psn := &models.HisPsn{
  28000. PsnNo: res5.Output.Baseinfo.PsnNo,
  28001. PatientId: id,
  28002. Certno: res5.Output.Baseinfo.Certno,
  28003. Gend: res5.Output.Baseinfo.Gend,
  28004. Naty: res5.Output.Baseinfo.Naty,
  28005. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28006. PsnName: res5.Output.Baseinfo.PsnName,
  28007. Idetinfo: idetinfoStr,
  28008. Insuinfo: infoStr,
  28009. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28010. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28011. VerifyNumber: res2.Output.EcToken,
  28012. }
  28013. if res2.Output.MdtrtCertType == "01" {
  28014. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28015. psn.VerifyNumber = res2.Output.EcToken
  28016. } else if res2.Output.MdtrtCertType == "02" {
  28017. psn.VerifyNumber = res2.Output.CardNo
  28018. } else {
  28019. psn.VerifyNumber = res2.Output.MdtrtCertNo
  28020. }
  28021. service.CreateHisPsn(psn)
  28022. if res2.Output.MdtrtCertType == "01" {
  28023. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28024. token := res2.Output.EcToken
  28025. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  28026. } else if res2.Output.MdtrtCertType == "02" {
  28027. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  28028. } else {
  28029. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  28030. }
  28031. var dat2 map[string]interface{}
  28032. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28033. fmt.Println(dat2)
  28034. } else {
  28035. fmt.Println(err)
  28036. }
  28037. userJSONBytes3, _ := json.Marshal(dat2)
  28038. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28039. utils.ErrorLog("解析失败:%v", err)
  28040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28041. return
  28042. }
  28043. saveLog(result2, src_resquest, "2207", "结算")
  28044. } else {
  28045. c.ServeSuccessJSON(map[string]interface{}{
  28046. "failed_code": -10,
  28047. "msg": res2.ErrMsg,
  28048. })
  28049. return
  28050. }
  28051. } else {
  28052. if miConfig.Code == "H15049901371" {
  28053. //赤峰地区国家医保医疗类别
  28054. //职工透析:医疗类别选特殊情况门诊990502
  28055. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28056. var med_type string
  28057. if his.Insutype == "390" {
  28058. if reg_type == 14 {
  28059. med_type = "9933"
  28060. } else if reg_type == 11 {
  28061. med_type = "11"
  28062. }
  28063. } else if his.Insutype == "310" {
  28064. if reg_type == 14 {
  28065. med_type = "990502"
  28066. } else if reg_type == 11 {
  28067. med_type = "11"
  28068. }
  28069. }
  28070. 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)
  28071. } else {
  28072. if his.IdCardType == 4 {
  28073. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28074. var token string
  28075. token = psn_info.VerifyNumber
  28076. 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)
  28077. } else {
  28078. if his.IdCardType == 1 {
  28079. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28080. bas := strings.Split(psn_info.CardInfo, "|")
  28081. basNumber := bas[2]
  28082. cert_no = basNumber
  28083. }
  28084. 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)
  28085. }
  28086. }
  28087. //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)
  28088. var dat map[string]interface{}
  28089. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28090. fmt.Println(dat)
  28091. } else {
  28092. fmt.Println(err)
  28093. }
  28094. saveLog(result2, src_resquest, "2207", "结算")
  28095. userJSONBytes, _ := json.Marshal(dat)
  28096. if miConfig.Code == "H15049901371" {
  28097. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28098. utils.ErrorLog("解析失败:%v", err)
  28099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28100. return
  28101. }
  28102. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28103. res.Output = resSeven10265.Output
  28104. res.ErrMsg = resSeven10265.ErrMsg
  28105. res.Cainfo = resSeven10265.Cainfo
  28106. res.WarnMsg = resSeven10265.WarnMsg
  28107. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28108. res.Infcode = infocode
  28109. } else {
  28110. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28111. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28112. utils.ErrorLog("解析失败:%v", err)
  28113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28114. return
  28115. }
  28116. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28117. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28118. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28119. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28120. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28121. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28122. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28123. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28124. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28125. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28126. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28127. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28128. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28129. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28130. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28131. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28132. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28133. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28134. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28135. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28136. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28137. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28138. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28139. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28140. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28141. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28142. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28143. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28144. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28145. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28146. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28147. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28148. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28149. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28150. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28151. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28152. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28153. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28154. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28155. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28156. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28157. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28158. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28159. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28160. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28161. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28162. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28163. res.Cainfo = gzresSeven10265Two.Cainfo
  28164. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28165. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28166. //res.Infcode = infocode
  28167. } else {
  28168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28169. utils.ErrorLog("解析失败:%v", err)
  28170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28171. return
  28172. }
  28173. }
  28174. }
  28175. }
  28176. if res.Infcode == -1 {
  28177. errlog := &models.HisOrderError{
  28178. UserOrgId: adminUser.CurrentOrgId,
  28179. Ctime: time.Now().Unix(),
  28180. Mtime: time.Now().Unix(),
  28181. Number: chrg_bchno,
  28182. ErrMsg: res.ErrMsg,
  28183. Status: 1,
  28184. PatientId: id,
  28185. RecordTime: recordDateTime,
  28186. Stage: 6,
  28187. }
  28188. service.CreateErrMsgLog(errlog)
  28189. c.ServeSuccessJSON(map[string]interface{}{
  28190. "failed_code": -10,
  28191. "msg": res.ErrMsg,
  28192. })
  28193. return
  28194. } else {
  28195. sickConfig, _ := service.FindSickById(his.SickType)
  28196. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28197. order.OrderStatus = 2
  28198. order.Status = 1
  28199. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28200. order.SetlId = res.Output.Setlinfo.SetlID
  28201. order.PsnNo = res.Output.Setlinfo.PsnNo
  28202. order.PsnName = res.Output.Setlinfo.PsnName
  28203. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28204. order.Certno = res.Output.Setlinfo.Certno
  28205. order.Gend = res.Output.Setlinfo.Gend
  28206. order.Naty = res.Output.Setlinfo.Naty
  28207. order.Age = res.Output.Setlinfo.Age
  28208. order.Insutype = res.Output.Setlinfo.Insutype
  28209. order.PsnType = res.Output.Setlinfo.PsnType
  28210. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28211. order.SetlTime = res.Output.Setlinfo.SetlTime
  28212. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28213. if res.Output.Setlinfo.MedType == "140101" {
  28214. order.MedType = "14"
  28215. } else {
  28216. if res.Output.Setlinfo.MedType == "110104" {
  28217. order.MedType = "11"
  28218. } else {
  28219. order.MedType = res.Output.Setlinfo.MedType
  28220. }
  28221. }
  28222. if reg_type == 1112 {
  28223. order.MedType = "1112"
  28224. }
  28225. if reg_type == 1111 {
  28226. order.MedType = "1111"
  28227. }
  28228. order.ClrType = res.Output.Setlinfo.ClrType
  28229. if adminUser.CurrentOrgId == 10480 {
  28230. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28231. order.ClrType = "11"
  28232. } else {
  28233. order.ClrType = "9903"
  28234. }
  28235. }
  28236. if adminUser.CurrentOrgId == 10721 {
  28237. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28238. order.ClrType = "11"
  28239. } else {
  28240. order.ClrType = "9903"
  28241. }
  28242. }
  28243. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28244. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28245. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28246. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28247. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28248. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28249. order.HifpPay = res.Output.Setlinfo.HifpPay
  28250. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28251. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28252. order.HifesPay = res.Output.Setlinfo.HifesPay
  28253. order.HifobPay = res.Output.Setlinfo.HifobPay
  28254. order.MafPay = res.Output.Setlinfo.MafPay
  28255. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28256. order.OthPay = res.Output.Setlinfo.OthPay
  28257. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28258. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28259. order.AcctPay = res.Output.Setlinfo.AcctPay
  28260. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28261. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28262. order.Balc = res.Output.Setlinfo.Balc
  28263. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28264. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28265. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28266. //order.ClrType = res.Output.Setlinfo.ClrType
  28267. order.ClrWay = res.Output.Setlinfo.ClrWay
  28268. order.Creator = order.Creator
  28269. order.Modify = roles.AdminUserId
  28270. order.RequestLog = src_resquest
  28271. order.FaPiaoNumber = fapiao_number
  28272. order.FaPiaoCode = fapiao_code
  28273. order.SickName = sickConfig.ClassName
  28274. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28275. //detailStr := string(setlDetail)
  28276. //order.SetlDetail = detailStr
  28277. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28278. err = service.UpDateOrder(order)
  28279. if err == nil {
  28280. //判断是否使用了押金
  28281. if dec_way == "true" {
  28282. tmpstring := strconv.FormatInt(order.ID, 10)
  28283. order.Decimal = decimal
  28284. service.UpDateOrder(order)
  28285. //扣押金
  28286. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28287. if errmsg != nil {
  28288. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28289. return
  28290. }
  28291. }
  28292. c.ServeSuccessJSON(map[string]interface{}{
  28293. "msg": "结算成功",
  28294. })
  28295. } else {
  28296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28297. return
  28298. }
  28299. }
  28300. } else {
  28301. adminUser := c.GetAdminUserInfo()
  28302. errlog := &models.HisOrderError{
  28303. UserOrgId: adminUser.CurrentOrgId,
  28304. Ctime: time.Now().Unix(),
  28305. Mtime: time.Now().Unix(),
  28306. ErrMsg: res.ErrMsg,
  28307. Status: 1,
  28308. PatientId: id,
  28309. RecordTime: recordDateTime,
  28310. Stage: 4,
  28311. }
  28312. service.CreateErrMsgLog(errlog)
  28313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28314. return
  28315. }
  28316. } else {
  28317. adminUser := c.GetAdminUserInfo()
  28318. errlog := &models.HisOrderError{
  28319. UserOrgId: adminUser.CurrentOrgId,
  28320. Ctime: time.Now().Unix(),
  28321. Mtime: time.Now().Unix(),
  28322. ErrMsg: res.ErrMsg,
  28323. Status: 1,
  28324. PatientId: id,
  28325. RecordTime: recordDateTime,
  28326. Stage: 4,
  28327. }
  28328. service.CreateErrMsgLog(errlog)
  28329. c.ServeSuccessJSON(map[string]interface{}{
  28330. "failed_code": -10,
  28331. "msg": res.ErrMsg,
  28332. })
  28333. return
  28334. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28335. //return
  28336. }
  28337. }
  28338. }
  28339. } else if tempOrder.ID > 0 {
  28340. if tempOrder.IsPre == 1 {
  28341. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28342. var rf []*ResultFive
  28343. json.Unmarshal([]byte(his.Iinfo), &rf)
  28344. chrg_bchno := tempOrder.Number
  28345. cert_no := his.Certno
  28346. var insutypes []string
  28347. var insutype string
  28348. var is390 int = 0
  28349. var is310 int = 0
  28350. for _, item := range rf {
  28351. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28352. insutypes = append(insutypes, item.Insutype)
  28353. }
  28354. }
  28355. if len(insutypes) == 1 {
  28356. insutype = insutypes[0]
  28357. } else {
  28358. for _, i := range insutypes {
  28359. if i == "390" {
  28360. is390 = 1
  28361. }
  28362. if i == "310" {
  28363. is310 = 1
  28364. }
  28365. }
  28366. }
  28367. if is390 == 1 {
  28368. insutype = "390"
  28369. }
  28370. if is310 == 1 {
  28371. insutype = "310"
  28372. }
  28373. if len(insutypes) == 0 {
  28374. insutype = "310"
  28375. }
  28376. if len(insutypes) == 2 {
  28377. insutype = strconv.FormatInt(his.SocialType, 10)
  28378. }
  28379. //insutype = "390"
  28380. if his.IdCardType == 1 {
  28381. // cert_no = his.MedicalInsuranceNumber
  28382. cert_no = his.Certno
  28383. } else {
  28384. cert_no = his.Certno
  28385. }
  28386. var res ResultSeven
  28387. var ahres ResultSevenAH
  28388. var resSeven10265 ResultSeven10265
  28389. var gzresSeven10265Two GZResultSeven10265Two
  28390. var src_resquest string
  28391. var result2 string
  28392. if miConfig.MdtrtareaAdmvs == "450721" {
  28393. res2 := c.GetoleInfo()
  28394. if res2.Infcode == 0 {
  28395. var result string
  28396. var request_log string
  28397. var result_log string
  28398. if res2.Output.MdtrtCertType == "02" {
  28399. 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)
  28400. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28401. } else if res2.Output.MdtrtCertType == "01" {
  28402. 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)
  28403. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28404. } else {
  28405. 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)
  28406. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28407. }
  28408. var dat map[string]interface{}
  28409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28410. fmt.Println(dat)
  28411. } else {
  28412. fmt.Println(err)
  28413. }
  28414. userJSONBytes, _ := json.Marshal(dat)
  28415. var res5 ResultTwo
  28416. //var resTwo10265 ResultTwo10265
  28417. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28418. utils.ErrorLog("解析失败:%v", err)
  28419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28420. return
  28421. }
  28422. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28423. if res5.Infcode == -1 {
  28424. c.ServeSuccessJSON(map[string]interface{}{
  28425. "failed_code": -10,
  28426. "msg": res5.ErrMsg,
  28427. })
  28428. return
  28429. }
  28430. var insutypes []string
  28431. var insutype string
  28432. var is390 int = 0
  28433. var is310 int = 0
  28434. for _, item := range res5.Output.Iinfo {
  28435. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28436. insutypes = append(insutypes, item.Insutype)
  28437. }
  28438. }
  28439. if len(insutypes) == 1 {
  28440. insutype = insutypes[0]
  28441. } else {
  28442. for _, i := range insutypes {
  28443. if i == "390" {
  28444. is390 = 1
  28445. }
  28446. if i == "310" {
  28447. is310 = 1
  28448. }
  28449. }
  28450. }
  28451. if is390 == 1 {
  28452. insutype = "390"
  28453. }
  28454. if is310 == 1 {
  28455. insutype = "310"
  28456. }
  28457. if len(insutypes) == 0 {
  28458. insutype = "310"
  28459. }
  28460. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28461. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28462. infoStr := string(Iinfos)
  28463. idetinfoStr := string(Idetinfos)
  28464. psn := &models.HisPsn{
  28465. PsnNo: res5.Output.Baseinfo.PsnNo,
  28466. PatientId: id,
  28467. Certno: res5.Output.Baseinfo.Certno,
  28468. Gend: res5.Output.Baseinfo.Gend,
  28469. Naty: res5.Output.Baseinfo.Naty,
  28470. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28471. PsnName: res5.Output.Baseinfo.PsnName,
  28472. Idetinfo: idetinfoStr,
  28473. Insuinfo: infoStr,
  28474. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28475. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28476. VerifyNumber: res2.Output.EcToken,
  28477. }
  28478. service.CreateHisPsn(psn)
  28479. if res2.Output.MdtrtCertType == "01" {
  28480. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28481. token := res2.Output.EcToken
  28482. 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)
  28483. } else if res2.Output.MdtrtCertType == "02" {
  28484. 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)
  28485. } else {
  28486. 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)
  28487. }
  28488. var dat2 map[string]interface{}
  28489. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28490. fmt.Println(dat2)
  28491. } else {
  28492. fmt.Println(err)
  28493. }
  28494. userJSONBytes3, _ := json.Marshal(dat2)
  28495. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28496. utils.ErrorLog("解析失败:%v", err)
  28497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28498. return
  28499. }
  28500. saveLog(result2, src_resquest, "2207", "结算")
  28501. } else {
  28502. c.ServeSuccessJSON(map[string]interface{}{
  28503. "failed_code": -10,
  28504. "msg": res2.ErrMsg,
  28505. })
  28506. return
  28507. }
  28508. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28509. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28510. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28511. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28512. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28513. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28514. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28515. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28516. resp, requestErr := http.Get(api)
  28517. if requestErr != nil {
  28518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28519. return
  28520. }
  28521. body, ioErr := ioutil.ReadAll(resp.Body)
  28522. if ioErr != nil {
  28523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28525. return
  28526. }
  28527. var respJSON map[string]interface{}
  28528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28531. return
  28532. }
  28533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28534. result, _ := json.Marshal(respJSON)
  28535. fmt.Println("log")
  28536. fmt.Println(string(result))
  28537. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28538. utils.ErrorLog("解析失败:%v", err)
  28539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28540. return
  28541. }
  28542. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28543. if reg_type == 11 && his.Insutype == "390" {
  28544. reg_type = 110104
  28545. }
  28546. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28547. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28548. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28549. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28550. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28551. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28552. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28553. resp, requestErr := http.Get(api)
  28554. if requestErr != nil {
  28555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28556. return
  28557. }
  28558. body, ioErr := ioutil.ReadAll(resp.Body)
  28559. if ioErr != nil {
  28560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28562. return
  28563. }
  28564. var respJSON map[string]interface{}
  28565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28568. return
  28569. }
  28570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28571. result, _ := json.Marshal(respJSON)
  28572. fmt.Println("log")
  28573. fmt.Println(string(result))
  28574. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28575. utils.ErrorLog("解析失败:%v", err)
  28576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28577. return
  28578. }
  28579. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28580. if reg_type == 11 && his.Insutype == "390" {
  28581. reg_type = 110104
  28582. }
  28583. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28584. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28585. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28586. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28587. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28588. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28589. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28590. resp, requestErr := http.Get(api)
  28591. if requestErr != nil {
  28592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28593. return
  28594. }
  28595. body, ioErr := ioutil.ReadAll(resp.Body)
  28596. if ioErr != nil {
  28597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28599. return
  28600. }
  28601. var respJSON map[string]interface{}
  28602. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28605. return
  28606. }
  28607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28608. result, _ := json.Marshal(respJSON)
  28609. fmt.Println("log")
  28610. fmt.Println(string(result))
  28611. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28612. utils.ErrorLog("解析失败:%v", err)
  28613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28614. return
  28615. }
  28616. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28617. if reg_type == 11 && his.Insutype == "390" {
  28618. reg_type = 110104
  28619. }
  28620. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28621. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28622. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28624. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28625. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28626. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28627. resp, requestErr := http.Get(api)
  28628. if requestErr != nil {
  28629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28630. return
  28631. }
  28632. body, ioErr := ioutil.ReadAll(resp.Body)
  28633. if ioErr != nil {
  28634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28636. return
  28637. }
  28638. var respJSON map[string]interface{}
  28639. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28642. return
  28643. }
  28644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28645. result, _ := json.Marshal(respJSON)
  28646. fmt.Println("log")
  28647. fmt.Println(string(result))
  28648. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28649. utils.ErrorLog("解析失败:%v", err)
  28650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28651. return
  28652. }
  28653. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28654. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28655. var result3101 Result3101
  28656. //utils.ErrorLog("解析失败:%v", result3101)
  28657. result3101.Infcode = "0"
  28658. if result3101.Infcode == "0" {
  28659. if len(result3101.Output.Result) > 0 {
  28660. var errMsgs []string
  28661. for _, item := range result3101.Output.Result {
  28662. errMsgs = append(errMsgs, item.VolaCont)
  28663. }
  28664. c.ServeSuccessJSON(map[string]interface{}{
  28665. "failed_code": -10,
  28666. "msg": errMsgs,
  28667. })
  28668. return
  28669. } else {
  28670. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28671. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28672. bas := strings.Split(psn_info.CardInfo, "|")
  28673. if his.IdCardType == 1 {
  28674. cert_no = bas[2]
  28675. } else if his.IdCardType == 3 {
  28676. cert_no = his.Certno
  28677. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28678. } else if his.IdCardType == 4 {
  28679. cert_no = his.Certno
  28680. psn_info.VerifyNumber = psn_info.VerifyNumber
  28681. }
  28682. //江苏地区国家医保医疗类别
  28683. //职工透析:医疗类别选特殊情况门诊9933
  28684. //居民血透门慢: 医疗类别选门诊慢病1402
  28685. //var med_type string
  28686. //if his.Insutype == "310" {
  28687. // if reg_type == 14 {
  28688. // med_type = "9933"
  28689. // } else if reg_type == 11 {
  28690. // med_type = "11"
  28691. //
  28692. // }
  28693. //} else if his.Insutype == "390" {
  28694. // if reg_type == 14 {
  28695. // med_type = "1402"
  28696. // } else if reg_type == 11 {
  28697. // med_type = "11"
  28698. // }
  28699. //}
  28700. var api string
  28701. if miConfig.MdtrtareaAdmvs == "320830" {
  28702. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28703. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28704. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28705. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28706. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28707. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28708. "&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
  28709. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28710. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28711. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28712. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28713. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28714. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28715. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28716. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28717. "&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
  28718. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28719. } else {
  28720. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28721. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28722. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28723. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28725. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28726. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28727. "&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
  28728. }
  28729. resp, requestErr := http.Get(api)
  28730. if requestErr != nil {
  28731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28732. return
  28733. }
  28734. body, ioErr := ioutil.ReadAll(resp.Body)
  28735. if ioErr != nil {
  28736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28738. return
  28739. }
  28740. var respJSON map[string]interface{}
  28741. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28744. return
  28745. }
  28746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28747. result, _ := json.Marshal(respJSON)
  28748. fmt.Println("log")
  28749. fmt.Println(string(result))
  28750. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28751. utils.ErrorLog("解析失败:%v", err)
  28752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28753. return
  28754. }
  28755. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28756. res.Output = resSeven10265.Output
  28757. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28758. res.ErrMsg = resSeven10265.ErrMsg
  28759. res.Cainfo = resSeven10265.Cainfo
  28760. res.WarnMsg = resSeven10265.WarnMsg
  28761. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28762. res.Infcode = infocode
  28763. }
  28764. }
  28765. } else if miConfig.MdtrtareaAdmvs == "150404" {
  28766. psn_info, _ := service.GetPsnByPatientId(id)
  28767. var verify_number string
  28768. if psn_info.IdCardType == 4 {
  28769. verify_number = psn_info.VerifyNumber
  28770. } else if psn_info.IdCardType == 1 {
  28771. bas := strings.Split(psn_info.CardInfo, "|")
  28772. cardNumber := bas[2]
  28773. verify_number = cardNumber
  28774. } else {
  28775. verify_number = psn_info.Certno
  28776. psn_info.IdCardType = 2
  28777. }
  28778. var api string
  28779. new_chrg_bchno := chrg_bchno
  28780. if adminUser.CurrentOrgId == 10265 {
  28781. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28782. new_chrg_bchno = "0000"
  28783. }
  28784. }
  28785. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28786. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28787. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28788. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28789. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28790. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28791. "&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
  28792. resp, requestErr := http.Get(api)
  28793. if requestErr != nil {
  28794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28795. return
  28796. }
  28797. body, ioErr := ioutil.ReadAll(resp.Body)
  28798. if ioErr != nil {
  28799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28801. return
  28802. }
  28803. var respJSON map[string]interface{}
  28804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28807. return
  28808. }
  28809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28810. result, _ := json.Marshal(respJSON)
  28811. fmt.Println("log")
  28812. fmt.Println(string(result))
  28813. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28814. utils.ErrorLog("解析失败:%v", err)
  28815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28816. return
  28817. }
  28818. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28819. res.Output = resSeven10265.Output
  28820. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28821. res.ErrMsg = resSeven10265.ErrMsg
  28822. res.Cainfo = resSeven10265.Cainfo
  28823. res.WarnMsg = resSeven10265.WarnMsg
  28824. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28825. res.Infcode = infocode
  28826. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28827. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28828. var cert_no string
  28829. if his.IdCardType == 1 {
  28830. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28831. } else {
  28832. cert_no = psn_info.VerifyNumber
  28833. }
  28834. 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)
  28835. var dat map[string]interface{}
  28836. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28837. fmt.Println(dat)
  28838. } else {
  28839. fmt.Println(err)
  28840. }
  28841. saveLog(result2, src_resquest, "2207", "结算")
  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. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28850. var cert_no string
  28851. var card_sn string
  28852. if his.IdCardType == 1 {
  28853. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28854. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28855. bas := strings.Split(psn_info.CardInfo, "|")
  28856. card_sn = bas[3]
  28857. } else if his.IdCardType == 2 {
  28858. cert_no = his.IdCardNo
  28859. } else {
  28860. cert_no = psn_info.VerifyNumber
  28861. }
  28862. var rf []*ResultFive
  28863. json.Unmarshal([]byte(his.Iinfo), &rf)
  28864. var psn_type string
  28865. for _, item := range rf {
  28866. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28867. psn_type = item.PsnType
  28868. }
  28869. }
  28870. 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)
  28871. var dat map[string]interface{}
  28872. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28873. fmt.Println(dat)
  28874. } else {
  28875. fmt.Println(err)
  28876. }
  28877. saveLog(result2, src_resquest, "2207", "结算")
  28878. userJSONBytes, _ := json.Marshal(dat)
  28879. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28880. utils.ErrorLog("解析失败:%v", err)
  28881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28882. return
  28883. }
  28884. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28885. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28886. var cert_no string
  28887. var card_sn string
  28888. if his.IdCardType == 1 {
  28889. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28890. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28891. //bas := strings.Split(psn_info.CardInfo, "|")
  28892. card_sn = ""
  28893. } else if his.IdCardType == 2 {
  28894. cert_no = his.IdCardNo
  28895. } else {
  28896. cert_no = psn_info.VerifyNumber
  28897. }
  28898. var rf []*ResultFive
  28899. json.Unmarshal([]byte(his.Iinfo), &rf)
  28900. var psn_type string
  28901. for _, item := range rf {
  28902. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28903. psn_type = item.PsnType
  28904. }
  28905. }
  28906. 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)
  28907. var dat map[string]interface{}
  28908. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28909. fmt.Println(dat)
  28910. } else {
  28911. fmt.Println(err)
  28912. }
  28913. saveLog(result2, src_resquest, "2207", "结算")
  28914. userJSONBytes, _ := json.Marshal(dat)
  28915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28916. utils.ErrorLog("解析失败:%v", err)
  28917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28918. return
  28919. }
  28920. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28921. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28922. var cert_no string
  28923. var card_sn string
  28924. if his.IdCardType == 1 {
  28925. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28926. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28927. //bas := strings.Split(psn_info.CardInfo, "|")
  28928. card_sn = ""
  28929. } else if his.IdCardType == 2 {
  28930. cert_no = his.IdCardNo
  28931. } else {
  28932. cert_no = psn_info.VerifyNumber
  28933. }
  28934. var rf []*ResultFive
  28935. json.Unmarshal([]byte(his.Iinfo), &rf)
  28936. var psn_type string
  28937. for _, item := range rf {
  28938. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28939. psn_type = item.PsnType
  28940. }
  28941. }
  28942. 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)
  28943. var dat map[string]interface{}
  28944. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28945. fmt.Println(dat)
  28946. } else {
  28947. fmt.Println(err)
  28948. }
  28949. saveLog(result2, src_resquest, "2207", "结算")
  28950. userJSONBytes, _ := json.Marshal(dat)
  28951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28952. utils.ErrorLog("解析失败:%v", err)
  28953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28954. return
  28955. }
  28956. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28957. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28958. if his.IdCardType == 1 {
  28959. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28960. bas := strings.Split(psn_info.CardInfo, "|")
  28961. cert_no = bas[2]
  28962. } else if his.IdCardType == 3 {
  28963. cert_no = his.Certno
  28964. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28965. } else if his.IdCardType == 4 {
  28966. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28967. cert_no = psn_info.VerifyNumber
  28968. psn_info.VerifyNumber = psn_info.VerifyNumber
  28969. } else {
  28970. cert_no = his.Certno
  28971. psn_info.VerifyNumber = his.Certno
  28972. }
  28973. var api string
  28974. var med_type string
  28975. if his.Insutype == "390" {
  28976. if reg_type == 992102 {
  28977. med_type = "992102"
  28978. }
  28979. if reg_type == 1104 {
  28980. med_type = "1104"
  28981. }
  28982. if reg_type == 1104 {
  28983. med_type = "1104"
  28984. }
  28985. if reg_type == 140104 {
  28986. med_type = "140104"
  28987. }
  28988. if reg_type == 140201 {
  28989. med_type = "140201"
  28990. }
  28991. if reg_type == 14 {
  28992. med_type = "14"
  28993. }
  28994. } else if his.Insutype == "310" {
  28995. if reg_type == 1104 {
  28996. med_type = "1104"
  28997. }
  28998. if reg_type == 992102 {
  28999. med_type = "992102"
  29000. }
  29001. if reg_type == 140104 {
  29002. med_type = "140104"
  29003. }
  29004. if reg_type == 140201 {
  29005. med_type = "140201"
  29006. }
  29007. if reg_type == 14 {
  29008. med_type = "14"
  29009. }
  29010. }
  29011. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29012. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29013. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29014. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29015. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29016. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29017. "&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
  29018. resp, requestErr := http.Get(api)
  29019. if requestErr != nil {
  29020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29021. return
  29022. }
  29023. body, ioErr := ioutil.ReadAll(resp.Body)
  29024. if ioErr != nil {
  29025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29027. return
  29028. }
  29029. var respJSON map[string]interface{}
  29030. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29033. return
  29034. }
  29035. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29036. if status == "0" {
  29037. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29038. c.ServeSuccessJSON(map[string]interface{}{
  29039. "failed_code": -10,
  29040. "msg": err_msg,
  29041. })
  29042. return
  29043. }
  29044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29045. result, _ := json.Marshal(respJSON)
  29046. fmt.Println("log")
  29047. fmt.Println(string(result))
  29048. if err := json.Unmarshal(result, &ahres); err != nil {
  29049. utils.ErrorLog("解析失败:%v", err)
  29050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29051. return
  29052. }
  29053. res.InfRefmsgid = ahres.InfRefmsgid
  29054. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29055. // 创建对应的Time类型
  29056. t := time.UnixMilli(timestamp)
  29057. // 格式化成指定的日期字符串
  29058. str := t.Format("2006-01-02 15:04:05")
  29059. res.Output.Setlinfo.SetlTime = str
  29060. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29061. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29062. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29063. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29064. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29065. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29066. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29067. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29068. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29069. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29070. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29071. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29072. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29073. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29074. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29075. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29076. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29077. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29078. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29079. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29080. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29081. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29082. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29083. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29084. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29085. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29086. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29087. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29088. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29089. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29090. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29091. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29092. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29093. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29094. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29095. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29096. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29097. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29098. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29099. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29100. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29101. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29102. res.Output.Setldetail = ahres.Output.Setldetail
  29103. res.ErrMsg = ahres.ErrMsg
  29104. res.Cainfo = ahres.Cainfo
  29105. res.WarnMsg = ahres.WarnMsg
  29106. res.Infcode = ahres.Infcode
  29107. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29108. res.Output.Setlinfo.ClrType = "11"
  29109. } else {
  29110. res.Output.Setlinfo.ClrType = "9903"
  29111. }
  29112. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29113. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29114. if his.IdCardType == 1 {
  29115. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29116. bas := strings.Split(psn_info.CardInfo, "|")
  29117. cert_no = bas[2]
  29118. } else if his.IdCardType == 3 {
  29119. cert_no = his.Certno
  29120. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  29121. } else if his.IdCardType == 4 {
  29122. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29123. cert_no = his.Certno
  29124. psn_info.VerifyNumber = psn_info.VerifyNumber
  29125. } else {
  29126. cert_no = his.Certno
  29127. psn_info.VerifyNumber = his.Certno
  29128. }
  29129. var api string
  29130. var med_type string
  29131. if his.Insutype == "390" {
  29132. if reg_type == 1104 {
  29133. med_type = "1104"
  29134. }
  29135. if reg_type == 992102 {
  29136. med_type = "992102"
  29137. }
  29138. if reg_type == 140104 {
  29139. med_type = "140104"
  29140. }
  29141. if reg_type == 14 {
  29142. med_type = "14"
  29143. }
  29144. if reg_type == 140201 {
  29145. med_type = "140201"
  29146. }
  29147. } else if his.Insutype == "310" {
  29148. if reg_type == 1104 {
  29149. med_type = "1104"
  29150. }
  29151. if reg_type == 992102 {
  29152. med_type = "992102"
  29153. }
  29154. if reg_type == 14 {
  29155. med_type = "14"
  29156. }
  29157. if reg_type == 140104 {
  29158. med_type = "140104"
  29159. }
  29160. if reg_type == 140201 {
  29161. med_type = "140201"
  29162. }
  29163. }
  29164. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29165. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29166. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29167. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29168. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29169. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29170. "&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
  29171. resp, requestErr := http.Get(api)
  29172. if requestErr != nil {
  29173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29174. return
  29175. }
  29176. body, ioErr := ioutil.ReadAll(resp.Body)
  29177. if ioErr != nil {
  29178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29180. return
  29181. }
  29182. var respJSON map[string]interface{}
  29183. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29186. return
  29187. }
  29188. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29189. if status == "0" {
  29190. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29191. c.ServeSuccessJSON(map[string]interface{}{
  29192. "failed_code": -10,
  29193. "msg": err_msg,
  29194. })
  29195. return
  29196. }
  29197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29198. result, _ := json.Marshal(respJSON)
  29199. fmt.Println("log")
  29200. fmt.Println(string(result))
  29201. if err := json.Unmarshal(result, &ahres); err != nil {
  29202. utils.ErrorLog("解析失败:%v", err)
  29203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29204. return
  29205. }
  29206. res.InfRefmsgid = ahres.InfRefmsgid
  29207. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29208. // 创建对应的Time类型
  29209. t := time.UnixMilli(timestamp)
  29210. // 格式化成指定的日期字符串
  29211. str := t.Format("2006-01-02 15:04:05")
  29212. res.Output.Setlinfo.SetlTime = str
  29213. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29214. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29215. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29216. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29217. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29218. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29219. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29220. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29221. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29222. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29223. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29224. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29225. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29226. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29227. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29228. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29229. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29230. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29231. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29232. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29233. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29234. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29235. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29236. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29237. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29238. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29239. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29240. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29241. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29242. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29243. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29244. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29245. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29246. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29247. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29248. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29249. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29250. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29251. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29252. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29253. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29254. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29255. res.Output.Setldetail = ahres.Output.Setldetail
  29256. res.ErrMsg = ahres.ErrMsg
  29257. res.Cainfo = ahres.Cainfo
  29258. res.WarnMsg = ahres.WarnMsg
  29259. res.Infcode = ahres.Infcode
  29260. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  29261. res.Output.Setlinfo.ClrType = "11"
  29262. } else {
  29263. res.Output.Setlinfo.ClrType = "9903"
  29264. }
  29265. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29266. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29267. var cert_no string
  29268. if his.IdCardType == 1 {
  29269. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  29270. } else if his.IdCardType == 2 {
  29271. cert_no = his.IdCardNo
  29272. } else {
  29273. cert_no = psn_info.VerifyNumber
  29274. }
  29275. 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, "")
  29276. var dat map[string]interface{}
  29277. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29278. fmt.Println(dat)
  29279. } else {
  29280. fmt.Println(err)
  29281. }
  29282. saveLog(result2, src_resquest, "2207", "结算")
  29283. userJSONBytes, _ := json.Marshal(dat)
  29284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29285. utils.ErrorLog("解析失败:%v", err)
  29286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29287. return
  29288. }
  29289. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29290. psn_info, _ := service.GetPsnByPatientId(id)
  29291. var verify_number string
  29292. if psn_info.IdCardType == 4 {
  29293. verify_number = psn_info.VerifyNumber
  29294. } else if psn_info.IdCardType == 1 {
  29295. bas := strings.Split(psn_info.CardInfo, "|")
  29296. cardNumber := bas[2]
  29297. verify_number = cardNumber
  29298. } else {
  29299. verify_number = psn_info.Certno
  29300. psn_info.IdCardType = 2
  29301. }
  29302. var api string
  29303. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29304. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29305. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29306. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29307. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29308. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29309. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29310. resp, requestErr := http.Get(api)
  29311. if requestErr != nil {
  29312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29313. return
  29314. }
  29315. body, ioErr := ioutil.ReadAll(resp.Body)
  29316. if ioErr != nil {
  29317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29319. return
  29320. }
  29321. var respJSON map[string]interface{}
  29322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29325. return
  29326. }
  29327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29328. result, _ := json.Marshal(respJSON)
  29329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29330. utils.ErrorLog("解析失败:%v", err)
  29331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29332. return
  29333. }
  29334. } else {
  29335. var src_resquest string
  29336. if miConfig.Code == "H15049901371" {
  29337. //赤峰地区国家医保医疗类别
  29338. //职工透析:医疗类别选特殊情况门诊990502
  29339. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29340. var med_type string
  29341. if his.Insutype == "390" {
  29342. if reg_type == 14 {
  29343. med_type = "9933"
  29344. } else if reg_type == 11 {
  29345. med_type = "11"
  29346. }
  29347. } else if his.Insutype == "310" {
  29348. if reg_type == 14 {
  29349. med_type = "990502"
  29350. } else if reg_type == 11 {
  29351. med_type = "11"
  29352. }
  29353. }
  29354. 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)
  29355. } else {
  29356. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  29357. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29358. if result3101.Infcode == 0 {
  29359. if len(result3101.Output.Result) > 0 {
  29360. c.ServeSuccessJSON(map[string]interface{}{
  29361. "failed_code": -10,
  29362. "failed_type": 100,
  29363. "warm_type": 2,
  29364. "msg": result3101,
  29365. })
  29366. return
  29367. }
  29368. } else {
  29369. c.ServeSuccessJSON(map[string]interface{}{
  29370. "failed_code": -10,
  29371. "msg": result3101.ErrMsg,
  29372. })
  29373. return
  29374. }
  29375. }
  29376. if his.IdCardType == 4 {
  29377. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29378. token := psn_info.VerifyNumber
  29379. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  29380. } else {
  29381. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  29382. }
  29383. }
  29384. var dat map[string]interface{}
  29385. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29386. fmt.Println(dat)
  29387. } else {
  29388. fmt.Println(err)
  29389. }
  29390. saveLog(result2, src_resquest, "2207", "结算")
  29391. userJSONBytes, _ := json.Marshal(dat)
  29392. if miConfig.Code == "H15049901371" {
  29393. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29394. utils.ErrorLog("解析失败:%v", err)
  29395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29396. return
  29397. }
  29398. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29399. res.Output = resSeven10265.Output
  29400. res.ErrMsg = resSeven10265.ErrMsg
  29401. res.Cainfo = resSeven10265.Cainfo
  29402. res.WarnMsg = resSeven10265.WarnMsg
  29403. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29404. res.Infcode = infocode
  29405. } else {
  29406. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29407. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29408. utils.ErrorLog("解析失败:%v", err)
  29409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29410. return
  29411. }
  29412. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29413. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29414. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29415. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29416. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29417. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29418. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29419. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29420. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29421. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29422. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29423. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29424. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29425. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29426. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29427. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29428. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29429. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29430. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29431. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29432. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29433. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29434. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29435. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29436. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29437. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29438. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29439. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29440. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29441. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29442. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29443. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29444. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29445. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29446. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29447. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29448. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29449. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29450. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29451. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29452. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29453. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29454. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29455. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29456. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29457. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29458. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29459. res.Cainfo = gzresSeven10265Two.Cainfo
  29460. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29461. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29462. //res.Infcode = infocode
  29463. } else {
  29464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29465. utils.ErrorLog("解析失败:%v", err)
  29466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29467. return
  29468. }
  29469. }
  29470. }
  29471. }
  29472. if res.Infcode != 0 {
  29473. errlog := &models.HisOrderError{
  29474. UserOrgId: adminUser.CurrentOrgId,
  29475. Ctime: time.Now().Unix(),
  29476. Mtime: time.Now().Unix(),
  29477. Number: chrg_bchno,
  29478. ErrMsg: res.ErrMsg,
  29479. Status: 1,
  29480. PatientId: id,
  29481. RecordTime: recordDateTime,
  29482. Stage: 6,
  29483. }
  29484. service.CreateErrMsgLog(errlog)
  29485. c.ServeSuccessJSON(map[string]interface{}{
  29486. "failed_code": -10,
  29487. "msg": res.ErrMsg,
  29488. })
  29489. return
  29490. } else {
  29491. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29492. order.OrderStatus = 2
  29493. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29494. order.SetlId = res.Output.Setlinfo.SetlID
  29495. order.PsnNo = res.Output.Setlinfo.PsnNo
  29496. order.PsnName = res.Output.Setlinfo.PsnName
  29497. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29498. order.Certno = res.Output.Setlinfo.Certno
  29499. order.Gend = res.Output.Setlinfo.Gend
  29500. order.Naty = res.Output.Setlinfo.Naty
  29501. order.Age = res.Output.Setlinfo.Age
  29502. order.Insutype = res.Output.Setlinfo.Insutype
  29503. order.PsnType = res.Output.Setlinfo.PsnType
  29504. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29505. order.SetlTime = res.Output.Setlinfo.SetlTime
  29506. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29507. order.PayWays = pay_ways
  29508. order.AcctUsedFlag = acct_used_flag
  29509. order.WechatPay = wechat_pay
  29510. order.AliPay = ali_pay
  29511. order.JifenPay = jifen_pay
  29512. order.BandCardPay = band_card_pay
  29513. order.CashPay = cash_pay
  29514. order.OthDesc = oth_desc
  29515. //order.MedType = res.Output.Setlinfo.MedType
  29516. if reg_type == 1112 {
  29517. order.MedType = "1112"
  29518. }
  29519. if reg_type == 1111 {
  29520. order.MedType = "1111"
  29521. }
  29522. order.ClrType = res.Output.Setlinfo.ClrType
  29523. if adminUser.CurrentOrgId == 10480 {
  29524. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29525. order.ClrType = "11"
  29526. } else {
  29527. order.ClrType = "9903"
  29528. }
  29529. }
  29530. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29531. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29532. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29533. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29534. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29535. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29536. order.HifpPay = res.Output.Setlinfo.HifpPay
  29537. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29538. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29539. order.HifesPay = res.Output.Setlinfo.HifesPay
  29540. order.HifobPay = res.Output.Setlinfo.HifobPay
  29541. order.MafPay = res.Output.Setlinfo.MafPay
  29542. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29543. order.OthPay = res.Output.Setlinfo.OthPay
  29544. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29545. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29546. order.AcctPay = res.Output.Setlinfo.AcctPay
  29547. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29548. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29549. order.Balc = res.Output.Setlinfo.Balc
  29550. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29551. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29552. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29553. order.ClrWay = res.Output.Setlinfo.ClrWay
  29554. order.Creator = order.Creator
  29555. order.Modify = roles.AdminUserId
  29556. order.RequestLog = src_resquest
  29557. order.Diagnosis = diagnosis_id
  29558. order.FaPiaoNumber = fapiao_number
  29559. order.FaPiaoCode = fapiao_code
  29560. order.PayCardNo = pay_card_no
  29561. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29562. detailStr := string(setlDetail)
  29563. order.SetlDetail = detailStr
  29564. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29565. err = service.UpDateOrder(order)
  29566. if err == nil {
  29567. //判断是否使用了押金
  29568. if dec_way == "true" {
  29569. tmpstring := strconv.FormatInt(order.ID, 10)
  29570. //扣押金
  29571. order.Decimal = decimal
  29572. service.UpDateOrder(order)
  29573. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29574. if errmsg != nil {
  29575. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29576. return
  29577. }
  29578. }
  29579. c.ServeSuccessJSON(map[string]interface{}{
  29580. "msg": "结算成功",
  29581. })
  29582. } else {
  29583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29584. return
  29585. }
  29586. }
  29587. }
  29588. }
  29589. }
  29590. // 上传明细-预结算-
  29591. func (c *HisApiController) GetPreUploadInfo() {
  29592. id, _ := c.GetInt64("id")
  29593. record_time := c.GetString("record_time")
  29594. his_patient_id, _ := c.GetInt64("his_patient_id")
  29595. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29596. admin_user_id, _ := c.GetInt64("admin_user_id")
  29597. diagnosis_id := c.GetString("diagnosis")
  29598. sick_type, _ := c.GetInt64("sick_type")
  29599. reg_type, _ := c.GetInt64("p_type")
  29600. begin_time := c.GetString("begin_time")
  29601. acct_used_flag := c.GetString("acct_used_flag")
  29602. id_str := c.GetString("ids")
  29603. ids_arr := strings.Split(id_str, ",")
  29604. timeLayout := "2006-01-02"
  29605. loc, _ := time.LoadLocation("Local")
  29606. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29607. if err != nil {
  29608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29609. return
  29610. }
  29611. recordDateTime := theTime.Unix()
  29612. adminUser := c.GetAdminUserInfo()
  29613. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29614. var config []*models.HisXtDiagnoseConfig
  29615. for _, item := range diagnosis_ids {
  29616. id, _ := strconv.ParseInt(item, 10, 64)
  29617. if id > 0 {
  29618. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29619. config = append(config, &diagnosisConfig)
  29620. }
  29621. }
  29622. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29623. sickConfig, _ := service.FindSickById(sick_type)
  29624. var prescriptions []*models.HisPrescription
  29625. var start_time int64
  29626. var end_time int64
  29627. var isSuccess bool = true
  29628. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29629. fmt.Println(his_patient_id)
  29630. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29631. timestamp := time.Now().Unix()
  29632. tempTime := time.Unix(timestamp, 0)
  29633. timeFormat := tempTime.Format("20060102150405")
  29634. chrgBchno := rand.Intn(100000) + 10000
  29635. new_chrg_bchno := ""
  29636. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29637. new_chrg_bchno = chrg_bchno
  29638. if adminUser.CurrentOrgId == 10265 {
  29639. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29640. new_chrg_bchno = "0000"
  29641. }
  29642. }
  29643. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29644. var patientPrescription models.HisPrescriptionInfo
  29645. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29646. if patientPrescription.ID == 0 {
  29647. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29648. }
  29649. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29650. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29651. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29652. strconv.FormatInt(his.PatientId, 10)
  29653. var res2406 Result2406
  29654. //安徽单病种处理
  29655. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29656. data := make(map[string]interface{})
  29657. client := &http.Client{}
  29658. data["psn_no"] = his.PsnNo
  29659. data["mdtrt_id"] = his.Number
  29660. data["operator"] = roles.UserName
  29661. data["cert_no"] = his.IdCardNo
  29662. data["org_name"] = miConfig.OrgName
  29663. data["psn_name"] = his.Name
  29664. data["ipt_otp_no"] = his.IptOtpNo
  29665. data["ipt_psn_sp_flag_type"] = "0901"
  29666. data["ipt_psn_sp_flag"] = "1"
  29667. data["fixmedins_code"] = miConfig.Code
  29668. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29669. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29670. data["url"] = miConfig.Url
  29671. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29672. bytesData, _ := json.Marshal(data)
  29673. var req *http.Request
  29674. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29675. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29676. resp, _ := client.Do(req)
  29677. defer resp.Body.Close()
  29678. body, ioErr := ioutil.ReadAll(resp.Body)
  29679. if ioErr != nil {
  29680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29682. return
  29683. }
  29684. var respJSON map[string]interface{}
  29685. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29688. return
  29689. }
  29690. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29691. if status == "0" {
  29692. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29693. c.ServeSuccessJSON(map[string]interface{}{
  29694. "failed_code": -10,
  29695. "msg": err_msg,
  29696. })
  29697. return
  29698. }
  29699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29700. userJSONBytes, _ := json.Marshal(respJSON)
  29701. fmt.Println("log")
  29702. fmt.Println(string(userJSONBytes))
  29703. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29704. utils.ErrorLog("解析失败:%v", err)
  29705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29706. return
  29707. }
  29708. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29709. data := make(map[string]interface{})
  29710. client := &http.Client{}
  29711. data["psn_no"] = his.PsnNo
  29712. data["mdtrt_id"] = his.Number
  29713. data["operator"] = roles.UserName
  29714. data["cert_no"] = his.IdCardNo
  29715. data["org_name"] = miConfig.OrgName
  29716. data["psn_name"] = his.Name
  29717. data["ipt_otp_no"] = his.IptOtpNo
  29718. data["ipt_psn_sp_flag_type"] = "0901"
  29719. data["ipt_psn_sp_flag"] = "1"
  29720. data["fixmedins_code"] = miConfig.Code
  29721. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29722. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29723. data["url"] = miConfig.Url
  29724. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29725. bytesData, _ := json.Marshal(data)
  29726. var req *http.Request
  29727. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29728. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29729. resp, _ := client.Do(req)
  29730. defer resp.Body.Close()
  29731. body, ioErr := ioutil.ReadAll(resp.Body)
  29732. if ioErr != nil {
  29733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29735. return
  29736. }
  29737. var respJSON map[string]interface{}
  29738. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29741. return
  29742. }
  29743. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29744. if status == "0" {
  29745. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29746. c.ServeSuccessJSON(map[string]interface{}{
  29747. "failed_code": -10,
  29748. "msg": err_msg,
  29749. })
  29750. return
  29751. }
  29752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29753. userJSONBytes, _ := json.Marshal(respJSON)
  29754. fmt.Println("log")
  29755. fmt.Println(string(userJSONBytes))
  29756. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29757. utils.ErrorLog("解析失败:%v", err)
  29758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29759. return
  29760. }
  29761. }
  29762. if res2406.Infcode != 0 {
  29763. adminUser := c.GetAdminUserInfo()
  29764. errlog := &models.HisOrderError{
  29765. UserOrgId: adminUser.CurrentOrgId,
  29766. Ctime: time.Now().Unix(),
  29767. Mtime: time.Now().Unix(),
  29768. ErrMsg: res2406.ErrMsg,
  29769. Status: 1,
  29770. PatientId: id,
  29771. RecordTime: recordDateTime,
  29772. Stage: 3,
  29773. }
  29774. service.CreateErrMsgLog(errlog)
  29775. c.ServeSuccessJSON(map[string]interface{}{
  29776. "failed_code": -10,
  29777. "msg": res2406.ErrMsg,
  29778. })
  29779. return
  29780. }
  29781. var res2 ResultSix
  29782. var res3 GZResultSix
  29783. var resSix10265 ResultSix10265
  29784. //var time_stamp string
  29785. if miConfig.MdtrtareaAdmvs == "421300" {
  29786. data := make(map[string]interface{})
  29787. client := &http.Client{}
  29788. data["psn_no"] = his.PsnNo
  29789. data["mdtrt_id"] = his.Number
  29790. data["department"] = department.Name
  29791. data["org_name"] = miConfig.OrgName
  29792. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29793. data["doctor_id"] = doctor_info.DoctorNumber
  29794. data["doctor_name"] = roles.UserName
  29795. data["fixmedins_code"] = miConfig.Code
  29796. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29797. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29798. data["secret_key"] = miConfig.SecretKey
  29799. data["sick_code"] = sickConfig.CountryCode
  29800. data["sick_name"] = sickConfig.ClassName
  29801. data["begin_time"] = begin_time
  29802. data["dept"] = strconv.FormatInt(department.ID, 10)
  29803. data["config"] = config
  29804. data["opter"] = roles.UserName
  29805. fmt.Println(data)
  29806. bytesData, _ := json.Marshal(data)
  29807. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29808. resp, _ := client.Do(req)
  29809. defer resp.Body.Close()
  29810. body, ioErr := ioutil.ReadAll(resp.Body)
  29811. if ioErr != nil {
  29812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29814. return
  29815. }
  29816. var respJSON map[string]interface{}
  29817. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29820. return
  29821. }
  29822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29823. userJSONBytes, _ := json.Marshal(respJSON)
  29824. fmt.Println("log")
  29825. fmt.Println(string(userJSONBytes))
  29826. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29827. utils.ErrorLog("解析失败:%v", err)
  29828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29829. return
  29830. }
  29831. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29832. data := make(map[string]interface{})
  29833. client := &http.Client{}
  29834. data["psn_no"] = his.PsnNo
  29835. data["mdtrt_id"] = his.Number
  29836. data["department"] = department.Name
  29837. data["org_name"] = miConfig.OrgName
  29838. if reg_type == 11 && his.Insutype == "390" {
  29839. data["med_type"] = "110104"
  29840. } else {
  29841. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29842. }
  29843. data["doctor_id"] = doctor_info.DoctorNumber
  29844. data["doctor_name"] = roles.UserName
  29845. data["fixmedins_code"] = miConfig.Code
  29846. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29847. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29848. data["secret_key"] = miConfig.SecretKey
  29849. data["sick_code"] = sickConfig.CountryCode
  29850. data["sick_name"] = sickConfig.ClassName
  29851. data["begin_time"] = begin_time
  29852. data["dept"] = strconv.FormatInt(department.ID, 10)
  29853. data["config"] = config
  29854. data["opter"] = roles.UserName
  29855. fmt.Println(data)
  29856. bytesData, _ := json.Marshal(data)
  29857. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29858. resp, _ := client.Do(req)
  29859. defer resp.Body.Close()
  29860. body, ioErr := ioutil.ReadAll(resp.Body)
  29861. if ioErr != nil {
  29862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29864. return
  29865. }
  29866. var respJSON map[string]interface{}
  29867. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29870. return
  29871. }
  29872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29873. userJSONBytes, _ := json.Marshal(respJSON)
  29874. fmt.Println("log")
  29875. fmt.Println(string(userJSONBytes))
  29876. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29877. utils.ErrorLog("解析失败:%v", err)
  29878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29879. return
  29880. }
  29881. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29882. data := make(map[string]interface{})
  29883. client := &http.Client{}
  29884. data["psn_no"] = his.PsnNo
  29885. data["mdtrt_id"] = his.Number
  29886. data["department"] = department.Name
  29887. data["org_name"] = miConfig.OrgName
  29888. if reg_type == 11 && his.Insutype == "390" {
  29889. data["med_type"] = "110104"
  29890. } else {
  29891. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29892. }
  29893. data["doctor_id"] = doctor_info.DoctorNumber
  29894. data["doctor_name"] = roles.UserName
  29895. data["fixmedins_code"] = miConfig.Code
  29896. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29897. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29898. data["secret_key"] = miConfig.SecretKey
  29899. data["sick_code"] = sickConfig.CountryCode
  29900. data["sick_name"] = sickConfig.ClassName
  29901. data["begin_time"] = begin_time
  29902. data["dept"] = strconv.FormatInt(department.ID, 10)
  29903. data["config"] = config
  29904. data["opter"] = roles.UserName
  29905. fmt.Println(data)
  29906. bytesData, _ := json.Marshal(data)
  29907. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29908. resp, _ := client.Do(req)
  29909. defer resp.Body.Close()
  29910. body, ioErr := ioutil.ReadAll(resp.Body)
  29911. if ioErr != nil {
  29912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29914. return
  29915. }
  29916. var respJSON map[string]interface{}
  29917. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29920. return
  29921. }
  29922. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29923. userJSONBytes, _ := json.Marshal(respJSON)
  29924. fmt.Println("log")
  29925. fmt.Println(string(userJSONBytes))
  29926. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29927. utils.ErrorLog("解析失败:%v", err)
  29928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29929. return
  29930. }
  29931. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29932. data := make(map[string]interface{})
  29933. client := &http.Client{}
  29934. data["psn_no"] = his.PsnNo
  29935. data["mdtrt_id"] = his.Number
  29936. data["department"] = department.Name
  29937. data["org_name"] = miConfig.OrgName
  29938. if reg_type == 11 && his.Insutype == "390" {
  29939. data["med_type"] = "110104"
  29940. } else {
  29941. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29942. }
  29943. data["doctor_id"] = doctor_info.DoctorNumber
  29944. data["doctor_name"] = roles.UserName
  29945. data["fixmedins_code"] = miConfig.Code
  29946. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29947. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29948. data["secret_key"] = miConfig.SecretKey
  29949. data["sick_code"] = sickConfig.CountryCode
  29950. data["sick_name"] = sickConfig.ClassName
  29951. data["begin_time"] = begin_time
  29952. data["dept"] = strconv.FormatInt(department.ID, 10)
  29953. data["config"] = config
  29954. data["opter"] = roles.UserName
  29955. fmt.Println(data)
  29956. bytesData, _ := json.Marshal(data)
  29957. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29958. resp, _ := client.Do(req)
  29959. defer resp.Body.Close()
  29960. body, ioErr := ioutil.ReadAll(resp.Body)
  29961. if ioErr != nil {
  29962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29964. return
  29965. }
  29966. var respJSON map[string]interface{}
  29967. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29970. return
  29971. }
  29972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29973. userJSONBytes, _ := json.Marshal(respJSON)
  29974. fmt.Println("log")
  29975. fmt.Println(string(userJSONBytes))
  29976. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29977. utils.ErrorLog("解析失败:%v", err)
  29978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29979. return
  29980. }
  29981. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29982. utils.ErrorLog("解析失败:%v", doctor_info)
  29983. data := make(map[string]interface{})
  29984. client := &http.Client{}
  29985. data["psn_no"] = his.PsnNo
  29986. data["mdtrt_id"] = his.Number
  29987. data["doctor"] = roles.UserName
  29988. data["department"] = department.Name
  29989. data["org_name"] = miConfig.OrgName
  29990. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29991. data["doctor_id"] = doctor_info.DoctorNumber
  29992. data["new_doctor_name"] = doctor_info.UserName
  29993. data["fixmedins_code"] = miConfig.Code
  29994. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29995. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29996. data["secret_key"] = miConfig.SecretKey
  29997. data["sick_code"] = sickConfig.CountryCode
  29998. data["sick_name"] = sickConfig.ClassName
  29999. data["url"] = miConfig.Url
  30000. data["ak"] = miConfig.AccessKey
  30001. data["begin_time"] = begin_time
  30002. data["cainfo"] = miConfig.Cainfo
  30003. data["dept"] = strconv.FormatInt(department.ID, 10)
  30004. data["config"] = config
  30005. bytesData, _ := json.Marshal(data)
  30006. var req *http.Request
  30007. if miConfig.MdtrtareaAdmvs == "320830" {
  30008. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  30009. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30010. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  30011. } else {
  30012. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  30013. }
  30014. resp, _ := client.Do(req)
  30015. defer resp.Body.Close()
  30016. body, ioErr := ioutil.ReadAll(resp.Body)
  30017. if ioErr != nil {
  30018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30020. return
  30021. }
  30022. var respJSON map[string]interface{}
  30023. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30026. return
  30027. }
  30028. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  30029. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  30030. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  30031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30032. userJSONBytes, _ := json.Marshal(respJSON)
  30033. fmt.Println("log")
  30034. fmt.Println(string(userJSONBytes))
  30035. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  30036. utils.ErrorLog("解析失败:%v", err)
  30037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30038. return
  30039. }
  30040. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30041. res2.Output = resSix10265.Output
  30042. res2.ErrMsg = resSix10265.ErrMsg
  30043. res2.Cainfo = resSix10265.Cainfo
  30044. res2.WarnMsg = resSix10265.WarnMsg
  30045. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30046. res2.Infcode = infocode
  30047. } else if miConfig.MdtrtareaAdmvs == "150404" {
  30048. data := make(map[string]interface{})
  30049. client := &http.Client{}
  30050. data["psn_no"] = his.PsnNo
  30051. data["mdtrt_id"] = his.Number
  30052. data["doctor"] = roles.UserName
  30053. data["department"] = department.Name
  30054. data["org_name"] = miConfig.OrgName
  30055. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30056. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  30057. data["fixmedins_code"] = miConfig.Code
  30058. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30059. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30060. data["secret_key"] = miConfig.SecretKey
  30061. data["sick_code"] = sickConfig.CountryCode
  30062. data["sick_name"] = sickConfig.ClassName
  30063. data["begin_time"] = begin_time
  30064. data["dept"] = strconv.FormatInt(department.ID, 10)
  30065. data["config"] = config
  30066. //data["url"] = miConfig.Url
  30067. //data["ak"] = miConfig.AccessKey
  30068. data["cainfo"] = miConfig.Cainfo
  30069. fmt.Println(data)
  30070. bytesData, _ := json.Marshal(data)
  30071. var req *http.Request
  30072. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  30073. resp, _ := client.Do(req)
  30074. defer resp.Body.Close()
  30075. body, ioErr := ioutil.ReadAll(resp.Body)
  30076. if ioErr != nil {
  30077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30079. return
  30080. }
  30081. var respJSON map[string]interface{}
  30082. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30085. return
  30086. }
  30087. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  30088. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  30089. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  30090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30091. userJSONBytes, _ := json.Marshal(respJSON)
  30092. fmt.Println("log")
  30093. fmt.Println(string(userJSONBytes))
  30094. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  30095. utils.ErrorLog("解析失败:%v", err)
  30096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30097. return
  30098. }
  30099. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30100. res2.Output = resSix10265.Output
  30101. res2.ErrMsg = resSix10265.ErrMsg
  30102. res2.Cainfo = resSix10265.Cainfo
  30103. res2.WarnMsg = resSix10265.WarnMsg
  30104. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30105. res2.Infcode = infocode
  30106. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30107. 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)
  30108. saveLog(result, requestLog, "2203", "上传就诊信息")
  30109. var respJSON2 map[string]interface{}
  30110. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30113. return
  30114. }
  30115. userJSONBytes2, _ := json.Marshal(respJSON2)
  30116. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30117. utils.ErrorLog("解析失败:%v", err)
  30118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30119. return
  30120. }
  30121. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30122. var result string
  30123. var requestLog string
  30124. 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, "")
  30125. saveLog(result, requestLog, "2203", "上传就诊信息")
  30126. var respJSON2 map[string]interface{}
  30127. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30130. return
  30131. }
  30132. userJSONBytes2, _ := json.Marshal(respJSON2)
  30133. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30134. utils.ErrorLog("解析失败:%v", err)
  30135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30136. return
  30137. }
  30138. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30139. var result string
  30140. var requestLog string
  30141. 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, "")
  30142. saveLog(result, requestLog, "2203", "上传就诊信息")
  30143. var respJSON2 map[string]interface{}
  30144. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30147. return
  30148. }
  30149. userJSONBytes2, _ := json.Marshal(respJSON2)
  30150. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30151. utils.ErrorLog("解析失败:%v", err)
  30152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30153. return
  30154. }
  30155. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30156. var result string
  30157. var requestLog string
  30158. 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, "")
  30159. saveLog(result, requestLog, "2203", "上传就诊信息")
  30160. var respJSON2 map[string]interface{}
  30161. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30164. return
  30165. }
  30166. userJSONBytes2, _ := json.Marshal(respJSON2)
  30167. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30168. utils.ErrorLog("解析失败:%v", err)
  30169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30170. return
  30171. }
  30172. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30173. data := make(map[string]interface{})
  30174. client := &http.Client{}
  30175. data["psn_no"] = his.PsnNo
  30176. data["mdtrt_id"] = his.Number
  30177. data["operator"] = roles.UserName
  30178. data["department"] = department.Name
  30179. data["org_name"] = miConfig.OrgName
  30180. var med_type string
  30181. if his.Insutype == "390" {
  30182. if reg_type == 992102 {
  30183. med_type = "992102"
  30184. data["sick_code"] = "ZDZ940"
  30185. data["sick_name"] = "慢性肾衰竭"
  30186. }
  30187. if reg_type == 140104 {
  30188. med_type = "140104"
  30189. data["sick_code"] = sickConfig.CountryCode
  30190. data["sick_name"] = sickConfig.ClassName
  30191. }
  30192. if reg_type == 14 {
  30193. med_type = "140104"
  30194. data["sick_code"] = sickConfig.CountryCode
  30195. data["sick_name"] = sickConfig.ClassName
  30196. }
  30197. if reg_type == 1104 {
  30198. med_type = "1104"
  30199. data["sick_code"] = sickConfig.CountryCode
  30200. data["sick_name"] = sickConfig.ClassName
  30201. }
  30202. } else if his.Insutype == "310" {
  30203. if reg_type == 992102 {
  30204. med_type = "992102"
  30205. data["sick_code"] = "ZDZ940"
  30206. data["sick_name"] = "慢性肾衰竭"
  30207. }
  30208. if reg_type == 140104 {
  30209. med_type = "140104"
  30210. data["sick_code"] = sickConfig.CountryCode
  30211. data["sick_name"] = sickConfig.ClassName
  30212. }
  30213. if reg_type == 14 {
  30214. med_type = "14"
  30215. data["sick_code"] = sickConfig.CountryCode
  30216. data["sick_name"] = sickConfig.ClassName
  30217. }
  30218. if reg_type == 1104 {
  30219. med_type = "1104"
  30220. data["sick_code"] = sickConfig.CountryCode
  30221. data["sick_name"] = sickConfig.ClassName
  30222. }
  30223. }
  30224. data["med_type"] = med_type
  30225. data["doctor_number"] = doctor_info.DoctorNumber
  30226. data["doctor_name"] = doctor_info.UserName
  30227. data["fixmedins_code"] = miConfig.Code
  30228. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30229. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30230. data["secret_key"] = miConfig.SecretKey
  30231. data["begin_time"] = begin_time
  30232. data["dept"] = strconv.FormatInt(department.ID, 10)
  30233. data["config"] = config
  30234. data["url"] = miConfig.Url
  30235. data["ak"] = miConfig.AccessKey
  30236. data["cainfo"] = miConfig.Cainfo
  30237. bytesData, _ := json.Marshal(data)
  30238. var req *http.Request
  30239. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30240. resp, _ := client.Do(req)
  30241. defer resp.Body.Close()
  30242. body, ioErr := ioutil.ReadAll(resp.Body)
  30243. if ioErr != nil {
  30244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30246. return
  30247. }
  30248. var respJSON map[string]interface{}
  30249. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30252. return
  30253. }
  30254. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30255. if status == "0" {
  30256. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30257. c.ServeSuccessJSON(map[string]interface{}{
  30258. "failed_code": -10,
  30259. "msg": err_msg,
  30260. })
  30261. return
  30262. }
  30263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30264. userJSONBytes, _ := json.Marshal(respJSON)
  30265. fmt.Println("log")
  30266. fmt.Println(string(userJSONBytes))
  30267. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30268. utils.ErrorLog("解析失败:%v", err)
  30269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30270. return
  30271. }
  30272. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30273. data := make(map[string]interface{})
  30274. client := &http.Client{}
  30275. data["psn_no"] = his.PsnNo
  30276. data["mdtrt_id"] = his.Number
  30277. data["operator"] = roles.UserName
  30278. data["department"] = department.Name
  30279. data["org_name"] = miConfig.OrgName
  30280. var med_type string
  30281. if his.Insutype == "390" {
  30282. if reg_type == 992102 {
  30283. med_type = "992102"
  30284. data["sick_code"] = sickConfig.CountryCode
  30285. data["sick_name"] = sickConfig.ClassName
  30286. }
  30287. if reg_type == 140104 {
  30288. med_type = "140104"
  30289. data["sick_code"] = sickConfig.CountryCode
  30290. data["sick_name"] = sickConfig.ClassName
  30291. }
  30292. if reg_type == 140201 {
  30293. med_type = "140201"
  30294. data["sick_code"] = sickConfig.CountryCode
  30295. data["sick_name"] = sickConfig.ClassName
  30296. }
  30297. if reg_type == 14 {
  30298. med_type = "14"
  30299. data["sick_code"] = sickConfig.CountryCode
  30300. data["sick_name"] = sickConfig.ClassName
  30301. }
  30302. if reg_type == 11 {
  30303. med_type = "11"
  30304. data["sick_code"] = sickConfig.CountryCode
  30305. data["sick_name"] = sickConfig.ClassName
  30306. }
  30307. } else if his.Insutype == "310" {
  30308. if reg_type == 992102 {
  30309. med_type = "992102"
  30310. data["sick_code"] = sickConfig.CountryCode
  30311. data["sick_name"] = sickConfig.ClassName
  30312. }
  30313. if reg_type == 140104 {
  30314. med_type = "140104"
  30315. data["sick_code"] = sickConfig.CountryCode
  30316. data["sick_name"] = sickConfig.ClassName
  30317. }
  30318. if reg_type == 140201 {
  30319. med_type = "140201"
  30320. data["sick_code"] = sickConfig.CountryCode
  30321. data["sick_name"] = sickConfig.ClassName
  30322. }
  30323. if reg_type == 14 {
  30324. med_type = "14"
  30325. data["sick_code"] = sickConfig.CountryCode
  30326. data["sick_name"] = sickConfig.ClassName
  30327. }
  30328. if reg_type == 11 {
  30329. med_type = "11"
  30330. data["sick_code"] = sickConfig.CountryCode
  30331. data["sick_name"] = sickConfig.ClassName
  30332. }
  30333. }
  30334. data["med_type"] = med_type
  30335. data["doctor_number"] = doctor_info.DoctorNumber
  30336. data["doctor_name"] = doctor_info.UserName
  30337. data["fixmedins_code"] = miConfig.Code
  30338. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30339. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30340. data["secret_key"] = miConfig.SecretKey
  30341. data["begin_time"] = begin_time
  30342. data["dept"] = strconv.FormatInt(department.ID, 10)
  30343. data["config"] = config
  30344. data["url"] = miConfig.Url
  30345. data["ak"] = miConfig.AccessKey
  30346. data["cainfo"] = miConfig.Cainfo
  30347. bytesData, _ := json.Marshal(data)
  30348. var req *http.Request
  30349. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30350. resp, _ := client.Do(req)
  30351. defer resp.Body.Close()
  30352. body, ioErr := ioutil.ReadAll(resp.Body)
  30353. if ioErr != nil {
  30354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30356. return
  30357. }
  30358. var respJSON map[string]interface{}
  30359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30362. return
  30363. }
  30364. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30365. if status == "0" {
  30366. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30367. c.ServeSuccessJSON(map[string]interface{}{
  30368. "failed_code": -10,
  30369. "msg": err_msg,
  30370. })
  30371. return
  30372. }
  30373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30374. userJSONBytes, _ := json.Marshal(respJSON)
  30375. fmt.Println("log")
  30376. fmt.Println(string(userJSONBytes))
  30377. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30378. utils.ErrorLog("解析失败:%v", err)
  30379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30380. return
  30381. }
  30382. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30383. var result string
  30384. var requestLog string
  30385. 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, "", begin_time)
  30386. saveLog(result, requestLog, "2203", "上传就诊信息")
  30387. var respJSON2 map[string]interface{}
  30388. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30391. return
  30392. }
  30393. userJSONBytes2, _ := json.Marshal(respJSON2)
  30394. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30395. utils.ErrorLog("解析失败:%v", err)
  30396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30397. return
  30398. }
  30399. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30400. data := make(map[string]interface{})
  30401. client := &http.Client{}
  30402. data["psn_no"] = his.PsnNo
  30403. data["mdtrt_id"] = his.Number
  30404. data["doctor"] = roles.UserName
  30405. data["department"] = department.Name
  30406. data["org_name"] = miConfig.OrgName
  30407. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30408. data["doctor_id"] = doctor_info.DoctorNumber
  30409. data["fixmedins_code"] = miConfig.Code
  30410. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30411. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30412. data["secret_key"] = miConfig.SecretKey
  30413. data["sick_code"] = sickConfig.CountryCode
  30414. data["sick_name"] = sickConfig.ClassName
  30415. data["begin_time"] = begin_time
  30416. data["new_doctor_name"] = doctor_info.UserName
  30417. data["dept"] = strconv.FormatInt(department.ID, 10)
  30418. data["config"] = config
  30419. bytesData, _ := json.Marshal(data)
  30420. var req *http.Request
  30421. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30422. resp, _ := client.Do(req)
  30423. defer resp.Body.Close()
  30424. body, ioErr := ioutil.ReadAll(resp.Body)
  30425. if ioErr != nil {
  30426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30428. return
  30429. }
  30430. var respJSON map[string]interface{}
  30431. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30434. return
  30435. }
  30436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30437. userJSONBytes, _ := json.Marshal(respJSON)
  30438. fmt.Println("log")
  30439. fmt.Println(string(userJSONBytes))
  30440. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30441. utils.ErrorLog("解析失败:%v", err)
  30442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30443. return
  30444. }
  30445. } else {
  30446. var result string
  30447. var requestLog string
  30448. if miConfig.MdtrtareaAdmvs == "440781" { //
  30449. 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)
  30450. } else {
  30451. if miConfig.Code == "H15049901371" {
  30452. //赤峰地区国家医保医疗类别
  30453. //职工透析:医疗类别选特殊情况门诊990502
  30454. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30455. var med_type string
  30456. if his.Insutype == "390" {
  30457. if reg_type == 14 {
  30458. med_type = "9933"
  30459. } else if reg_type == 11 {
  30460. med_type = "11"
  30461. }
  30462. } else if his.Insutype == "310" {
  30463. if reg_type == 14 {
  30464. med_type = "990502"
  30465. } else if reg_type == 11 {
  30466. med_type = "11"
  30467. }
  30468. }
  30469. 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)
  30470. } else {
  30471. 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)
  30472. }
  30473. saveLog(result, requestLog, "2203", "上传就诊信息")
  30474. var respJSON2 map[string]interface{}
  30475. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30478. return
  30479. }
  30480. userJSONBytes2, _ := json.Marshal(respJSON2)
  30481. if miConfig.Code == "H15049901371" {
  30482. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30483. utils.ErrorLog("解析失败:%v", err)
  30484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30485. return
  30486. }
  30487. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30488. res2.Output = resSix10265.Output
  30489. res2.ErrMsg = resSix10265.ErrMsg
  30490. res2.Cainfo = resSix10265.Cainfo
  30491. res2.WarnMsg = resSix10265.WarnMsg
  30492. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30493. res2.Infcode = infocode
  30494. } else {
  30495. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30496. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30497. utils.ErrorLog("解析失败:%v", err)
  30498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30499. return
  30500. }
  30501. res2.Infcode = res3.Infcode
  30502. } else {
  30503. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30504. utils.ErrorLog("解析失败:%v", err)
  30505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30506. return
  30507. }
  30508. }
  30509. }
  30510. }
  30511. }
  30512. if res2.Infcode == -1 {
  30513. adminUser := c.GetAdminUserInfo()
  30514. errlog := &models.HisOrderError{
  30515. UserOrgId: adminUser.CurrentOrgId,
  30516. Ctime: time.Now().Unix(),
  30517. Mtime: time.Now().Unix(),
  30518. ErrMsg: res2.ErrMsg,
  30519. Status: 1,
  30520. PatientId: id,
  30521. RecordTime: recordDateTime,
  30522. Stage: 3,
  30523. }
  30524. service.CreateErrMsgLog(errlog)
  30525. c.ServeSuccessJSON(map[string]interface{}{
  30526. "failed_code": -10,
  30527. "msg": res2.ErrMsg,
  30528. })
  30529. return
  30530. }
  30531. if res2.Infcode != 0 {
  30532. adminUser := c.GetAdminUserInfo()
  30533. errlog := &models.HisOrderError{
  30534. UserOrgId: adminUser.CurrentOrgId,
  30535. Ctime: time.Now().Unix(),
  30536. Mtime: time.Now().Unix(),
  30537. ErrMsg: res2.ErrMsg,
  30538. Status: 1,
  30539. PatientId: id,
  30540. RecordTime: recordDateTime,
  30541. Stage: 3,
  30542. }
  30543. service.CreateErrMsgLog(errlog)
  30544. c.ServeSuccessJSON(map[string]interface{}{
  30545. "failed_code": -10,
  30546. "msg": res2.ErrMsg,
  30547. })
  30548. return
  30549. } else {
  30550. his.Diagnosis = diagnosis_id
  30551. his.SickType = sickConfig.ID
  30552. his.PType = fmt.Sprintf("%d", reg_type)
  30553. service.UpdateHisPatientThree(&his)
  30554. data := make(map[string]interface{})
  30555. if settle_accounts_type == 1 { //日结
  30556. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30557. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30558. } else {
  30559. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30560. }
  30561. data["pre"] = prescriptions
  30562. } else { //月结
  30563. start_time_str := c.GetString("start_time")
  30564. end_time_str := c.GetString("end_time")
  30565. timeLayout := "2006-01-02"
  30566. loc, _ := time.LoadLocation("Local")
  30567. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30568. if err != nil {
  30569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30570. return
  30571. }
  30572. recordStartTime := theStartTime.Unix()
  30573. start_time = recordStartTime
  30574. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30575. if err != nil {
  30576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30577. return
  30578. }
  30579. recordEndTime := theEndTime.Unix()
  30580. end_time = recordEndTime
  30581. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30582. data["pre"] = prescriptions
  30583. }
  30584. client := &http.Client{}
  30585. data["psn_no"] = his.PsnNo
  30586. data["mdtrt_id"] = his.Number
  30587. data["chrg_bchno"] = new_chrg_bchno
  30588. data["org_name"] = miConfig.OrgName
  30589. data["doctor"] = doctor_info.UserName
  30590. data["doctor_id"] = doctor_info.DoctorNumber
  30591. data["dept"] = department.Name
  30592. data["fixmedins_code"] = miConfig.Code
  30593. data["opter"] = roles.UserName
  30594. data["dept_code"] = department.Number
  30595. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30596. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30597. data["secret_key"] = miConfig.SecretKey
  30598. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30599. data["url"] = miConfig.Url
  30600. data["ak"] = miConfig.AccessKey
  30601. data["new_doctor_name"] = patientPrescription.Doctor
  30602. if his.Insutype == "390" {
  30603. if reg_type == 992102 {
  30604. data["diag_code"] = "ZDZ940"
  30605. }
  30606. if reg_type == 140104 {
  30607. data["diag_code"] = sickConfig.CountryCode
  30608. }
  30609. if reg_type == 140201 {
  30610. data["diag_code"] = sickConfig.CountryCode
  30611. }
  30612. if reg_type == 14 {
  30613. data["diag_code"] = sickConfig.CountryCode
  30614. }
  30615. if reg_type == 1104 {
  30616. data["diag_code"] = sickConfig.CountryCode
  30617. }
  30618. } else if his.Insutype == "310" {
  30619. if miConfig.MdtrtareaAdmvs == "341203" {
  30620. if reg_type == 992102 {
  30621. data["diag_code"] = "ZDZ940"
  30622. }
  30623. if reg_type != 992102 {
  30624. data["diag_code"] = sickConfig.CountryCode
  30625. }
  30626. } else {
  30627. data["diag_code"] = sickConfig.CountryCode
  30628. }
  30629. }
  30630. data["cainfo"] = miConfig.Cainfo
  30631. data["opter"] = roles.UserName
  30632. var ids []int64
  30633. for _, item := range prescriptions {
  30634. ids = append(ids, item.ID)
  30635. }
  30636. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30637. if config.IsOpen == 1 { //对接了医保,走医保流程
  30638. var res ResultFour
  30639. var resFour10265 ResultFour10265
  30640. if miConfig.MdtrtareaAdmvs == "421300" {
  30641. bytesData, _ := json.Marshal(data)
  30642. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30643. resp, _ := client.Do(req)
  30644. defer resp.Body.Close()
  30645. body, ioErr := ioutil.ReadAll(resp.Body)
  30646. if ioErr != nil {
  30647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30649. return
  30650. }
  30651. var respJSON map[string]interface{}
  30652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30655. return
  30656. }
  30657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30658. userJSONBytes, _ := json.Marshal(respJSON)
  30659. fmt.Println("log")
  30660. fmt.Println(string(userJSONBytes))
  30661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30662. utils.ErrorLog("解析失败:%v", err)
  30663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30664. return
  30665. }
  30666. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30667. bytesData, _ := json.Marshal(data)
  30668. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30669. resp, _ := client.Do(req)
  30670. defer resp.Body.Close()
  30671. body, ioErr := ioutil.ReadAll(resp.Body)
  30672. if ioErr != nil {
  30673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30675. return
  30676. }
  30677. var respJSON map[string]interface{}
  30678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30681. return
  30682. }
  30683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30684. userJSONBytes, _ := json.Marshal(respJSON)
  30685. fmt.Println("log")
  30686. fmt.Println(string(userJSONBytes))
  30687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30688. utils.ErrorLog("解析失败:%v", err)
  30689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30690. return
  30691. }
  30692. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30693. bytesData, _ := json.Marshal(data)
  30694. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30695. resp, _ := client.Do(req)
  30696. defer resp.Body.Close()
  30697. body, ioErr := ioutil.ReadAll(resp.Body)
  30698. if ioErr != nil {
  30699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30701. return
  30702. }
  30703. var respJSON map[string]interface{}
  30704. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30707. return
  30708. }
  30709. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30710. userJSONBytes, _ := json.Marshal(respJSON)
  30711. fmt.Println("log")
  30712. fmt.Println(string(userJSONBytes))
  30713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30714. utils.ErrorLog("解析失败:%v", err)
  30715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30716. return
  30717. }
  30718. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30719. bytesData, _ := json.Marshal(data)
  30720. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30721. resp, _ := client.Do(req)
  30722. defer resp.Body.Close()
  30723. body, ioErr := ioutil.ReadAll(resp.Body)
  30724. if ioErr != nil {
  30725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30727. return
  30728. }
  30729. var respJSON map[string]interface{}
  30730. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30733. return
  30734. }
  30735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30736. userJSONBytes, _ := json.Marshal(respJSON)
  30737. fmt.Println("log")
  30738. fmt.Println(string(userJSONBytes))
  30739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30740. utils.ErrorLog("解析失败:%v", err)
  30741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30742. return
  30743. }
  30744. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30745. var result3101 Result3101
  30746. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30747. result3101.Infcode = "0"
  30748. if result3101.Infcode == "0" {
  30749. if len(result3101.Output.Result) > 0 {
  30750. var errMsgs []string
  30751. for _, item := range result3101.Output.Result {
  30752. errMsgs = append(errMsgs, item.VolaCont)
  30753. }
  30754. c.ServeSuccessJSON(map[string]interface{}{
  30755. "failed_code": -10,
  30756. "msg": errMsgs,
  30757. })
  30758. return
  30759. } else {
  30760. if miConfig.MdtrtareaAdmvs == "320921" {
  30761. data["doctor_id"] = doctor_info.DoctorNumber
  30762. } else {
  30763. data["doctor_id"] = doctor_info.DoctorNumber
  30764. }
  30765. bytesData, _ := json.Marshal(data)
  30766. var req *http.Request
  30767. if miConfig.MdtrtareaAdmvs == "320830" {
  30768. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30769. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30770. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30771. } else {
  30772. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30773. }
  30774. resp, _ := client.Do(req)
  30775. defer resp.Body.Close()
  30776. body, ioErr := ioutil.ReadAll(resp.Body)
  30777. if ioErr != nil {
  30778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30780. return
  30781. }
  30782. var respJSON map[string]interface{}
  30783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30786. return
  30787. }
  30788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30789. userJSONBytes, _ := json.Marshal(respJSON)
  30790. fmt.Println("log")
  30791. fmt.Println(string(userJSONBytes))
  30792. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30793. utils.ErrorLog("解析失败:%v", err)
  30794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30795. return
  30796. }
  30797. res.InfRefmsgid = resFour10265.InfRefmsgid
  30798. res.Output = resFour10265.Output
  30799. res.ErrMsg = resFour10265.ErrMsg
  30800. res.Cainfo = resFour10265.Cainfo
  30801. res.WarnMsg = resFour10265.WarnMsg
  30802. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30803. res.Infcode = infocode
  30804. }
  30805. }
  30806. } else if miConfig.MdtrtareaAdmvs == "150404" {
  30807. var pagesize int = 5
  30808. var start int = 1
  30809. var stop int
  30810. var pagecount int
  30811. var curpage int
  30812. data["doctor_id"] = doctor_info.DoctorNumber
  30813. var res2 ResultFour
  30814. //var result res.
  30815. //总页数,向上取整,注意除之前要先转换类型为float64
  30816. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30817. for curpage = 1; curpage <= pagecount; curpage++ {
  30818. if curpage == 1 {
  30819. start = 1
  30820. } else {
  30821. start = (curpage-1)*pagesize + 1
  30822. }
  30823. stop = curpage * pagesize
  30824. if stop > len(prescriptions) {
  30825. stop = len(prescriptions)
  30826. }
  30827. //var requestLog string
  30828. data["pre"] = prescriptions[start-1 : stop]
  30829. fmt.Println(data["pre"])
  30830. bytesData, _ := json.Marshal(data)
  30831. var req *http.Request
  30832. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30833. resp, _ := client.Do(req)
  30834. defer resp.Body.Close()
  30835. body, ioErr := ioutil.ReadAll(resp.Body)
  30836. if ioErr != nil {
  30837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30839. return
  30840. }
  30841. var respJSON map[string]interface{}
  30842. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30845. return
  30846. }
  30847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30848. userJSONBytes, _ := json.Marshal(respJSON)
  30849. fmt.Println("log")
  30850. fmt.Println(string(userJSONBytes))
  30851. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30852. utils.ErrorLog("解析失败:%v", err)
  30853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30854. return
  30855. }
  30856. res.InfRefmsgid = resFour10265.InfRefmsgid
  30857. res.Output = resFour10265.Output
  30858. res.ErrMsg = resFour10265.ErrMsg
  30859. res.Cainfo = resFour10265.Cainfo
  30860. res.WarnMsg = resFour10265.WarnMsg
  30861. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30862. res.Infcode = infocode
  30863. if infocode == 0 {
  30864. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30865. } else {
  30866. isSuccess = false
  30867. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30868. res.Infcode = -1
  30869. res.ErrMsg = resFour10265.ErrMsg
  30870. errlog := &models.HisOrderError{
  30871. UserOrgId: adminUser.CurrentOrgId,
  30872. Ctime: time.Now().Unix(),
  30873. Mtime: time.Now().Unix(),
  30874. Number: chrg_bchno,
  30875. ErrMsg: "",
  30876. Status: 1,
  30877. PatientId: id,
  30878. RecordTime: recordDateTime,
  30879. Stage: 4,
  30880. }
  30881. service.CreateErrMsgLog(errlog)
  30882. }
  30883. }
  30884. if isSuccess {
  30885. res.Infcode = 0
  30886. res.Output.Result = res2.Output.Result
  30887. } else {
  30888. order := &models.HisOrder{
  30889. UserOrgId: adminUser.CurrentOrgId,
  30890. HisPatientId: his.ID,
  30891. PatientId: his.PatientId,
  30892. SettleAccountsDate: recordDateTime,
  30893. Ctime: time.Now().Unix(),
  30894. Mtime: time.Now().Unix(),
  30895. MdtrtId: his.Number,
  30896. PsnNo: his.PsnNo,
  30897. MedType: strconv.FormatInt(reg_type, 10),
  30898. Status: 1,
  30899. Number: chrg_bchno,
  30900. Infcode: res.Infcode,
  30901. WarnMsg: res.WarnMsg,
  30902. Cainfo: res.Cainfo,
  30903. ErrMsg: res.ErrMsg,
  30904. RespondTime: res.RefmsgTime,
  30905. InfRefmsgid: res.InfRefmsgid,
  30906. OrderStatus: 1,
  30907. IsMedicineInsurance: 1,
  30908. SettleType: settle_accounts_type,
  30909. SettleStartTime: start_time,
  30910. SettleEndTime: end_time,
  30911. Creator: roles.AdminUserId,
  30912. Modify: roles.AdminUserId,
  30913. PType: 2,
  30914. Diagnosis: diagnosis_id,
  30915. }
  30916. err = service.CreateOrder(order)
  30917. if err != nil {
  30918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30919. return
  30920. }
  30921. c.ServeSuccessJSON(map[string]interface{}{
  30922. "failed_code": -10,
  30923. "msg": res2.ErrMsg,
  30924. })
  30925. return
  30926. }
  30927. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30928. 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)
  30929. var dat map[string]interface{}
  30930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30931. fmt.Println(dat)
  30932. } else {
  30933. fmt.Println(err)
  30934. }
  30935. saveLog(result, request_log, "2204", "上传费用明细")
  30936. userJSONBytes, _ := json.Marshal(dat)
  30937. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30938. utils.ErrorLog("解析失败:%v", err)
  30939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30940. return
  30941. }
  30942. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30943. 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, "", "")
  30944. var dat map[string]interface{}
  30945. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30946. fmt.Println(dat)
  30947. } else {
  30948. fmt.Println(err)
  30949. }
  30950. saveLog(result, request_log, "2204", "上传费用明细")
  30951. userJSONBytes, _ := json.Marshal(dat)
  30952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30953. utils.ErrorLog("解析失败:%v", err)
  30954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30955. return
  30956. }
  30957. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30958. 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, "", "")
  30959. var dat map[string]interface{}
  30960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30961. fmt.Println(dat)
  30962. } else {
  30963. fmt.Println(err)
  30964. }
  30965. saveLog(result, request_log, "2204", "上传费用明细")
  30966. userJSONBytes, _ := json.Marshal(dat)
  30967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30968. utils.ErrorLog("解析失败:%v", err)
  30969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30970. return
  30971. }
  30972. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30973. 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, "", "")
  30974. var dat map[string]interface{}
  30975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30976. fmt.Println(dat)
  30977. } else {
  30978. fmt.Println(err)
  30979. }
  30980. saveLog(result, request_log, "2204", "上传费用明细")
  30981. userJSONBytes, _ := json.Marshal(dat)
  30982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30983. utils.ErrorLog("解析失败:%v", err)
  30984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30985. return
  30986. }
  30987. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30988. bytesData, _ := json.Marshal(data)
  30989. var req *http.Request
  30990. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30991. resp, _ := client.Do(req)
  30992. defer resp.Body.Close()
  30993. body, ioErr := ioutil.ReadAll(resp.Body)
  30994. if ioErr != nil {
  30995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30997. return
  30998. }
  30999. var respJSON map[string]interface{}
  31000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31003. return
  31004. }
  31005. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31006. if status == "0" {
  31007. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31008. c.ServeSuccessJSON(map[string]interface{}{
  31009. "failed_code": -10,
  31010. "msg": err_msg,
  31011. })
  31012. return
  31013. }
  31014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31015. userJSONBytes, _ := json.Marshal(respJSON)
  31016. fmt.Println("log")
  31017. fmt.Println(string(userJSONBytes))
  31018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31019. utils.ErrorLog("解析失败:%v", err)
  31020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31021. return
  31022. }
  31023. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31024. bytesData, _ := json.Marshal(data)
  31025. var req *http.Request
  31026. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  31027. resp, _ := client.Do(req)
  31028. defer resp.Body.Close()
  31029. body, ioErr := ioutil.ReadAll(resp.Body)
  31030. if ioErr != nil {
  31031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31033. return
  31034. }
  31035. var respJSON map[string]interface{}
  31036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31039. return
  31040. }
  31041. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31042. if status == "0" {
  31043. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31044. c.ServeSuccessJSON(map[string]interface{}{
  31045. "failed_code": -10,
  31046. "msg": err_msg,
  31047. })
  31048. return
  31049. }
  31050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31051. userJSONBytes, _ := json.Marshal(respJSON)
  31052. fmt.Println("log")
  31053. fmt.Println(string(userJSONBytes))
  31054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31055. utils.ErrorLog("解析失败:%v", err)
  31056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31057. return
  31058. }
  31059. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31060. 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, "", "")
  31061. var dat map[string]interface{}
  31062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31063. fmt.Println(dat)
  31064. } else {
  31065. fmt.Println(err)
  31066. }
  31067. saveLog(result, request_log, "2204", "上传费用明细")
  31068. userJSONBytes, _ := json.Marshal(dat)
  31069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31070. utils.ErrorLog("解析失败:%v", err)
  31071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31072. return
  31073. }
  31074. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31075. bytesData, _ := json.Marshal(data)
  31076. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  31077. resp, _ := client.Do(req)
  31078. defer resp.Body.Close()
  31079. body, ioErr := ioutil.ReadAll(resp.Body)
  31080. if ioErr != nil {
  31081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31083. return
  31084. }
  31085. var respJSON map[string]interface{}
  31086. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31089. return
  31090. }
  31091. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31092. userJSONBytes, _ := json.Marshal(respJSON)
  31093. fmt.Println("log")
  31094. fmt.Println(string(userJSONBytes))
  31095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31096. utils.ErrorLog("解析失败:%v", err)
  31097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31098. return
  31099. }
  31100. } else {
  31101. if miConfig.MdtrtareaAdmvs == "441202" {
  31102. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31103. if result3101.Infcode == 0 {
  31104. if len(result3101.Output.Result) > 0 {
  31105. var errMsgs []string
  31106. for _, item := range result3101.Output.Result {
  31107. errMsgs = append(errMsgs, item.VolaCont)
  31108. }
  31109. c.ServeSuccessJSON(map[string]interface{}{
  31110. "failed_code": -10,
  31111. "msg": errMsgs,
  31112. })
  31113. return
  31114. } else {
  31115. 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)
  31116. var dat map[string]interface{}
  31117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31118. fmt.Println(dat)
  31119. } else {
  31120. fmt.Println(err)
  31121. }
  31122. saveLog(result, request_log, "2204", "上传费用明细")
  31123. userJSONBytes, _ := json.Marshal(dat)
  31124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31125. utils.ErrorLog("解析失败:%v", err)
  31126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31127. return
  31128. }
  31129. }
  31130. } else {
  31131. c.ServeSuccessJSON(map[string]interface{}{
  31132. "failed_code": -10,
  31133. "msg": result3101.ErrMsg,
  31134. })
  31135. return
  31136. }
  31137. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31138. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31139. if result3101.Infcode == 0 {
  31140. if len(result3101.Output.Result) > 0 {
  31141. var errMsgs []string
  31142. for _, item := range result3101.Output.Result {
  31143. errMsgs = append(errMsgs, item.VolaCont)
  31144. }
  31145. c.ServeSuccessJSON(map[string]interface{}{
  31146. "failed_code": -10,
  31147. "msg": errMsgs,
  31148. })
  31149. return
  31150. } else {
  31151. 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)
  31152. var dat map[string]interface{}
  31153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31154. fmt.Println(dat)
  31155. } else {
  31156. fmt.Println(err)
  31157. }
  31158. saveLog(result, request_log, "2204", "上传费用明细")
  31159. userJSONBytes, _ := json.Marshal(dat)
  31160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31161. utils.ErrorLog("解析失败:%v", err)
  31162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31163. return
  31164. }
  31165. }
  31166. } else {
  31167. c.ServeSuccessJSON(map[string]interface{}{
  31168. "failed_code": -10,
  31169. "msg": result3101.ErrMsg,
  31170. })
  31171. return
  31172. }
  31173. } else {
  31174. if miConfig.Code == "H15049901371" {
  31175. 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)
  31176. var dat map[string]interface{}
  31177. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31178. fmt.Println(dat)
  31179. } else {
  31180. fmt.Println(err)
  31181. }
  31182. saveLog(result, request_log, "2204", "上传费用明细")
  31183. userJSONBytes, _ := json.Marshal(dat)
  31184. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  31185. utils.ErrorLog("解析失败:%v", err)
  31186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31187. return
  31188. }
  31189. res.InfRefmsgid = resFour10265.InfRefmsgid
  31190. res.Output = resFour10265.Output
  31191. res.ErrMsg = resFour10265.ErrMsg
  31192. res.Cainfo = resFour10265.Cainfo
  31193. res.WarnMsg = resFour10265.WarnMsg
  31194. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  31195. res.Infcode = infocode
  31196. } else {
  31197. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  31198. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31199. if result3101.Infcode == 0 {
  31200. if len(result3101.Output.Result) > 0 {
  31201. c.ServeSuccessJSON(map[string]interface{}{
  31202. "failed_code": -10,
  31203. "failed_type": 100,
  31204. "warm_type": 1,
  31205. "msg": result3101,
  31206. })
  31207. return
  31208. } else {
  31209. 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)
  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, request_log, "2204", "上传费用明细")
  31217. userJSONBytes, _ := json.Marshal(dat)
  31218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31219. utils.ErrorLog("解析失败:%v", err)
  31220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31221. return
  31222. }
  31223. }
  31224. } else {
  31225. c.ServeSuccessJSON(map[string]interface{}{
  31226. "failed_code": -10,
  31227. "msg": result3101.ErrMsg,
  31228. })
  31229. return
  31230. }
  31231. } else {
  31232. 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)
  31233. var dat map[string]interface{}
  31234. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31235. fmt.Println(dat)
  31236. } else {
  31237. fmt.Println(err)
  31238. }
  31239. saveLog(result, request_log, "2204", "上传费用明细")
  31240. userJSONBytes, _ := json.Marshal(dat)
  31241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31242. utils.ErrorLog("解析失败:%v", err)
  31243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31244. return
  31245. }
  31246. }
  31247. }
  31248. }
  31249. }
  31250. var total_two float64
  31251. if res.Infcode == -1 {
  31252. errlog := &models.HisOrderError{
  31253. UserOrgId: adminUser.CurrentOrgId,
  31254. Ctime: time.Now().Unix(),
  31255. Mtime: time.Now().Unix(),
  31256. Number: chrg_bchno,
  31257. ErrMsg: res.ErrMsg,
  31258. Status: 1,
  31259. PatientId: id,
  31260. RecordTime: recordDateTime,
  31261. Stage: 4,
  31262. }
  31263. service.CreateErrMsgLog(errlog)
  31264. c.ServeSuccessJSON(map[string]interface{}{
  31265. "failed_code": -10,
  31266. "msg": res.ErrMsg,
  31267. })
  31268. return
  31269. }
  31270. if res.Infcode == 0 {
  31271. order := &models.HisOrder{
  31272. UserOrgId: adminUser.CurrentOrgId,
  31273. HisPatientId: his.ID,
  31274. PatientId: his.PatientId,
  31275. SettleAccountsDate: recordDateTime,
  31276. Ctime: time.Now().Unix(),
  31277. Mtime: time.Now().Unix(),
  31278. MdtrtId: his.Number,
  31279. PsnNo: his.PsnNo,
  31280. MedType: strconv.FormatInt(reg_type, 10),
  31281. Status: 1,
  31282. Number: chrg_bchno,
  31283. Infcode: res.Infcode,
  31284. WarnMsg: res.WarnMsg,
  31285. Cainfo: res.Cainfo,
  31286. ErrMsg: res.ErrMsg,
  31287. RespondTime: res.RefmsgTime,
  31288. InfRefmsgid: res.InfRefmsgid,
  31289. OrderStatus: 1,
  31290. IsMedicineInsurance: 1,
  31291. SettleType: settle_accounts_type,
  31292. SettleStartTime: start_time,
  31293. SettleEndTime: end_time,
  31294. Creator: roles.AdminUserId,
  31295. Modify: roles.AdminUserId,
  31296. PType: 2,
  31297. Diagnosis: diagnosis_id,
  31298. }
  31299. err = service.CreateOrder(order)
  31300. if err != nil {
  31301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31302. return
  31303. }
  31304. for _, item := range res.Output.Result {
  31305. temp := strings.Split(item.FeedetlSn, "-")
  31306. var advice_id int64 = 0
  31307. var project_id int64 = 0
  31308. var types int64 = 0
  31309. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31310. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31311. if temp[1] == "1" {
  31312. advice_id = id
  31313. project_id = 0
  31314. } else if temp[1] == "2" {
  31315. advice_id = 0
  31316. project_id = id
  31317. }
  31318. total_two = total_two + item.DetItemFeeSumamt
  31319. info := &models.HisOrderInfo{
  31320. OrderNumber: order.Number,
  31321. FeedetlSn: item.FeedetlSn,
  31322. UploadDate: time.Now().Unix(),
  31323. AdviceId: advice_id,
  31324. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31325. Cnt: item.Cnt,
  31326. Pric: float64(item.Pric),
  31327. PatientId: his.PatientId,
  31328. PricUplmtAmt: item.PricUplmtAmt,
  31329. SelfpayProp: item.SelfpayProp,
  31330. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31331. OverlmtAmt: item.OverlmtAmt,
  31332. PreselfpayAmt: item.PreselfpayAmt,
  31333. BasMednFlag: item.BasMednFlag,
  31334. MedChrgitmType: item.MedChrgitmType,
  31335. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31336. Status: 1,
  31337. Memo: item.Memo,
  31338. Mtime: time.Now().Unix(),
  31339. InscpScpAmt: item.InscpScpAmt,
  31340. DrtReimFlag: item.DrtReimFlag,
  31341. Ctime: time.Now().Unix(),
  31342. ListSpItemFlag: item.ListSpItemFlag,
  31343. ChldMedcFlag: item.ChldMedcFlag,
  31344. LmtUsedFlag: item.LmtUsedFlag,
  31345. ChrgitmLv: item.ChrgitmLv,
  31346. UserOrgId: adminUser.CurrentOrgId,
  31347. HisPatientId: his.ID,
  31348. OrderId: order.ID,
  31349. ProjectId: project_id,
  31350. Type: types,
  31351. }
  31352. service.CreateOrderInfo(info)
  31353. }
  31354. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31355. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31356. var total float64
  31357. for _, item := range prescriptions {
  31358. if item.Type == 1 { //药品
  31359. for _, subItem := range item.HisDoctorAdviceInfo {
  31360. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31361. total_one := price * subItem.PrescribingNumber
  31362. fmt.Println("subItem")
  31363. fmt.Println(subItem.Price)
  31364. fmt.Println("price")
  31365. fmt.Println(price)
  31366. fmt.Println("total_one")
  31367. fmt.Println(total_one)
  31368. total = total + total_one
  31369. fmt.Println(total)
  31370. }
  31371. }
  31372. if item.Type == 2 { //项目
  31373. for _, subItem := range item.HisPrescriptionProject {
  31374. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31375. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31376. total_one := price * cnt
  31377. total = total + total_one
  31378. }
  31379. }
  31380. }
  31381. allTotal := fmt.Sprintf("%.2f", total)
  31382. if res.Infcode == 0 {
  31383. var rf []*ResultFive
  31384. json.Unmarshal([]byte(his.Iinfo), &rf)
  31385. chrg_bchno := chrg_bchno
  31386. cert_no := his.Certno
  31387. var insutypes []string
  31388. var insutype string
  31389. var is390 int = 0
  31390. var is310 int = 0
  31391. for _, item := range rf {
  31392. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31393. insutypes = append(insutypes, item.Insutype)
  31394. }
  31395. }
  31396. if len(insutypes) == 1 {
  31397. insutype = insutypes[0]
  31398. } else {
  31399. for _, i := range insutypes {
  31400. if i == "390" {
  31401. is390 = 1
  31402. }
  31403. if i == "310" {
  31404. is310 = 1
  31405. }
  31406. }
  31407. }
  31408. if is390 == 1 {
  31409. insutype = "390"
  31410. }
  31411. if is310 == 1 {
  31412. insutype = "310"
  31413. }
  31414. if len(insutypes) == 0 {
  31415. insutype = "390"
  31416. }
  31417. if len(insutypes) == 2 {
  31418. insutype = strconv.FormatInt(his.SocialType, 10)
  31419. }
  31420. //insutype = "390"
  31421. if his.IdCardType == 1 {
  31422. cert_no = his.MedicalInsuranceNumber
  31423. } else {
  31424. cert_no = his.Certno
  31425. }
  31426. var res ResultSeven
  31427. var res10633 ResultSeven10633
  31428. var ahres ResultSevenAH
  31429. var resSeven10265 ResultSeven10265
  31430. var resSeven10265Two ResultSeven10265Two
  31431. var resSeven10633Three ResultSeven10633Three
  31432. var gzresSeven10265Two GZResultSeven10265Two
  31433. if miConfig.MdtrtareaAdmvs == "421300" {
  31434. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31435. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31436. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31437. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31438. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31439. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31440. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31441. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31442. resp, requestErr := http.Get(api)
  31443. if requestErr != nil {
  31444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31445. return
  31446. }
  31447. body, ioErr := ioutil.ReadAll(resp.Body)
  31448. if ioErr != nil {
  31449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31451. return
  31452. }
  31453. var respJSON map[string]interface{}
  31454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31457. return
  31458. }
  31459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31460. result, _ := json.Marshal(respJSON)
  31461. fmt.Println("log")
  31462. fmt.Println(string(result))
  31463. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31464. utils.ErrorLog("解析失败:%v", err)
  31465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31466. return
  31467. }
  31468. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31469. if reg_type == 11 && his.Insutype == "390" {
  31470. reg_type = 110104
  31471. }
  31472. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31473. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31474. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31475. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31476. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31477. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31478. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31479. resp, requestErr := http.Get(api)
  31480. if requestErr != nil {
  31481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31482. return
  31483. }
  31484. body, ioErr := ioutil.ReadAll(resp.Body)
  31485. if ioErr != nil {
  31486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31488. return
  31489. }
  31490. var respJSON map[string]interface{}
  31491. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31494. return
  31495. }
  31496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31497. result, _ := json.Marshal(respJSON)
  31498. fmt.Println("log")
  31499. fmt.Println(string(result))
  31500. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31501. utils.ErrorLog("解析失败:%v", err)
  31502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31503. return
  31504. }
  31505. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31506. if reg_type == 11 && his.Insutype == "390" {
  31507. reg_type = 110104
  31508. }
  31509. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31510. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31511. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31512. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31513. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31514. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31515. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31516. resp, requestErr := http.Get(api)
  31517. if requestErr != nil {
  31518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31519. return
  31520. }
  31521. body, ioErr := ioutil.ReadAll(resp.Body)
  31522. if ioErr != nil {
  31523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31525. return
  31526. }
  31527. var respJSON map[string]interface{}
  31528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31531. return
  31532. }
  31533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31534. result, _ := json.Marshal(respJSON)
  31535. fmt.Println("log")
  31536. fmt.Println(string(result))
  31537. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31538. utils.ErrorLog("解析失败:%v", err)
  31539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31540. return
  31541. }
  31542. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31543. if reg_type == 11 && his.Insutype == "390" {
  31544. reg_type = 110104
  31545. }
  31546. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31547. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31548. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31549. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31550. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31551. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31552. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31553. resp, requestErr := http.Get(api)
  31554. if requestErr != nil {
  31555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31556. return
  31557. }
  31558. body, ioErr := ioutil.ReadAll(resp.Body)
  31559. if ioErr != nil {
  31560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31562. return
  31563. }
  31564. var respJSON map[string]interface{}
  31565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31568. return
  31569. }
  31570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31571. result, _ := json.Marshal(respJSON)
  31572. fmt.Println("log")
  31573. fmt.Println(string(result))
  31574. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31575. utils.ErrorLog("解析失败:%v", err)
  31576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31577. return
  31578. }
  31579. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31580. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31581. var result3101 Result3101
  31582. //utils.ErrorLog("解析失败:%v", result3101)
  31583. result3101.Infcode = "0"
  31584. if result3101.Infcode == "0" {
  31585. if len(result3101.Output.Result) > 0 {
  31586. var errMsgs []string
  31587. for _, item := range result3101.Output.Result {
  31588. errMsgs = append(errMsgs, item.VolaCont)
  31589. }
  31590. c.ServeSuccessJSON(map[string]interface{}{
  31591. "failed_code": -10,
  31592. "msg": errMsgs,
  31593. })
  31594. return
  31595. } else {
  31596. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31597. if his.IdCardType != 4 {
  31598. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31599. bas := strings.Split(psn_info.CardInfo, "|")
  31600. if his.IdCardType == 1 {
  31601. cert_no = bas[2]
  31602. } else {
  31603. cert_no = bas[1]
  31604. }
  31605. } else {
  31606. cert_no = his.Certno
  31607. }
  31608. //江苏地区国家医保医疗类别
  31609. //职工透析:医疗类别选特殊情况门诊9933
  31610. //居民血透门慢: 医疗类别选门诊慢病1402
  31611. //var med_type string
  31612. //if his.Insutype == "310" {
  31613. // if reg_type == 14 {
  31614. // med_type = "9933"
  31615. // } else if reg_type == 11 {
  31616. // med_type = "11"
  31617. //
  31618. // }
  31619. //} else if his.Insutype == "390" {
  31620. // if reg_type == 14 {
  31621. // med_type = "1402"
  31622. // } else if reg_type == 11 {
  31623. // med_type = "11"
  31624. // }
  31625. //}
  31626. var api string
  31627. if miConfig.MdtrtareaAdmvs == "320830" {
  31628. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31629. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31630. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31631. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31632. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31633. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31634. "&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
  31635. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31636. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31637. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31638. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31639. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31640. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31641. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31642. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31643. "&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
  31644. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31645. } else {
  31646. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31647. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31648. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31649. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31650. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31651. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31652. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31653. "&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
  31654. }
  31655. resp, requestErr := http.Get(api)
  31656. if requestErr != nil {
  31657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31658. return
  31659. }
  31660. body, ioErr := ioutil.ReadAll(resp.Body)
  31661. if ioErr != nil {
  31662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31664. return
  31665. }
  31666. var respJSON map[string]interface{}
  31667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31670. return
  31671. }
  31672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31673. result, _ := json.Marshal(respJSON)
  31674. fmt.Println("log")
  31675. fmt.Println(string(result))
  31676. {
  31677. if miConfig.MdtrtareaAdmvs == "320830" {
  31678. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208") {
  31679. fmt.Println("log")
  31680. fmt.Println(string(result))
  31681. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31682. utils.ErrorLog("解析失败:%v", err)
  31683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31684. return
  31685. }
  31686. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31687. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31688. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31689. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31690. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31691. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31692. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31693. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31694. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31695. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31696. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31697. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31698. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31699. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31700. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31701. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31702. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31703. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31704. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31705. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31706. //HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31707. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31708. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31709. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31710. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31711. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31712. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31713. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31714. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31715. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31716. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31717. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31718. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31719. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31720. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31721. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31722. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31723. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31724. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31725. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31726. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31727. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31728. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31729. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31730. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31731. res10633.Cainfo = resSeven10633Three.Cainfo
  31732. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31733. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31734. res10633.Infcode = infocode
  31735. } else {
  31736. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31737. utils.ErrorLog("解析失败:%v", err)
  31738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31739. return
  31740. }
  31741. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31742. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31743. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31744. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31745. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31746. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31747. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31748. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31749. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31750. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31751. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31752. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31753. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31754. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31755. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31756. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31757. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31758. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31759. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31760. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31761. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31762. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31763. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31764. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31765. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31766. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31767. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31768. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31769. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31770. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31771. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31772. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31773. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31774. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31775. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31776. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31777. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31778. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31779. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31780. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31781. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31782. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31783. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31784. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31785. res10633.Cainfo = resSeven10633Three.Cainfo
  31786. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31787. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31788. res10633.Infcode = infocode
  31789. }
  31790. } else {
  31791. fmt.Println("log")
  31792. //fmt.Println(string(result))
  31793. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209") {
  31794. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31795. utils.ErrorLog("解析失败:%v", err)
  31796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31797. return
  31798. }
  31799. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31800. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31801. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31802. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31803. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31804. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31805. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31806. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31807. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31808. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31809. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31810. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31811. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31812. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31813. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31814. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31815. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31816. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31817. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31818. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31819. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31820. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31821. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31822. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31823. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31824. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31825. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31826. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31827. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31828. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31829. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31830. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31831. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31832. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31833. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31834. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31835. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31836. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31837. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31838. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31839. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31840. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31841. res10633.Cainfo = resSeven10633Three.Cainfo
  31842. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31843. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31844. res10633.Infcode = infocode
  31845. } else {
  31846. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31847. utils.ErrorLog("解析失败:%v", err)
  31848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31849. return
  31850. }
  31851. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31852. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31853. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPayv
  31854. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31855. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31856. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31857. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31858. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31859. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31860. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31861. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31862. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31863. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31864. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31865. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31866. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31867. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31868. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31869. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31870. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31871. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31872. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31873. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31874. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31875. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31876. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31877. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31878. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31879. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31880. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31881. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31882. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31883. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31884. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31885. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31886. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31887. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31888. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31889. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31890. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31891. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31892. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31893. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31894. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31895. res10633.Cainfo = resSeven10633Three.Cainfo
  31896. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31897. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31898. res10633.Infcode = infocode
  31899. }
  31900. }
  31901. }
  31902. }
  31903. }
  31904. } else if miConfig.MdtrtareaAdmvs == "150404" {
  31905. psn_info, _ := service.GetPsnByPatientId(id)
  31906. var verify_number string
  31907. if psn_info.IdCardType == 4 {
  31908. verify_number = psn_info.VerifyNumber
  31909. } else if psn_info.IdCardType == 1 {
  31910. bas := strings.Split(psn_info.CardInfo, "|")
  31911. cardNumber := bas[2]
  31912. verify_number = cardNumber
  31913. } else {
  31914. psn_info.IdCardType = 2
  31915. verify_number = psn_info.Certno
  31916. }
  31917. var api string
  31918. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31919. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31920. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31921. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31922. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31923. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31924. "&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
  31925. resp, requestErr := http.Get(api)
  31926. if requestErr != nil {
  31927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31928. return
  31929. }
  31930. body, ioErr := ioutil.ReadAll(resp.Body)
  31931. if ioErr != nil {
  31932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31934. return
  31935. }
  31936. var respJSON map[string]interface{}
  31937. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31940. return
  31941. }
  31942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31943. result, _ := json.Marshal(respJSON)
  31944. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31945. utils.ErrorLog("解析失败:%v", err)
  31946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31947. return
  31948. }
  31949. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31950. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31951. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31952. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31953. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31954. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31955. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31956. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31957. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31958. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31959. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31960. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31961. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31962. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31963. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31964. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31965. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31966. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31967. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31968. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31969. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31970. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31971. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31972. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31973. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31974. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31975. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31976. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31977. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31978. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31979. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31980. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31981. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31982. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31983. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31984. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31985. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31986. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31987. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31988. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31989. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31990. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31991. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31992. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31993. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31994. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31995. res.ErrMsg = resSeven10265.ErrMsg
  31996. res.Cainfo = resSeven10265.Cainfo
  31997. res.WarnMsg = resSeven10265.WarnMsg
  31998. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31999. res.Infcode = infocode
  32000. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32001. acct_used_flag := "1"
  32002. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  32003. var result string
  32004. var request_log string
  32005. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  32006. 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)
  32007. } else {
  32008. 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)
  32009. }
  32010. var dat map[string]interface{}
  32011. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32012. fmt.Println(dat)
  32013. } else {
  32014. fmt.Println(err)
  32015. }
  32016. saveLog(result, request_log, "2206", "预结算")
  32017. userJSONBytes, _ := json.Marshal(dat)
  32018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32019. utils.ErrorLog("解析失败:%v", err)
  32020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32021. return
  32022. }
  32023. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32024. var result string
  32025. var request_log string
  32026. if his.IdCardType == 2 {
  32027. insutype = strconv.FormatInt(his.SocialType, 10)
  32028. 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, "")
  32029. } else if his.IdCardType == 1 {
  32030. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32031. bas := strings.Split(psn_info.CardInfo, "|")
  32032. basNumber := bas[2]
  32033. card_sn := bas[3]
  32034. var rf []*ResultFive
  32035. json.Unmarshal([]byte(his.Iinfo), &rf)
  32036. var psn_type string
  32037. for _, item := range rf {
  32038. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32039. psn_type = item.PsnType
  32040. }
  32041. }
  32042. insutype = strconv.FormatInt(his.SocialType, 10)
  32043. 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)
  32044. } else {
  32045. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32046. //bas := strings.Split(psn_info.CardInfo, "|")
  32047. //basNumber := bas[2]
  32048. //card_sn := bas[3]
  32049. var rf []*ResultFive
  32050. json.Unmarshal([]byte(his.Iinfo), &rf)
  32051. var psn_type string
  32052. for _, item := range rf {
  32053. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32054. psn_type = item.PsnType
  32055. }
  32056. }
  32057. insutype = strconv.FormatInt(his.SocialType, 10)
  32058. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32059. 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)
  32060. }
  32061. var dat map[string]interface{}
  32062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32063. fmt.Println(dat)
  32064. } else {
  32065. fmt.Println(err)
  32066. }
  32067. saveLog(result, request_log, "2206", "预结算")
  32068. userJSONBytes, _ := json.Marshal(dat)
  32069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32070. utils.ErrorLog("解析失败:%v", err)
  32071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32072. return
  32073. }
  32074. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32075. var result string
  32076. var request_log string
  32077. if his.IdCardType == 2 {
  32078. insutype = strconv.FormatInt(his.SocialType, 10)
  32079. 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, "")
  32080. } else if his.IdCardType == 1 {
  32081. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32082. bas := strings.Split(psn_info.CardInfo, "|")
  32083. basNumber := bas[0]
  32084. card_sn := ""
  32085. var rf []*ResultFive
  32086. json.Unmarshal([]byte(his.Iinfo), &rf)
  32087. var psn_type string
  32088. for _, item := range rf {
  32089. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32090. psn_type = item.PsnType
  32091. }
  32092. }
  32093. insutype = strconv.FormatInt(his.SocialType, 10)
  32094. 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)
  32095. } else {
  32096. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32097. //bas := strings.Split(psn_info.CardInfo, "|")
  32098. //basNumber := bas[2]
  32099. //card_sn := bas[3]
  32100. var rf []*ResultFive
  32101. json.Unmarshal([]byte(his.Iinfo), &rf)
  32102. var psn_type string
  32103. for _, item := range rf {
  32104. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32105. psn_type = item.PsnType
  32106. }
  32107. }
  32108. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32109. 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)
  32110. }
  32111. var dat map[string]interface{}
  32112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32113. fmt.Println(dat)
  32114. } else {
  32115. fmt.Println(err)
  32116. }
  32117. saveLog(result, request_log, "2206", "预结算")
  32118. userJSONBytes, _ := json.Marshal(dat)
  32119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32120. utils.ErrorLog("解析失败:%v", err)
  32121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32122. return
  32123. }
  32124. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32125. var result string
  32126. var request_log string
  32127. if his.IdCardType == 2 {
  32128. insutype = strconv.FormatInt(his.SocialType, 10)
  32129. 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, "")
  32130. } else if his.IdCardType == 1 {
  32131. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32132. bas := strings.Split(psn_info.CardInfo, "|")
  32133. basNumber := bas[0]
  32134. card_sn := ""
  32135. var rf []*ResultFive
  32136. json.Unmarshal([]byte(his.Iinfo), &rf)
  32137. var psn_type string
  32138. for _, item := range rf {
  32139. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32140. psn_type = item.PsnType
  32141. }
  32142. }
  32143. insutype = strconv.FormatInt(his.SocialType, 10)
  32144. 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)
  32145. } else {
  32146. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32147. //bas := strings.Split(psn_info.CardInfo, "|")
  32148. //basNumber := bas[2]
  32149. //card_sn := bas[3]
  32150. var rf []*ResultFive
  32151. json.Unmarshal([]byte(his.Iinfo), &rf)
  32152. var psn_type string
  32153. for _, item := range rf {
  32154. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32155. psn_type = item.PsnType
  32156. }
  32157. }
  32158. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32159. 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)
  32160. }
  32161. var dat map[string]interface{}
  32162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32163. fmt.Println(dat)
  32164. } else {
  32165. fmt.Println(err)
  32166. }
  32167. saveLog(result, request_log, "2206", "预结算")
  32168. userJSONBytes, _ := json.Marshal(dat)
  32169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32170. utils.ErrorLog("解析失败:%v", err)
  32171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32172. return
  32173. }
  32174. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32175. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32176. if his.IdCardType == 4 {
  32177. psn_info.VerifyNumber = psn_info.VerifyNumber
  32178. cert_no = psn_info.VerifyNumber
  32179. } else if his.IdCardType == 2 {
  32180. cert_no = psn_info.Certno
  32181. psn_info.VerifyNumber = psn_info.Certno
  32182. } else {
  32183. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32184. bas := strings.Split(psn_info.CardInfo, "|")
  32185. if his.IdCardType == 1 {
  32186. cert_no = bas[2]
  32187. } else {
  32188. cert_no = bas[1]
  32189. }
  32190. }
  32191. var api string
  32192. var med_type string
  32193. if his.Insutype == "390" {
  32194. if reg_type == 992102 {
  32195. med_type = "992102"
  32196. }
  32197. if reg_type == 140104 {
  32198. med_type = "140104"
  32199. }
  32200. if reg_type == 140201 {
  32201. med_type = "140201"
  32202. }
  32203. if reg_type == 14 {
  32204. med_type = "140104"
  32205. }
  32206. if reg_type == 1104 {
  32207. med_type = "1104"
  32208. }
  32209. } else if his.Insutype == "310" {
  32210. if reg_type == 1104 {
  32211. med_type = "1104"
  32212. }
  32213. if reg_type == 992102 {
  32214. med_type = "992102"
  32215. }
  32216. if reg_type == 140104 {
  32217. med_type = "140104"
  32218. }
  32219. if reg_type == 140201 {
  32220. med_type = "140201"
  32221. }
  32222. if reg_type == 14 {
  32223. med_type = "140104"
  32224. }
  32225. }
  32226. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32227. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32228. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32229. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32230. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32231. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32232. "&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
  32233. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32234. resp, requestErr := http.Get(api)
  32235. if requestErr != nil {
  32236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32237. return
  32238. }
  32239. body, ioErr := ioutil.ReadAll(resp.Body)
  32240. if ioErr != nil {
  32241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32243. return
  32244. }
  32245. var respJSON map[string]interface{}
  32246. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32249. return
  32250. }
  32251. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32252. if status == "0" {
  32253. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32254. c.ServeSuccessJSON(map[string]interface{}{
  32255. "failed_code": -10,
  32256. "msg": err_msg,
  32257. })
  32258. return
  32259. }
  32260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32261. result, _ := json.Marshal(respJSON)
  32262. fmt.Println("log")
  32263. fmt.Println(string(result))
  32264. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32265. utils.ErrorLog("解析失败:%v", err)
  32266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32267. return
  32268. }
  32269. res.InfRefmsgid = ahres.InfRefmsgid
  32270. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32271. // 创建对应的Time类型
  32272. t := time.UnixMilli(timestamp)
  32273. // 格式化成指定的日期字符串
  32274. str := t.Format("2006-01-02 15:04:05")
  32275. res.Output.Setlinfo.SetlTime = str
  32276. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32277. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32278. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32279. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32280. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32281. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32282. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32283. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32284. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32285. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32286. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32287. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32288. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32289. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32290. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32291. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32292. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32293. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32294. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32295. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32296. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32297. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32298. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32299. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32300. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32301. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32302. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32303. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32304. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32305. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32306. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32307. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32308. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32309. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32310. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32311. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32312. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32313. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32314. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32315. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32316. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32317. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32318. //res.Output.Setldetail = ahres.Output.Setldetail
  32319. res.ErrMsg = ahres.ErrMsg
  32320. res.Cainfo = ahres.Cainfo
  32321. res.WarnMsg = ahres.WarnMsg
  32322. res.Infcode = ahres.Infcode
  32323. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32324. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32325. if his.IdCardType == 4 {
  32326. psn_info.VerifyNumber = psn_info.VerifyNumber
  32327. cert_no = psn_info.Certno
  32328. } else if his.IdCardType == 2 {
  32329. cert_no = psn_info.Certno
  32330. psn_info.VerifyNumber = psn_info.Certno
  32331. } else {
  32332. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32333. bas := strings.Split(psn_info.CardInfo, "|")
  32334. if his.IdCardType == 1 {
  32335. cert_no = bas[2]
  32336. } else {
  32337. cert_no = bas[1]
  32338. }
  32339. }
  32340. var api string
  32341. var med_type string
  32342. if his.Insutype == "390" {
  32343. if reg_type == 992102 {
  32344. med_type = "992102"
  32345. }
  32346. if reg_type == 140104 {
  32347. med_type = "140104"
  32348. }
  32349. if reg_type == 140201 {
  32350. med_type = "140201"
  32351. }
  32352. if reg_type == 14 {
  32353. med_type = "14"
  32354. }
  32355. } else if his.Insutype == "310" {
  32356. if reg_type == 992102 {
  32357. med_type = "992102"
  32358. }
  32359. if reg_type == 140104 {
  32360. med_type = "140104"
  32361. }
  32362. if reg_type == 140201 {
  32363. med_type = "140201"
  32364. }
  32365. if reg_type == 14 {
  32366. med_type = "14"
  32367. }
  32368. }
  32369. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32370. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32371. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32372. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32373. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32374. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32375. "&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
  32376. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32377. resp, requestErr := http.Get(api)
  32378. if requestErr != nil {
  32379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32380. return
  32381. }
  32382. body, ioErr := ioutil.ReadAll(resp.Body)
  32383. if ioErr != nil {
  32384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32386. return
  32387. }
  32388. var respJSON map[string]interface{}
  32389. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32392. return
  32393. }
  32394. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32395. if status == "0" {
  32396. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32397. c.ServeSuccessJSON(map[string]interface{}{
  32398. "failed_code": -10,
  32399. "msg": err_msg,
  32400. })
  32401. return
  32402. }
  32403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32404. result, _ := json.Marshal(respJSON)
  32405. fmt.Println("log")
  32406. fmt.Println(string(result))
  32407. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32408. utils.ErrorLog("解析失败:%v", err)
  32409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32410. return
  32411. }
  32412. res.InfRefmsgid = ahres.InfRefmsgid
  32413. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32414. // 创建对应的Time类型
  32415. t := time.UnixMilli(timestamp)
  32416. // 格式化成指定的日期字符串
  32417. str := t.Format("2006-01-02 15:04:05")
  32418. res.Output.Setlinfo.SetlTime = str
  32419. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32420. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32421. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32422. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32423. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32424. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32425. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32426. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32427. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32428. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32429. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32430. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32431. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32432. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32433. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32434. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32435. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32436. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32437. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32438. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32439. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32440. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32441. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32442. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32443. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32444. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32445. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32446. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32447. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32448. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32449. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32450. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32451. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32452. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32453. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32454. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32455. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32456. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32457. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32458. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32459. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32460. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32461. //res.Output.Setldetail = ahres.Output.Setldetail
  32462. res.ErrMsg = ahres.ErrMsg
  32463. res.Cainfo = ahres.Cainfo
  32464. res.WarnMsg = ahres.WarnMsg
  32465. res.Infcode = ahres.Infcode
  32466. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32467. var result string
  32468. var request_log string
  32469. if his.IdCardType == 2 {
  32470. 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")
  32471. } else if his.IdCardType == 1 {
  32472. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32473. bas := strings.Split(psn_info.CardInfo, "|")
  32474. basNumber := bas[2]
  32475. card_sn := bas[3]
  32476. 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")
  32477. } else {
  32478. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32479. 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")
  32480. }
  32481. var dat map[string]interface{}
  32482. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32483. fmt.Println(dat)
  32484. } else {
  32485. fmt.Println(err)
  32486. }
  32487. saveLog(result, request_log, "2206", "预结算")
  32488. userJSONBytes, _ := json.Marshal(dat)
  32489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32490. utils.ErrorLog("解析失败:%v", err)
  32491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32492. return
  32493. }
  32494. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32495. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32496. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32497. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32498. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32499. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32500. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32501. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32502. resp, requestErr := http.Get(api)
  32503. if requestErr != nil {
  32504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32505. return
  32506. }
  32507. body, ioErr := ioutil.ReadAll(resp.Body)
  32508. if ioErr != nil {
  32509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32511. return
  32512. }
  32513. var respJSON map[string]interface{}
  32514. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32517. return
  32518. }
  32519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32520. result, _ := json.Marshal(respJSON)
  32521. fmt.Println("log")
  32522. fmt.Println(string(result))
  32523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32524. utils.ErrorLog("解析失败:%v", err)
  32525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32526. return
  32527. }
  32528. } else {
  32529. if miConfig.MdtrtareaAdmvs == "441202" {
  32530. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32531. if result3101.Infcode == 0 {
  32532. if len(result3101.Output.Result) > 0 {
  32533. c.ServeSuccessJSON(map[string]interface{}{
  32534. "failed_code": -10,
  32535. "failed_type": 100,
  32536. "msg": result3101.Output.Result,
  32537. })
  32538. return
  32539. } else {
  32540. var result string
  32541. var request_log string
  32542. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32543. allTotal = fmt.Sprintf("%.2f", total_two)
  32544. if his.IdCardType == 4 {
  32545. 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, acct_used_flag)
  32546. } else {
  32547. 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, acct_used_flag)
  32548. }
  32549. var dat map[string]interface{}
  32550. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32551. fmt.Println(dat)
  32552. } else {
  32553. fmt.Println(err)
  32554. }
  32555. saveLog(result, request_log, "2206", "预结算")
  32556. //userJSONBytes, _ := json.Marshal(dat)
  32557. //
  32558. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32559. // utils.ErrorLog("解析失败:%v", err)
  32560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32561. // return
  32562. //}
  32563. userJSONBytes, _ := json.Marshal(dat)
  32564. if miConfig.Code == "H15049901371" {
  32565. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32566. utils.ErrorLog("解析失败:%v", err)
  32567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32568. return
  32569. }
  32570. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32571. res.Output = resSeven10265.Output
  32572. res.ErrMsg = resSeven10265.ErrMsg
  32573. res.Cainfo = resSeven10265.Cainfo
  32574. res.WarnMsg = resSeven10265.WarnMsg
  32575. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32576. res.Infcode = infocode
  32577. } else {
  32578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32579. utils.ErrorLog("解析失败:%v", err)
  32580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32581. return
  32582. }
  32583. }
  32584. }
  32585. } else {
  32586. c.ServeSuccessJSON(map[string]interface{}{
  32587. "failed_code": -10,
  32588. "msg": result3101.ErrMsg,
  32589. })
  32590. return
  32591. }
  32592. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32593. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32594. if result3101.Infcode == 0 {
  32595. if len(result3101.Output.Result) > 0 {
  32596. var errMsgs []string
  32597. for _, item := range result3101.Output.Result {
  32598. errMsgs = append(errMsgs, item.VolaCont)
  32599. }
  32600. c.ServeSuccessJSON(map[string]interface{}{
  32601. "failed_code": -10,
  32602. "msg": errMsgs,
  32603. })
  32604. return
  32605. } else {
  32606. var result string
  32607. var request_log string
  32608. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32609. allTotal = fmt.Sprintf("%.2f", total_two)
  32610. if his.IdCardType == 4 {
  32611. 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, acct_used_flag)
  32612. } else {
  32613. 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, acct_used_flag)
  32614. }
  32615. var dat map[string]interface{}
  32616. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32617. fmt.Println(dat)
  32618. } else {
  32619. fmt.Println(err)
  32620. }
  32621. saveLog(result, request_log, "2206", "预结算")
  32622. //userJSONBytes, _ := json.Marshal(dat)
  32623. //
  32624. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32625. // utils.ErrorLog("解析失败:%v", err)
  32626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32627. // return
  32628. //}
  32629. userJSONBytes, _ := json.Marshal(dat)
  32630. if miConfig.Code == "H15049901371" {
  32631. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32632. utils.ErrorLog("解析失败:%v", err)
  32633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32634. return
  32635. }
  32636. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32637. res.Output = resSeven10265.Output
  32638. res.ErrMsg = resSeven10265.ErrMsg
  32639. res.Cainfo = resSeven10265.Cainfo
  32640. res.WarnMsg = resSeven10265.WarnMsg
  32641. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32642. res.Infcode = infocode
  32643. } else {
  32644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32645. utils.ErrorLog("解析失败:%v", err)
  32646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32647. return
  32648. }
  32649. }
  32650. }
  32651. } else {
  32652. c.ServeSuccessJSON(map[string]interface{}{
  32653. "failed_code": -10,
  32654. "msg": result3101.ErrMsg,
  32655. })
  32656. return
  32657. }
  32658. } else {
  32659. var result string
  32660. var request_log string
  32661. var dat map[string]interface{}
  32662. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32663. allTotal = fmt.Sprintf("%.2f", total_two)
  32664. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  32665. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32666. if result3101.Infcode == 0 {
  32667. if len(result3101.Output.Result) > 0 {
  32668. c.ServeSuccessJSON(map[string]interface{}{
  32669. "failed_code": -10,
  32670. "failed_type": 100,
  32671. "warm_type": 2,
  32672. "msg": result3101,
  32673. })
  32674. return
  32675. } else {
  32676. var result string
  32677. var request_log string
  32678. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32679. allTotal = fmt.Sprintf("%.2f", total_two)
  32680. if his.IdCardType == 4 {
  32681. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.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, acct_used_flag)
  32682. } else {
  32683. if his.IdCardType == 2 {
  32684. cert_no = psn_info.Certno
  32685. psn_info.VerifyNumber = psn_info.Certno
  32686. } else {
  32687. bas := strings.Split(psn_info.CardInfo, "|")
  32688. cert_no = bas[2]
  32689. }
  32690. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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, acct_used_flag)
  32691. }
  32692. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32693. fmt.Println(dat)
  32694. } else {
  32695. fmt.Println(err)
  32696. }
  32697. saveLog(result, request_log, "2206", "预结算")
  32698. }
  32699. } else {
  32700. c.ServeSuccessJSON(map[string]interface{}{
  32701. "failed_code": -10,
  32702. "msg": result3101.ErrMsg,
  32703. })
  32704. return
  32705. }
  32706. } else {
  32707. if his.IdCardType == 4 {
  32708. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.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, acct_used_flag)
  32709. } else {
  32710. if his.IdCardType == 2 {
  32711. cert_no = psn_info.Certno
  32712. psn_info.VerifyNumber = psn_info.Certno
  32713. } else {
  32714. bas := strings.Split(psn_info.CardInfo, "|")
  32715. cert_no = bas[2]
  32716. }
  32717. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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, acct_used_flag)
  32718. }
  32719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32720. fmt.Println(dat)
  32721. } else {
  32722. fmt.Println(err)
  32723. }
  32724. saveLog(result, request_log, "2206", "预结算")
  32725. }
  32726. //userJSONBytes, _ := json.Marshal(dat)
  32727. //
  32728. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32729. // utils.ErrorLog("解析失败:%v", err)
  32730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32731. // return
  32732. //}
  32733. userJSONBytes, _ := json.Marshal(dat)
  32734. if miConfig.Code == "H15049901371" {
  32735. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32736. utils.ErrorLog("解析失败:%v", err)
  32737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32738. return
  32739. }
  32740. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32741. res.Output = resSeven10265.Output
  32742. res.ErrMsg = resSeven10265.ErrMsg
  32743. res.Cainfo = resSeven10265.Cainfo
  32744. res.WarnMsg = resSeven10265.WarnMsg
  32745. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32746. res.Infcode = infocode
  32747. } else {
  32748. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32749. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32750. utils.ErrorLog("解析失败:%v", err)
  32751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32752. return
  32753. }
  32754. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32755. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32756. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32757. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32758. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32759. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32760. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32761. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32762. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32763. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32764. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32765. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32766. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32767. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32768. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32769. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32770. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32771. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32772. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32773. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32774. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32775. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32776. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32777. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32778. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32779. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32780. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32781. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32782. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32783. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32784. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32785. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32786. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32787. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32788. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32789. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32790. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32791. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32792. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32793. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32794. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32795. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32796. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32797. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32798. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32799. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32800. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32801. res.Cainfo = gzresSeven10265Two.Cainfo
  32802. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32803. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32804. //res.Infcode = infocode
  32805. } else {
  32806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32807. utils.ErrorLog("解析失败:%v", err)
  32808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32809. return
  32810. }
  32811. }
  32812. }
  32813. }
  32814. }
  32815. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32816. if res10633.Infcode == -1 {
  32817. errlog := &models.HisOrderError{
  32818. UserOrgId: adminUser.CurrentOrgId,
  32819. Ctime: time.Now().Unix(),
  32820. Mtime: time.Now().Unix(),
  32821. Number: chrg_bchno,
  32822. ErrMsg: res10633.ErrMsg,
  32823. Status: 1,
  32824. PatientId: id,
  32825. RecordTime: recordDateTime,
  32826. Stage: 20,
  32827. }
  32828. service.CreateErrMsgLog(errlog)
  32829. c.ServeSuccessJSON(map[string]interface{}{
  32830. "failed_code": -10,
  32831. "msg": res10633.ErrMsg,
  32832. })
  32833. return
  32834. }
  32835. if res10633.Infcode != 0 {
  32836. errlog := &models.HisOrderError{
  32837. UserOrgId: adminUser.CurrentOrgId,
  32838. Ctime: time.Now().Unix(),
  32839. Mtime: time.Now().Unix(),
  32840. Number: chrg_bchno,
  32841. ErrMsg: res10633.ErrMsg,
  32842. Status: 1,
  32843. PatientId: id,
  32844. RecordTime: recordDateTime,
  32845. Stage: 20,
  32846. }
  32847. service.CreateErrMsgLog(errlog)
  32848. c.ServeSuccessJSON(map[string]interface{}{
  32849. "failed_code": -10,
  32850. "msg": res10633.ErrMsg,
  32851. })
  32852. return
  32853. } else {
  32854. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32855. order.OrderStatus = 1
  32856. order.IsPre = 1
  32857. order.Status = 1
  32858. order.MdtrtId = res10633.Output.Setlinfo.MdtrtID
  32859. order.SetlId = res10633.Output.Setlinfo.SetlID
  32860. order.PsnNo = res10633.Output.Setlinfo.PsnNo
  32861. order.PsnName = res10633.Output.Setlinfo.PsnName
  32862. order.PsnCertType = res10633.Output.Setlinfo.PsnCertType
  32863. order.Certno = res10633.Output.Setlinfo.Certno
  32864. order.Gend = res10633.Output.Setlinfo.Gend
  32865. order.Naty = res10633.Output.Setlinfo.Naty
  32866. order.Age = res10633.Output.Setlinfo.Age
  32867. order.Insutype = res10633.Output.Setlinfo.Insutype
  32868. order.PsnType = res10633.Output.Setlinfo.PsnType
  32869. order.CvlservFlag = res10633.Output.Setlinfo.CvlservFlag
  32870. order.SetlTime = res10633.Output.Setlinfo.SetlTime
  32871. order.AcctUsedFlag = acct_used_flag
  32872. order.MdtrtCertType = res10633.Output.Setlinfo.MdtrtCertType
  32873. if res10633.Output.Setlinfo.MedType == "140101" {
  32874. order.MedType = "14"
  32875. } else {
  32876. if res10633.Output.Setlinfo.MedType == "110104" {
  32877. order.MedType = "11"
  32878. } else {
  32879. order.MedType = res10633.Output.Setlinfo.MedType
  32880. }
  32881. }
  32882. if res10633.Output.Setlinfo.MedType == "992102" {
  32883. order.MedType = "992102"
  32884. }
  32885. if res10633.Output.Setlinfo.MedType == "140104" {
  32886. order.MedType = "140104"
  32887. }
  32888. if res10633.Output.Setlinfo.MedType == "1104" {
  32889. order.MedType = "1104"
  32890. }
  32891. if res10633.Output.Setlinfo.MedType == "140201" {
  32892. order.MedType = "140201"
  32893. }
  32894. if res10633.Output.Setlinfo.MedType == "14" {
  32895. order.MedType = "14"
  32896. }
  32897. if reg_type == 1112 {
  32898. order.MedType = "1112"
  32899. }
  32900. if reg_type == 1111 {
  32901. order.MedType = "1111"
  32902. }
  32903. order.ClrType = res10633.Output.Setlinfo.ClrType
  32904. if adminUser.CurrentOrgId == 10480 {
  32905. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32906. order.ClrType = "11"
  32907. } else {
  32908. order.ClrType = "9903"
  32909. }
  32910. }
  32911. order.MedfeeSumamt = res10633.Output.Setlinfo.MedfeeSumamt
  32912. order.FulamtOwnpayAmt = res10633.Output.Setlinfo.FulamtOwnpayAmt
  32913. order.OverlmtSelfPay = res10633.Output.Setlinfo.OverlmtSelfpay
  32914. order.PreselfpayAmt = res10633.Output.Setlinfo.PreselfpayAmt
  32915. order.InscpScpAmt = res10633.Output.Setlinfo.InscpScpAmt
  32916. order.ActPayDedc = res10633.Output.Setlinfo.ActPayDedc
  32917. order.HifpPay = res10633.Output.Setlinfo.HifpPay
  32918. order.CvlservPay = res10633.Output.Setlinfo.CvlservPay
  32919. order.HifesPay = res10633.Output.Setlinfo.HifesPay
  32920. order.HifobPay = res10633.Output.Setlinfo.HifobPay
  32921. order.MafPay = res10633.Output.Setlinfo.MafPay
  32922. order.HifmiPay = res10633.Output.Setlinfo.HifmiPay
  32923. order.OthPay = res10633.Output.Setlinfo.OthPay
  32924. order.FundPaySumamt = res10633.Output.Setlinfo.FundPaySumamt
  32925. order.PsnPartAmt = res10633.Output.Setlinfo.PsnPartAmt
  32926. order.AcctPay = res10633.Output.Setlinfo.AcctPay
  32927. order.PsnCashPay = res10633.Output.Setlinfo.PsnCashPay
  32928. order.Balc = res10633.Output.Setlinfo.Balc
  32929. order.MedinsSetlId = res10633.Output.Setlinfo.MedinsSetlID
  32930. order.ClrOptins = res10633.Output.Setlinfo.ClrOptins
  32931. order.ClrWay = res10633.Output.Setlinfo.ClrWay
  32932. order.Creator = order.Creator
  32933. order.Modify = roles.AdminUserId
  32934. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32935. //detailStr := string(setlDetail)
  32936. //order.SetlDetail = detailStr
  32937. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32938. err = service.UpDateOrder(order)
  32939. if err == nil {
  32940. c.ServeSuccessJSON(map[string]interface{}{
  32941. "msg": "预结算成功",
  32942. })
  32943. } else {
  32944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32945. return
  32946. }
  32947. }
  32948. } else {
  32949. if res.Infcode == -1 {
  32950. errlog := &models.HisOrderError{
  32951. UserOrgId: adminUser.CurrentOrgId,
  32952. Ctime: time.Now().Unix(),
  32953. Mtime: time.Now().Unix(),
  32954. Number: chrg_bchno,
  32955. ErrMsg: res.ErrMsg,
  32956. Status: 1,
  32957. PatientId: id,
  32958. RecordTime: recordDateTime,
  32959. Stage: 20,
  32960. }
  32961. service.CreateErrMsgLog(errlog)
  32962. c.ServeSuccessJSON(map[string]interface{}{
  32963. "failed_code": -10,
  32964. "msg": res.ErrMsg,
  32965. })
  32966. return
  32967. }
  32968. if res.Infcode != 0 {
  32969. errlog := &models.HisOrderError{
  32970. UserOrgId: adminUser.CurrentOrgId,
  32971. Ctime: time.Now().Unix(),
  32972. Mtime: time.Now().Unix(),
  32973. Number: chrg_bchno,
  32974. ErrMsg: res.ErrMsg,
  32975. Status: 1,
  32976. PatientId: id,
  32977. RecordTime: recordDateTime,
  32978. Stage: 20,
  32979. }
  32980. service.CreateErrMsgLog(errlog)
  32981. c.ServeSuccessJSON(map[string]interface{}{
  32982. "failed_code": -10,
  32983. "msg": res.ErrMsg,
  32984. })
  32985. return
  32986. } else {
  32987. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32988. order.OrderStatus = 1
  32989. order.IsPre = 1
  32990. order.Status = 1
  32991. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32992. order.SetlId = res.Output.Setlinfo.SetlID
  32993. order.PsnNo = res.Output.Setlinfo.PsnNo
  32994. order.PsnName = res.Output.Setlinfo.PsnName
  32995. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32996. order.Certno = res.Output.Setlinfo.Certno
  32997. order.Gend = res.Output.Setlinfo.Gend
  32998. order.Naty = res.Output.Setlinfo.Naty
  32999. order.Age = res.Output.Setlinfo.Age
  33000. order.Insutype = res.Output.Setlinfo.Insutype
  33001. order.PsnType = res.Output.Setlinfo.PsnType
  33002. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  33003. order.SetlTime = res.Output.Setlinfo.SetlTime
  33004. order.AcctUsedFlag = acct_used_flag
  33005. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  33006. if res.Output.Setlinfo.MedType == "140101" {
  33007. order.MedType = "14"
  33008. } else {
  33009. if res.Output.Setlinfo.MedType == "110104" {
  33010. order.MedType = "11"
  33011. } else {
  33012. order.MedType = res.Output.Setlinfo.MedType
  33013. }
  33014. }
  33015. if res.Output.Setlinfo.MedType == "992102" {
  33016. order.MedType = "992102"
  33017. }
  33018. if res.Output.Setlinfo.MedType == "140104" {
  33019. order.MedType = "140104"
  33020. }
  33021. if res.Output.Setlinfo.MedType == "1104" {
  33022. order.MedType = "1104"
  33023. }
  33024. if res.Output.Setlinfo.MedType == "140201" {
  33025. order.MedType = "140201"
  33026. }
  33027. if res.Output.Setlinfo.MedType == "14" {
  33028. order.MedType = "14"
  33029. }
  33030. if reg_type == 1112 {
  33031. order.MedType = "1112"
  33032. }
  33033. if reg_type == 1111 {
  33034. order.MedType = "1111"
  33035. }
  33036. order.ClrType = res.Output.Setlinfo.ClrType
  33037. if adminUser.CurrentOrgId == 10480 {
  33038. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  33039. order.ClrType = "11"
  33040. } else {
  33041. order.ClrType = "9903"
  33042. }
  33043. }
  33044. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  33045. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  33046. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  33047. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  33048. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  33049. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  33050. order.HifpPay = res.Output.Setlinfo.HifpPay
  33051. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  33052. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  33053. order.HifesPay = res.Output.Setlinfo.HifesPay
  33054. order.HifobPay = res.Output.Setlinfo.HifobPay
  33055. order.MafPay = res.Output.Setlinfo.MafPay
  33056. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  33057. order.OthPay = res.Output.Setlinfo.OthPay
  33058. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  33059. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  33060. order.AcctPay = res.Output.Setlinfo.AcctPay
  33061. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  33062. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  33063. order.Balc = res.Output.Setlinfo.Balc
  33064. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  33065. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  33066. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  33067. order.ClrWay = res.Output.Setlinfo.ClrWay
  33068. order.Creator = order.Creator
  33069. order.Modify = roles.AdminUserId
  33070. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  33071. //detailStr := string(setlDetail)
  33072. //order.SetlDetail = detailStr
  33073. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  33074. err = service.UpDateOrder(order)
  33075. if err == nil {
  33076. c.ServeSuccessJSON(map[string]interface{}{
  33077. "msg": "预结算成功",
  33078. })
  33079. } else {
  33080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  33081. return
  33082. }
  33083. }
  33084. }
  33085. } else {
  33086. adminUser := c.GetAdminUserInfo()
  33087. errlog := &models.HisOrderError{
  33088. UserOrgId: adminUser.CurrentOrgId,
  33089. Ctime: time.Now().Unix(),
  33090. Mtime: time.Now().Unix(),
  33091. ErrMsg: res.ErrMsg,
  33092. Status: 1,
  33093. PatientId: id,
  33094. RecordTime: recordDateTime,
  33095. Stage: 4,
  33096. }
  33097. service.CreateErrMsgLog(errlog)
  33098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  33099. return
  33100. }
  33101. } else {
  33102. if miConfig.MdtrtareaAdmvs == "150404" {
  33103. order := &models.HisOrder{
  33104. UserOrgId: adminUser.CurrentOrgId,
  33105. HisPatientId: his.ID,
  33106. PatientId: his.PatientId,
  33107. SettleAccountsDate: recordDateTime,
  33108. Ctime: time.Now().Unix(),
  33109. Mtime: time.Now().Unix(),
  33110. MdtrtId: his.Number,
  33111. PsnNo: his.PsnNo,
  33112. MedType: strconv.FormatInt(reg_type, 10),
  33113. Status: 1,
  33114. Number: chrg_bchno,
  33115. Infcode: res.Infcode,
  33116. WarnMsg: res.WarnMsg,
  33117. Cainfo: res.Cainfo,
  33118. ErrMsg: res.ErrMsg,
  33119. RespondTime: res.RefmsgTime,
  33120. InfRefmsgid: res.InfRefmsgid,
  33121. OrderStatus: 1,
  33122. IsMedicineInsurance: 1,
  33123. SettleType: settle_accounts_type,
  33124. SettleStartTime: start_time,
  33125. SettleEndTime: end_time,
  33126. Creator: roles.AdminUserId,
  33127. Modify: roles.AdminUserId,
  33128. PType: 2,
  33129. Diagnosis: diagnosis_id,
  33130. }
  33131. err = service.CreateOrder(order)
  33132. if err != nil {
  33133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  33134. return
  33135. }
  33136. }
  33137. adminUser := c.GetAdminUserInfo()
  33138. errlog := &models.HisOrderError{
  33139. UserOrgId: adminUser.CurrentOrgId,
  33140. Ctime: time.Now().Unix(),
  33141. Mtime: time.Now().Unix(),
  33142. ErrMsg: res.ErrMsg,
  33143. Status: 1,
  33144. PatientId: id,
  33145. RecordTime: recordDateTime,
  33146. Stage: 4,
  33147. }
  33148. service.CreateErrMsgLog(errlog)
  33149. c.ServeSuccessJSON(map[string]interface{}{
  33150. "failed_code": -10,
  33151. "msg": res.ErrMsg,
  33152. })
  33153. return
  33154. }
  33155. }
  33156. }
  33157. }
  33158. // 退款
  33159. func (c *HisApiController) Refund() {
  33160. order_id, _ := c.GetInt64("order_id")
  33161. admin_user_id, _ := c.GetInt64("admin_user_id")
  33162. adminUser := c.GetAdminUserInfo()
  33163. var order models.HisOrder
  33164. order, _ = service.GetHisOrderByID(order_id)
  33165. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  33166. if fapiao.ID > 0 {
  33167. c.ServeSuccessJSON(map[string]interface{}{
  33168. "failed_code": -10,
  33169. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  33170. })
  33171. return
  33172. }
  33173. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33174. if order.ID == 0 {
  33175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33176. return
  33177. }
  33178. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33179. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33180. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33181. if config.IsOpen == 1 { //对接了医保,走医保流程
  33182. var res ResultSixteen
  33183. var ahres ResultSevenAH
  33184. var resSixteen10265 ResultSixteen10265
  33185. var resSixteen10265Two ResultSixteen10265Two
  33186. var gz ResultgzSixteen10265Two
  33187. var src_resquest string
  33188. var result string
  33189. if miConfig.MdtrtareaAdmvs == "421300" {
  33190. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33191. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33192. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33193. resp3, requestErr3 := http.Get(api3)
  33194. if requestErr3 != nil {
  33195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33196. return
  33197. }
  33198. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33199. if ioErr3 != nil {
  33200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33202. return
  33203. }
  33204. var respJSON3 map[string]interface{}
  33205. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33208. return
  33209. }
  33210. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33211. userJSONBytes3, _ := json.Marshal(respJSON3)
  33212. fmt.Println("log")
  33213. fmt.Println(string(userJSONBytes3))
  33214. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33215. utils.ErrorLog("解析失败:%v", err)
  33216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33217. return
  33218. }
  33219. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33220. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33221. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33222. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33223. resp3, requestErr3 := http.Get(api3)
  33224. if requestErr3 != nil {
  33225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33226. return
  33227. }
  33228. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33229. if ioErr3 != nil {
  33230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33232. return
  33233. }
  33234. var respJSON3 map[string]interface{}
  33235. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33238. return
  33239. }
  33240. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33241. userJSONBytes3, _ := json.Marshal(respJSON3)
  33242. fmt.Println("log")
  33243. fmt.Println(string(userJSONBytes3))
  33244. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33245. utils.ErrorLog("解析失败:%v", err)
  33246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33247. return
  33248. }
  33249. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33250. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33251. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33252. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33253. resp3, requestErr3 := http.Get(api3)
  33254. if requestErr3 != nil {
  33255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33256. return
  33257. }
  33258. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33259. if ioErr3 != nil {
  33260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33262. return
  33263. }
  33264. var respJSON3 map[string]interface{}
  33265. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33268. return
  33269. }
  33270. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33271. userJSONBytes3, _ := json.Marshal(respJSON3)
  33272. fmt.Println("log")
  33273. fmt.Println(string(userJSONBytes3))
  33274. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33275. utils.ErrorLog("解析失败:%v", err)
  33276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33277. return
  33278. }
  33279. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33280. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33281. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33282. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33283. resp3, requestErr3 := http.Get(api3)
  33284. if requestErr3 != nil {
  33285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33286. return
  33287. }
  33288. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33289. if ioErr3 != nil {
  33290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33292. return
  33293. }
  33294. var respJSON3 map[string]interface{}
  33295. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33298. return
  33299. }
  33300. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33301. userJSONBytes3, _ := json.Marshal(respJSON3)
  33302. fmt.Println("log")
  33303. fmt.Println(string(userJSONBytes3))
  33304. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33305. utils.ErrorLog("解析失败:%v", err)
  33306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33307. return
  33308. }
  33309. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33310. var api3 string
  33311. if miConfig.MdtrtareaAdmvs == "320830" {
  33312. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  33313. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33314. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33315. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33316. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33317. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33318. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33319. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33320. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33321. } else {
  33322. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33323. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33324. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33325. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33326. }
  33327. resp3, requestErr3 := http.Get(api3)
  33328. if requestErr3 != nil {
  33329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33330. return
  33331. }
  33332. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33333. if ioErr3 != nil {
  33334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33336. return
  33337. }
  33338. var respJSON3 map[string]interface{}
  33339. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33342. return
  33343. }
  33344. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33345. userJSONBytes3, _ := json.Marshal(respJSON3)
  33346. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33347. utils.ErrorLog("解析失败:%v", err)
  33348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33349. return
  33350. }
  33351. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33352. res.Output = resSixteen10265.Output
  33353. res.ErrMsg = resSixteen10265.ErrMsg
  33354. res.Cainfo = resSixteen10265.Cainfo
  33355. res.WarnMsg = resSixteen10265.WarnMsg
  33356. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33357. res.Infcode = infocode
  33358. } else if miConfig.MdtrtareaAdmvs == "150404" {
  33359. var api3 string
  33360. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  33361. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33362. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33363. resp3, requestErr3 := http.Get(api3)
  33364. if requestErr3 != nil {
  33365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33366. return
  33367. }
  33368. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33369. if ioErr3 != nil {
  33370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33372. return
  33373. }
  33374. var respJSON3 map[string]interface{}
  33375. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33378. return
  33379. }
  33380. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33381. userJSONBytes3, _ := json.Marshal(respJSON3)
  33382. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33383. utils.ErrorLog("解析失败:%v", err)
  33384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33385. return
  33386. }
  33387. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33388. res.Output = resSixteen10265.Output
  33389. res.ErrMsg = resSixteen10265.ErrMsg
  33390. res.Cainfo = resSixteen10265.Cainfo
  33391. res.WarnMsg = resSixteen10265.WarnMsg
  33392. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33393. res.Infcode = infocode
  33394. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33395. 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)
  33396. var dat map[string]interface{}
  33397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33398. fmt.Println(dat)
  33399. } else {
  33400. fmt.Println(err)
  33401. }
  33402. saveLog(result, src_resquest, "2208", "退费")
  33403. userJSONBytes, _ := json.Marshal(dat)
  33404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33405. utils.ErrorLog("解析失败:%v", err)
  33406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33407. return
  33408. }
  33409. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33410. 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, "")
  33411. var dat map[string]interface{}
  33412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33413. fmt.Println(dat)
  33414. } else {
  33415. fmt.Println(err)
  33416. }
  33417. saveLog(result, src_resquest, "2208", "退费")
  33418. userJSONBytes, _ := json.Marshal(dat)
  33419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33420. utils.ErrorLog("解析失败:%v", err)
  33421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33422. return
  33423. }
  33424. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33425. 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, "")
  33426. var dat map[string]interface{}
  33427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33428. fmt.Println(dat)
  33429. } else {
  33430. fmt.Println(err)
  33431. }
  33432. saveLog(result, src_resquest, "2208", "退费")
  33433. userJSONBytes, _ := json.Marshal(dat)
  33434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33435. utils.ErrorLog("解析失败:%v", err)
  33436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33437. return
  33438. }
  33439. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33440. 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, "")
  33441. var dat map[string]interface{}
  33442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33443. fmt.Println(dat)
  33444. } else {
  33445. fmt.Println(err)
  33446. }
  33447. saveLog(result, src_resquest, "2208", "退费")
  33448. userJSONBytes, _ := json.Marshal(dat)
  33449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33450. utils.ErrorLog("解析失败:%v", err)
  33451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33452. return
  33453. }
  33454. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33455. var api3 string
  33456. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33457. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33458. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33459. resp3, requestErr3 := http.Get(api3)
  33460. if requestErr3 != nil {
  33461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33462. return
  33463. }
  33464. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33465. if ioErr3 != nil {
  33466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33468. return
  33469. }
  33470. var respJSON3 map[string]interface{}
  33471. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33474. return
  33475. }
  33476. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33477. if status == "0" {
  33478. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33479. c.ServeSuccessJSON(map[string]interface{}{
  33480. "failed_code": -10,
  33481. "msg": err_msg,
  33482. })
  33483. return
  33484. }
  33485. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33486. userJSONBytes3, _ := json.Marshal(respJSON3)
  33487. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33488. // utils.ErrorLog("解析失败:%v", err)
  33489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33490. // return
  33491. //}
  33492. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33493. utils.ErrorLog("解析失败:%v", err)
  33494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33495. return
  33496. }
  33497. res.InfRefmsgid = ahres.InfRefmsgid
  33498. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33499. // 创建对应的Time类型
  33500. t := time.UnixMilli(timestamp)
  33501. // 格式化成指定的日期字符串
  33502. str := t.Format("2006-01-02 15:04:05")
  33503. res.Output.Setlinfo.SetlTime = str
  33504. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33505. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33506. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33507. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33508. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33509. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33510. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33511. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33512. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33513. //
  33514. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33515. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33516. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33517. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33518. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33519. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33520. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33521. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33522. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33523. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33524. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33525. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33526. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33527. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33528. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33529. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33530. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33531. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33532. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33533. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33534. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33535. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33536. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33537. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33538. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33539. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33540. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33541. //res.Output.Setldetail = ahres.Output.Setldetail
  33542. res.ErrMsg = ahres.ErrMsg
  33543. res.Cainfo = ahres.Cainfo
  33544. res.WarnMsg = ahres.WarnMsg
  33545. res.Infcode = ahres.Infcode
  33546. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33547. var api3 string
  33548. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33549. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33550. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33551. resp3, requestErr3 := http.Get(api3)
  33552. if requestErr3 != nil {
  33553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33554. return
  33555. }
  33556. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33557. if ioErr3 != nil {
  33558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33560. return
  33561. }
  33562. var respJSON3 map[string]interface{}
  33563. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33566. return
  33567. }
  33568. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33569. if status == "0" {
  33570. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33571. c.ServeSuccessJSON(map[string]interface{}{
  33572. "failed_code": -10,
  33573. "msg": err_msg,
  33574. })
  33575. return
  33576. }
  33577. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33578. userJSONBytes3, _ := json.Marshal(respJSON3)
  33579. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33580. // utils.ErrorLog("解析失败:%v", err)
  33581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33582. // return
  33583. //}
  33584. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33585. utils.ErrorLog("解析失败:%v", err)
  33586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33587. return
  33588. }
  33589. res.InfRefmsgid = ahres.InfRefmsgid
  33590. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33591. // 创建对应的Time类型
  33592. t := time.UnixMilli(timestamp)
  33593. // 格式化成指定的日期字符串
  33594. str := t.Format("2006-01-02 15:04:05")
  33595. res.Output.Setlinfo.SetlTime = str
  33596. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33597. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33598. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33599. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33600. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33601. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33602. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33603. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33604. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33605. //
  33606. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33607. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33608. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33609. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33610. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33611. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33612. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33613. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33614. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33615. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33616. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33617. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33618. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33619. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33620. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33621. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33622. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33623. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33624. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33625. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33626. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33627. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33628. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33629. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33630. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33631. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33632. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33633. //res.Output.Setldetail = ahres.Output.Setldetail
  33634. res.ErrMsg = ahres.ErrMsg
  33635. res.Cainfo = ahres.Cainfo
  33636. res.WarnMsg = ahres.WarnMsg
  33637. res.Infcode = ahres.Infcode
  33638. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33639. 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, "")
  33640. var dat map[string]interface{}
  33641. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33642. fmt.Println(dat)
  33643. } else {
  33644. fmt.Println(err)
  33645. }
  33646. saveLog(result, src_resquest, "2208", "退费")
  33647. userJSONBytes, _ := json.Marshal(dat)
  33648. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33649. utils.ErrorLog("解析失败:%v", err)
  33650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33651. return
  33652. }
  33653. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33654. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33655. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33656. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33657. resp3, requestErr3 := http.Get(api3)
  33658. if requestErr3 != nil {
  33659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33660. return
  33661. }
  33662. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33663. if ioErr3 != nil {
  33664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33666. return
  33667. }
  33668. var respJSON3 map[string]interface{}
  33669. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33672. return
  33673. }
  33674. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33675. userJSONBytes3, _ := json.Marshal(respJSON3)
  33676. fmt.Println("log")
  33677. fmt.Println(string(userJSONBytes3))
  33678. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33679. utils.ErrorLog("解析失败:%v", err)
  33680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33681. return
  33682. }
  33683. } else {
  33684. if miConfig.Code == "H15049901371" {
  33685. 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)
  33686. var dat map[string]interface{}
  33687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33688. fmt.Println(dat)
  33689. } else {
  33690. fmt.Println(err)
  33691. }
  33692. saveLog(result, src_resquest, "2208", "退费")
  33693. if strings.Contains(result, "Post") {
  33694. res.Infcode = -1
  33695. res.ErrMsg = result
  33696. }
  33697. userJSONBytes, _ := json.Marshal(dat)
  33698. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33699. utils.ErrorLog("解析失败:%v", err)
  33700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33701. return
  33702. }
  33703. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33704. res.Output = resSixteen10265.Output
  33705. res.ErrMsg = resSixteen10265.ErrMsg
  33706. res.Cainfo = resSixteen10265.Cainfo
  33707. res.WarnMsg = resSixteen10265.WarnMsg
  33708. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33709. res.Infcode = infocode
  33710. } else {
  33711. 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)
  33712. var dat map[string]interface{}
  33713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33714. fmt.Println(dat)
  33715. } else {
  33716. fmt.Println(err)
  33717. }
  33718. saveLog(result, src_resquest, "2208", "退费")
  33719. userJSONBytes, _ := json.Marshal(dat)
  33720. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33721. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33722. utils.ErrorLog("解析失败:%v", err)
  33723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33724. return
  33725. }
  33726. res.Infcode = gz.Infcode
  33727. } else {
  33728. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33729. utils.ErrorLog("解析失败:%v", err)
  33730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33731. return
  33732. }
  33733. }
  33734. if strings.Contains(result, "Post") {
  33735. res.Infcode = -1
  33736. res.ErrMsg = result
  33737. }
  33738. }
  33739. }
  33740. if res.Infcode == -1 {
  33741. c.ServeSuccessJSON(map[string]interface{}{
  33742. "failed_code": -10,
  33743. "msg": res.ErrMsg,
  33744. })
  33745. return
  33746. }
  33747. if res.Infcode != -1 {
  33748. var res2 ResultSix
  33749. var resSix10265 ResultSix10265
  33750. if miConfig.MdtrtareaAdmvs == "421300" {
  33751. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33752. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33753. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33754. resp3, requestErr3 := http.Get(api3)
  33755. if requestErr3 != nil {
  33756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33757. return
  33758. }
  33759. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33760. if ioErr3 != nil {
  33761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33763. return
  33764. }
  33765. var respJSON3 map[string]interface{}
  33766. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33769. return
  33770. }
  33771. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33772. userJSONBytes3, _ := json.Marshal(respJSON3)
  33773. fmt.Println("log")
  33774. fmt.Println(string(userJSONBytes3))
  33775. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33776. utils.ErrorLog("解析失败:%v", err)
  33777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33778. return
  33779. }
  33780. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33781. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33782. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33784. resp3, requestErr3 := http.Get(api3)
  33785. if requestErr3 != nil {
  33786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33787. return
  33788. }
  33789. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33790. if ioErr3 != nil {
  33791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33793. return
  33794. }
  33795. var respJSON3 map[string]interface{}
  33796. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33799. return
  33800. }
  33801. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33802. userJSONBytes3, _ := json.Marshal(respJSON3)
  33803. fmt.Println("log")
  33804. fmt.Println(string(userJSONBytes3))
  33805. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33806. utils.ErrorLog("解析失败:%v", err)
  33807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33808. return
  33809. }
  33810. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33811. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33812. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33813. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33814. resp3, requestErr3 := http.Get(api3)
  33815. if requestErr3 != nil {
  33816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33817. return
  33818. }
  33819. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33820. if ioErr3 != nil {
  33821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33823. return
  33824. }
  33825. var respJSON3 map[string]interface{}
  33826. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33829. return
  33830. }
  33831. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33832. userJSONBytes3, _ := json.Marshal(respJSON3)
  33833. fmt.Println("log")
  33834. fmt.Println(string(userJSONBytes3))
  33835. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33836. utils.ErrorLog("解析失败:%v", err)
  33837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33838. return
  33839. }
  33840. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33841. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33842. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33844. resp3, requestErr3 := http.Get(api3)
  33845. if requestErr3 != nil {
  33846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33847. return
  33848. }
  33849. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33850. if ioErr3 != nil {
  33851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33853. return
  33854. }
  33855. var respJSON3 map[string]interface{}
  33856. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33859. return
  33860. }
  33861. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33862. userJSONBytes3, _ := json.Marshal(respJSON3)
  33863. fmt.Println("log")
  33864. fmt.Println(string(userJSONBytes3))
  33865. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33866. utils.ErrorLog("解析失败:%v", err)
  33867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33868. return
  33869. }
  33870. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33871. var api3 string
  33872. if miConfig.MdtrtareaAdmvs == "320830" {
  33873. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33874. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33875. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33876. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33877. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33878. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33879. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33880. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33881. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33882. } else {
  33883. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33884. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33885. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33886. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33887. }
  33888. resp3, requestErr3 := http.Get(api3)
  33889. if requestErr3 != nil {
  33890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33891. return
  33892. }
  33893. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33894. if ioErr3 != nil {
  33895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33897. return
  33898. }
  33899. var respJSON3 map[string]interface{}
  33900. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33903. return
  33904. }
  33905. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33906. userJSONBytes3, _ := json.Marshal(respJSON3)
  33907. fmt.Println("log")
  33908. fmt.Println(string(userJSONBytes3))
  33909. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33910. utils.ErrorLog("解析失败:%v", err)
  33911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33912. return
  33913. }
  33914. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33915. res2.Output = resSix10265.Output
  33916. res2.ErrMsg = resSix10265.ErrMsg
  33917. res2.Cainfo = resSix10265.Cainfo
  33918. res2.WarnMsg = resSix10265.WarnMsg
  33919. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33920. res2.Infcode = infocode
  33921. } else if miConfig.MdtrtareaAdmvs == "150404" {
  33922. var api3 string
  33923. new_chrg_bchno := order.Number
  33924. if adminUser.CurrentOrgId == 10265 {
  33925. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33926. new_chrg_bchno = "0000"
  33927. }
  33928. }
  33929. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33930. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33932. resp3, requestErr3 := http.Get(api3)
  33933. if requestErr3 != nil {
  33934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33935. return
  33936. }
  33937. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33938. if ioErr3 != nil {
  33939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33941. return
  33942. }
  33943. var respJSON3 map[string]interface{}
  33944. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33947. return
  33948. }
  33949. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33950. userJSONBytes3, _ := json.Marshal(respJSON3)
  33951. fmt.Println("log")
  33952. fmt.Println(string(userJSONBytes3))
  33953. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33954. utils.ErrorLog("解析失败:%v", err)
  33955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33956. return
  33957. }
  33958. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33959. res2.Output = resSix10265.Output
  33960. res2.ErrMsg = resSix10265.ErrMsg
  33961. res2.Cainfo = resSix10265.Cainfo
  33962. res2.WarnMsg = resSix10265.WarnMsg
  33963. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33964. res2.Infcode = infocode
  33965. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33966. 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)
  33967. var dat map[string]interface{}
  33968. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33969. fmt.Println(dat)
  33970. } else {
  33971. fmt.Println(err)
  33972. }
  33973. saveLog(result2, src_request, "2205", "撤销明细")
  33974. userJSONBytes, _ := json.Marshal(dat)
  33975. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33976. utils.ErrorLog("解析失败:%v", err)
  33977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33978. return
  33979. }
  33980. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33981. 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, "")
  33982. var dat map[string]interface{}
  33983. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33984. fmt.Println(dat)
  33985. } else {
  33986. fmt.Println(err)
  33987. }
  33988. saveLog(result2, src_request, "2205", "撤销明细")
  33989. userJSONBytes, _ := json.Marshal(dat)
  33990. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33991. utils.ErrorLog("解析失败:%v", err)
  33992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33993. return
  33994. }
  33995. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33996. 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, "")
  33997. var dat map[string]interface{}
  33998. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33999. fmt.Println(dat)
  34000. } else {
  34001. fmt.Println(err)
  34002. }
  34003. saveLog(result2, src_request, "2205", "撤销明细")
  34004. userJSONBytes, _ := json.Marshal(dat)
  34005. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34006. utils.ErrorLog("解析失败:%v", err)
  34007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34008. return
  34009. }
  34010. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34011. 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, "")
  34012. var dat map[string]interface{}
  34013. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34014. fmt.Println(dat)
  34015. } else {
  34016. fmt.Println(err)
  34017. }
  34018. saveLog(result2, src_request, "2205", "撤销明细")
  34019. userJSONBytes, _ := json.Marshal(dat)
  34020. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34021. utils.ErrorLog("解析失败:%v", err)
  34022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34023. return
  34024. }
  34025. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34026. var api3 string
  34027. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34028. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34029. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34030. resp3, requestErr3 := http.Get(api3)
  34031. if requestErr3 != nil {
  34032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34033. return
  34034. }
  34035. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34036. if ioErr3 != nil {
  34037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34039. return
  34040. }
  34041. var respJSON3 map[string]interface{}
  34042. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34045. return
  34046. }
  34047. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34048. if status == "0" {
  34049. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34050. c.ServeSuccessJSON(map[string]interface{}{
  34051. "failed_code": -10,
  34052. "msg": err_msg,
  34053. })
  34054. return
  34055. }
  34056. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34057. userJSONBytes3, _ := json.Marshal(respJSON3)
  34058. fmt.Println("log")
  34059. fmt.Println(string(userJSONBytes3))
  34060. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34061. utils.ErrorLog("解析失败:%v", err)
  34062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34063. return
  34064. }
  34065. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34066. 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, "")
  34067. var dat map[string]interface{}
  34068. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34069. fmt.Println(dat)
  34070. } else {
  34071. fmt.Println(err)
  34072. }
  34073. saveLog(result2, src_request, "2205", "撤销明细")
  34074. userJSONBytes, _ := json.Marshal(dat)
  34075. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34076. utils.ErrorLog("解析失败:%v", err)
  34077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34078. return
  34079. }
  34080. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34081. 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, "")
  34082. var dat map[string]interface{}
  34083. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34084. fmt.Println(dat)
  34085. } else {
  34086. fmt.Println(err)
  34087. }
  34088. saveLog(result2, src_request, "2205", "撤销明细")
  34089. userJSONBytes, _ := json.Marshal(dat)
  34090. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34091. utils.ErrorLog("解析失败:%v", err)
  34092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34093. return
  34094. }
  34095. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34096. 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, "")
  34097. var dat map[string]interface{}
  34098. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34099. fmt.Println(dat)
  34100. } else {
  34101. fmt.Println(err)
  34102. }
  34103. saveLog(result2, src_request, "2205", "撤销明细")
  34104. userJSONBytes, _ := json.Marshal(dat)
  34105. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34106. utils.ErrorLog("解析失败:%v", err)
  34107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34108. return
  34109. }
  34110. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34111. var api3 string
  34112. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34113. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34114. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34115. resp3, requestErr3 := http.Get(api3)
  34116. if requestErr3 != nil {
  34117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34118. return
  34119. }
  34120. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34121. if ioErr3 != nil {
  34122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34124. return
  34125. }
  34126. var respJSON3 map[string]interface{}
  34127. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34130. return
  34131. }
  34132. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34133. if status == "0" {
  34134. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34135. c.ServeSuccessJSON(map[string]interface{}{
  34136. "failed_code": -10,
  34137. "msg": err_msg,
  34138. })
  34139. return
  34140. }
  34141. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34142. userJSONBytes3, _ := json.Marshal(respJSON3)
  34143. fmt.Println("log")
  34144. fmt.Println(string(userJSONBytes3))
  34145. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34146. utils.ErrorLog("解析失败:%v", err)
  34147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34148. return
  34149. }
  34150. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34151. 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, "")
  34152. var dat map[string]interface{}
  34153. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34154. fmt.Println(dat)
  34155. } else {
  34156. fmt.Println(err)
  34157. }
  34158. saveLog(result2, src_request, "2205", "撤销明细")
  34159. userJSONBytes, _ := json.Marshal(dat)
  34160. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34161. utils.ErrorLog("解析失败:%v", err)
  34162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34163. return
  34164. }
  34165. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34166. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  34167. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34168. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34169. resp3, requestErr3 := http.Get(api3)
  34170. if requestErr3 != nil {
  34171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34172. return
  34173. }
  34174. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34175. if ioErr3 != nil {
  34176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34178. return
  34179. }
  34180. var respJSON3 map[string]interface{}
  34181. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34184. return
  34185. }
  34186. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34187. userJSONBytes3, _ := json.Marshal(respJSON3)
  34188. fmt.Println("log")
  34189. fmt.Println(string(userJSONBytes3))
  34190. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34191. utils.ErrorLog("解析失败:%v", err)
  34192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34193. return
  34194. }
  34195. } else {
  34196. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34197. res2.Infcode = 0
  34198. } else {
  34199. 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)
  34200. var dat map[string]interface{}
  34201. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34202. fmt.Println(dat)
  34203. } else {
  34204. fmt.Println(err)
  34205. }
  34206. saveLog(result2, src_request, "2205", "撤销明细")
  34207. userJSONBytes, _ := json.Marshal(dat)
  34208. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34209. utils.ErrorLog("解析失败:%v", err)
  34210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34211. return
  34212. }
  34213. }
  34214. }
  34215. if res2.Infcode == -1 {
  34216. c.ServeSuccessJSON(map[string]interface{}{
  34217. "failed_code": -10,
  34218. "msg": res2.ErrMsg,
  34219. })
  34220. return
  34221. }
  34222. if res2.Infcode == 0 {
  34223. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  34224. if err == nil {
  34225. //当押金不为零时产生退费记录
  34226. if order.Decimal != 0 {
  34227. tmp := strconv.FormatInt(order.ID, 10)
  34228. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  34229. if err != nil {
  34230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34231. return
  34232. }
  34233. }
  34234. c.ServeSuccessJSON(map[string]interface{}{
  34235. "msg": "退费成功",
  34236. })
  34237. } else {
  34238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34239. return
  34240. }
  34241. } else {
  34242. c.ServeSuccessJSON(map[string]interface{}{
  34243. "failed_code": -10,
  34244. "msg": res2.ErrMsg,
  34245. })
  34246. }
  34247. } else {
  34248. c.ServeSuccessJSON(map[string]interface{}{
  34249. "failed_code": -10,
  34250. "msg": res.ErrMsg,
  34251. })
  34252. }
  34253. }
  34254. }
  34255. func (c *HisApiController) RefundNumber() {
  34256. record_time := c.GetString("record_time")
  34257. //patient_id, _ := c.GetInt64("patient_id")
  34258. admin_user_id, _ := c.GetInt64("admin_user_id")
  34259. his_patient_id, _ := c.GetInt64("id")
  34260. timeLayout := "2006-01-02"
  34261. loc, _ := time.LoadLocation("Local")
  34262. adminUser := c.GetAdminUserInfo()
  34263. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34264. fmt.Println(err)
  34265. if err != nil {
  34266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34267. return
  34268. }
  34269. recordDateTime := theTime.Unix()
  34270. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34271. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  34272. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34273. //order, _ := service.GetHisOrderByID(order_id)
  34274. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34275. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34276. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34277. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  34278. if count > 0 {
  34279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  34280. return
  34281. }
  34282. if config.IsOpen == 1 { //对接了医保,走医保流程
  34283. var res2 ResultSix
  34284. var res3 GZResultSix
  34285. var resSix10265 ResultSix10265
  34286. if miConfig.MdtrtareaAdmvs == "421300" {
  34287. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34288. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34289. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34290. resp3, requestErr3 := http.Get(api3)
  34291. if requestErr3 != nil {
  34292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34293. return
  34294. }
  34295. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34296. if ioErr3 != nil {
  34297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34299. return
  34300. }
  34301. var respJSON3 map[string]interface{}
  34302. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34305. return
  34306. }
  34307. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34308. userJSONBytes3, _ := json.Marshal(respJSON3)
  34309. fmt.Println("log")
  34310. fmt.Println(string(userJSONBytes3))
  34311. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34312. utils.ErrorLog("解析失败:%v", err)
  34313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34314. return
  34315. }
  34316. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34317. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34318. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34319. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34320. resp3, requestErr3 := http.Get(api3)
  34321. if requestErr3 != nil {
  34322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34323. return
  34324. }
  34325. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34326. if ioErr3 != nil {
  34327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34329. return
  34330. }
  34331. var respJSON3 map[string]interface{}
  34332. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34335. return
  34336. }
  34337. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34338. userJSONBytes3, _ := json.Marshal(respJSON3)
  34339. fmt.Println("log")
  34340. fmt.Println(string(userJSONBytes3))
  34341. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34342. utils.ErrorLog("解析失败:%v", err)
  34343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34344. return
  34345. }
  34346. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34347. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34348. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34349. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34350. resp3, requestErr3 := http.Get(api3)
  34351. if requestErr3 != nil {
  34352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34353. return
  34354. }
  34355. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34356. if ioErr3 != nil {
  34357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34359. return
  34360. }
  34361. var respJSON3 map[string]interface{}
  34362. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34365. return
  34366. }
  34367. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34368. userJSONBytes3, _ := json.Marshal(respJSON3)
  34369. fmt.Println("log")
  34370. fmt.Println(string(userJSONBytes3))
  34371. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34372. utils.ErrorLog("解析失败:%v", err)
  34373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34374. return
  34375. }
  34376. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34377. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34378. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34379. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34380. resp3, requestErr3 := http.Get(api3)
  34381. if requestErr3 != nil {
  34382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34383. return
  34384. }
  34385. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34386. if ioErr3 != nil {
  34387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34389. return
  34390. }
  34391. var respJSON3 map[string]interface{}
  34392. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34395. return
  34396. }
  34397. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34398. userJSONBytes3, _ := json.Marshal(respJSON3)
  34399. fmt.Println("log")
  34400. fmt.Println(string(userJSONBytes3))
  34401. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34402. utils.ErrorLog("解析失败:%v", err)
  34403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34404. return
  34405. }
  34406. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34407. var api3 string
  34408. if miConfig.MdtrtareaAdmvs == "320830" {
  34409. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34410. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34411. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34412. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34413. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34414. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34415. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34416. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34417. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34418. } else {
  34419. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34420. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34421. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34422. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34423. }
  34424. resp3, requestErr3 := http.Get(api3)
  34425. if requestErr3 != nil {
  34426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34427. return
  34428. }
  34429. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34430. if ioErr3 != nil {
  34431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34433. return
  34434. }
  34435. var respJSON3 map[string]interface{}
  34436. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34439. return
  34440. }
  34441. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34442. userJSONBytes3, _ := json.Marshal(respJSON3)
  34443. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34444. utils.ErrorLog("解析失败:%v", err)
  34445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34446. return
  34447. }
  34448. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34449. res2.Output = resSix10265.Output
  34450. res2.ErrMsg = resSix10265.ErrMsg
  34451. res2.Cainfo = resSix10265.Cainfo
  34452. res2.WarnMsg = resSix10265.WarnMsg
  34453. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34454. res2.Infcode = infocode
  34455. } else if miConfig.MdtrtareaAdmvs == "150404" {
  34456. var api3 string
  34457. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34458. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34459. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34460. resp3, requestErr3 := http.Get(api3)
  34461. if requestErr3 != nil {
  34462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34463. return
  34464. }
  34465. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34466. if ioErr3 != nil {
  34467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34469. return
  34470. }
  34471. var respJSON3 map[string]interface{}
  34472. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34475. return
  34476. }
  34477. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34478. userJSONBytes3, _ := json.Marshal(respJSON3)
  34479. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34480. utils.ErrorLog("解析失败:%v", err)
  34481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34482. return
  34483. }
  34484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34485. res2.Output = resSix10265.Output
  34486. res2.ErrMsg = resSix10265.ErrMsg
  34487. res2.Cainfo = resSix10265.Cainfo
  34488. res2.WarnMsg = resSix10265.WarnMsg
  34489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34490. res2.Infcode = infocode
  34491. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34492. 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)
  34493. var dat map[string]interface{}
  34494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34495. fmt.Println(dat)
  34496. } else {
  34497. fmt.Println(err)
  34498. }
  34499. saveLog(result, request, "2202", "退号")
  34500. userJSONBytes, _ := json.Marshal(dat)
  34501. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34502. utils.ErrorLog("解析失败:%v", err)
  34503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34504. return
  34505. }
  34506. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34507. 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, "")
  34508. var dat map[string]interface{}
  34509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34510. fmt.Println(dat)
  34511. } else {
  34512. fmt.Println(err)
  34513. }
  34514. saveLog(result, request, "2202", "退号")
  34515. userJSONBytes, _ := json.Marshal(dat)
  34516. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34517. utils.ErrorLog("解析失败:%v", err)
  34518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34519. return
  34520. }
  34521. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34522. 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, "")
  34523. var dat map[string]interface{}
  34524. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34525. fmt.Println(dat)
  34526. } else {
  34527. fmt.Println(err)
  34528. }
  34529. saveLog(result, request, "2202", "退号")
  34530. userJSONBytes, _ := json.Marshal(dat)
  34531. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34532. utils.ErrorLog("解析失败:%v", err)
  34533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34534. return
  34535. }
  34536. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34537. 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, "")
  34538. var dat map[string]interface{}
  34539. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34540. fmt.Println(dat)
  34541. } else {
  34542. fmt.Println(err)
  34543. }
  34544. saveLog(result, request, "2202", "退号")
  34545. userJSONBytes, _ := json.Marshal(dat)
  34546. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34547. utils.ErrorLog("解析失败:%v", err)
  34548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34549. return
  34550. }
  34551. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34552. var api3 string
  34553. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34554. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34555. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34556. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34557. resp3, requestErr3 := http.Get(api3)
  34558. if requestErr3 != nil {
  34559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34560. return
  34561. }
  34562. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34563. if ioErr3 != nil {
  34564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34566. return
  34567. }
  34568. var respJSON3 map[string]interface{}
  34569. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34572. return
  34573. }
  34574. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34575. if status == "0" {
  34576. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34577. c.ServeSuccessJSON(map[string]interface{}{
  34578. "failed_code": -10,
  34579. "msg": err_msg,
  34580. })
  34581. return
  34582. }
  34583. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34584. userJSONBytes3, _ := json.Marshal(respJSON3)
  34585. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34586. utils.ErrorLog("解析失败:%v", err)
  34587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34588. return
  34589. }
  34590. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34591. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34592. var api3 string
  34593. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34594. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34595. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34596. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34597. resp3, requestErr3 := http.Get(api3)
  34598. if requestErr3 != nil {
  34599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34600. return
  34601. }
  34602. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34603. if ioErr3 != nil {
  34604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34606. return
  34607. }
  34608. var respJSON3 map[string]interface{}
  34609. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34612. return
  34613. }
  34614. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34615. if status == "0" {
  34616. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34617. c.ServeSuccessJSON(map[string]interface{}{
  34618. "failed_code": -10,
  34619. "msg": err_msg,
  34620. })
  34621. return
  34622. }
  34623. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34624. userJSONBytes3, _ := json.Marshal(respJSON3)
  34625. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34626. utils.ErrorLog("解析失败:%v", err)
  34627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34628. return
  34629. }
  34630. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34631. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34632. 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, "")
  34633. var dat map[string]interface{}
  34634. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34635. fmt.Println(dat)
  34636. } else {
  34637. fmt.Println(err)
  34638. }
  34639. saveLog(result, request, "2202", "退号")
  34640. userJSONBytes, _ := json.Marshal(dat)
  34641. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34642. utils.ErrorLog("解析失败:%v", err)
  34643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34644. return
  34645. }
  34646. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34647. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34648. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34649. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34650. resp3, requestErr3 := http.Get(api3)
  34651. if requestErr3 != nil {
  34652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34653. return
  34654. }
  34655. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34656. if ioErr3 != nil {
  34657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34659. return
  34660. }
  34661. var respJSON3 map[string]interface{}
  34662. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34665. return
  34666. }
  34667. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34668. userJSONBytes3, _ := json.Marshal(respJSON3)
  34669. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34670. utils.ErrorLog("解析失败:%v", err)
  34671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34672. return
  34673. }
  34674. } else {
  34675. var api3 string
  34676. if miConfig.Code == "H15049901371" {
  34677. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34678. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34679. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34680. } else {
  34681. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34682. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34683. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34684. }
  34685. resp3, requestErr3 := http.Get(api3)
  34686. if requestErr3 != nil {
  34687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34688. return
  34689. }
  34690. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34691. if ioErr3 != nil {
  34692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34694. return
  34695. }
  34696. var respJSON3 map[string]interface{}
  34697. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34700. return
  34701. }
  34702. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34703. userJSONBytes3, _ := json.Marshal(respJSON3)
  34704. if miConfig.Code == "H15049901371" {
  34705. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34706. utils.ErrorLog("解析失败:%v", err)
  34707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34708. return
  34709. }
  34710. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34711. res2.Output = resSix10265.Output
  34712. res2.ErrMsg = resSix10265.ErrMsg
  34713. res2.Cainfo = resSix10265.Cainfo
  34714. res2.WarnMsg = resSix10265.WarnMsg
  34715. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34716. res2.Infcode = infocode
  34717. } else {
  34718. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34719. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34720. utils.ErrorLog("解析失败:%v", err)
  34721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34722. return
  34723. }
  34724. res2.Infcode = res3.Infcode
  34725. } else {
  34726. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34727. utils.ErrorLog("解析失败:%v", err)
  34728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34729. return
  34730. }
  34731. }
  34732. }
  34733. }
  34734. if res2.Infcode == -1 {
  34735. c.ServeSuccessJSON(map[string]interface{}{
  34736. "failed_code": -10,
  34737. "msg": res2.ErrMsg,
  34738. })
  34739. return
  34740. }
  34741. if res2.Infcode == 0 {
  34742. if err == nil {
  34743. c.ServeSuccessJSON(map[string]interface{}{
  34744. "msg": "退号成功",
  34745. })
  34746. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34747. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34748. } else {
  34749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34750. return
  34751. }
  34752. }
  34753. } else {
  34754. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34755. //if err == nil {
  34756. // c.ServeSuccessJSON(map[string]interface{}{
  34757. // "msg": "退费成功",
  34758. // })
  34759. //} else {
  34760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34761. // return
  34762. //}
  34763. }
  34764. }
  34765. func (c *HisApiController) RefundDetail() {
  34766. order_id, _ := c.GetInt64("order_id")
  34767. admin_user_id, _ := c.GetInt64("admin_user_id")
  34768. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34769. number := c.GetString("number")
  34770. record_time := c.GetString("record_time")
  34771. patient_id, _ := c.GetInt64("patient_id")
  34772. //med_type, _ := c.GetInt64("med_type")
  34773. timeLayout := "2006-01-02"
  34774. loc, _ := time.LoadLocation("Local")
  34775. adminUser := c.GetAdminUserInfo()
  34776. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34777. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34778. fmt.Println(err)
  34779. if err != nil {
  34780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34781. return
  34782. }
  34783. recordDateTime := theTime.Unix()
  34784. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34785. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34786. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34787. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34788. var order models.HisOrder
  34789. order, _ = service.GetHisOrderByID(order_id)
  34790. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34791. if config.IsOpen == 1 { //对接了医保,走医保流程
  34792. var res2 ResultSix
  34793. if miConfig.MdtrtareaAdmvs == "421300" {
  34794. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34795. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34797. resp3, requestErr3 := http.Get(api3)
  34798. if requestErr3 != nil {
  34799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34800. return
  34801. }
  34802. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34803. if ioErr3 != nil {
  34804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34806. return
  34807. }
  34808. var respJSON3 map[string]interface{}
  34809. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34812. return
  34813. }
  34814. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34815. userJSONBytes3, _ := json.Marshal(respJSON3)
  34816. fmt.Println("log")
  34817. fmt.Println(string(userJSONBytes3))
  34818. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34819. utils.ErrorLog("解析失败:%v", err)
  34820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34821. return
  34822. }
  34823. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34824. if err == nil {
  34825. c.ServeSuccessJSON(map[string]interface{}{
  34826. "msg": "撤销明细成功",
  34827. })
  34828. return
  34829. } else {
  34830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34831. return
  34832. }
  34833. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34834. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34835. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34836. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34837. resp3, requestErr3 := http.Get(api3)
  34838. if requestErr3 != nil {
  34839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34840. return
  34841. }
  34842. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34843. if ioErr3 != nil {
  34844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34846. return
  34847. }
  34848. var respJSON3 map[string]interface{}
  34849. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34852. return
  34853. }
  34854. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34855. userJSONBytes3, _ := json.Marshal(respJSON3)
  34856. fmt.Println("log")
  34857. fmt.Println(string(userJSONBytes3))
  34858. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34859. utils.ErrorLog("解析失败:%v", err)
  34860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34861. return
  34862. }
  34863. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34864. if err == nil {
  34865. c.ServeSuccessJSON(map[string]interface{}{
  34866. "msg": "撤销明细成功",
  34867. })
  34868. return
  34869. } else {
  34870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34871. return
  34872. }
  34873. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34874. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34875. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34876. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34877. resp3, requestErr3 := http.Get(api3)
  34878. if requestErr3 != nil {
  34879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34880. return
  34881. }
  34882. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34883. if ioErr3 != nil {
  34884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34886. return
  34887. }
  34888. var respJSON3 map[string]interface{}
  34889. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34892. return
  34893. }
  34894. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34895. userJSONBytes3, _ := json.Marshal(respJSON3)
  34896. fmt.Println("log")
  34897. fmt.Println(string(userJSONBytes3))
  34898. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34899. utils.ErrorLog("解析失败:%v", err)
  34900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34901. return
  34902. }
  34903. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34904. if err == nil {
  34905. c.ServeSuccessJSON(map[string]interface{}{
  34906. "msg": "撤销明细成功",
  34907. })
  34908. return
  34909. } else {
  34910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34911. return
  34912. }
  34913. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34914. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34915. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34916. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34917. resp3, requestErr3 := http.Get(api3)
  34918. if requestErr3 != nil {
  34919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34920. return
  34921. }
  34922. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34923. if ioErr3 != nil {
  34924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34926. return
  34927. }
  34928. var respJSON3 map[string]interface{}
  34929. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34932. return
  34933. }
  34934. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34935. userJSONBytes3, _ := json.Marshal(respJSON3)
  34936. fmt.Println("log")
  34937. fmt.Println(string(userJSONBytes3))
  34938. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34939. utils.ErrorLog("解析失败:%v", err)
  34940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34941. return
  34942. }
  34943. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34944. if err == nil {
  34945. c.ServeSuccessJSON(map[string]interface{}{
  34946. "msg": "撤销明细成功",
  34947. })
  34948. return
  34949. } else {
  34950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34951. return
  34952. }
  34953. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34954. var resSix10265 ResultSix10265
  34955. var api3 string
  34956. if miConfig.MdtrtareaAdmvs == "320830" {
  34957. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34958. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34960. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34961. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34962. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34963. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34964. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34965. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34966. } else {
  34967. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34968. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34969. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34970. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34971. }
  34972. resp3, requestErr3 := http.Get(api3)
  34973. utils.ErrorLog("接口: %v", requestErr3)
  34974. if requestErr3 != nil {
  34975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34976. return
  34977. }
  34978. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34979. if ioErr3 != nil {
  34980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34982. return
  34983. }
  34984. var respJSON3 map[string]interface{}
  34985. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34988. return
  34989. }
  34990. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34991. userJSONBytes3, _ := json.Marshal(respJSON3)
  34992. fmt.Println("log")
  34993. fmt.Println(string(userJSONBytes3))
  34994. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34995. utils.ErrorLog("解析失败:%v", err)
  34996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34997. return
  34998. }
  34999. res2.InfRefmsgid = resSix10265.InfRefmsgid
  35000. res2.Output = resSix10265.Output
  35001. res2.ErrMsg = resSix10265.ErrMsg
  35002. res2.Cainfo = resSix10265.Cainfo
  35003. res2.WarnMsg = resSix10265.WarnMsg
  35004. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35005. res2.Infcode = infocode
  35006. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35007. if err == nil {
  35008. c.ServeSuccessJSON(map[string]interface{}{
  35009. "msg": "撤销明细成功",
  35010. })
  35011. return
  35012. } else {
  35013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35014. return
  35015. }
  35016. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35017. var api3 string
  35018. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  35019. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35020. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35021. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35022. resp3, requestErr3 := http.Get(api3)
  35023. utils.ErrorLog("接口: %v", requestErr3)
  35024. if requestErr3 != nil {
  35025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35026. return
  35027. }
  35028. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35029. if ioErr3 != nil {
  35030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35032. return
  35033. }
  35034. var respJSON3 map[string]interface{}
  35035. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35038. return
  35039. }
  35040. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  35041. if status == "0" {
  35042. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  35043. c.ServeSuccessJSON(map[string]interface{}{
  35044. "failed_code": -10,
  35045. "msg": err_msg,
  35046. })
  35047. return
  35048. }
  35049. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35050. userJSONBytes3, _ := json.Marshal(respJSON3)
  35051. fmt.Println("log")
  35052. fmt.Println(string(userJSONBytes3))
  35053. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35054. utils.ErrorLog("解析失败:%v", err)
  35055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35056. return
  35057. }
  35058. fmt.Println(res2.Infcode)
  35059. if res2.Infcode == -1 {
  35060. c.ServeSuccessJSON(map[string]interface{}{
  35061. "failed_code": -10,
  35062. "msg": res2.ErrMsg,
  35063. })
  35064. return
  35065. }
  35066. if res2.Infcode == 0 {
  35067. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35068. if err == nil {
  35069. c.ServeSuccessJSON(map[string]interface{}{
  35070. "msg": "撤销明细成功",
  35071. })
  35072. return
  35073. } else {
  35074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35075. return
  35076. }
  35077. } else {
  35078. c.ServeSuccessJSON(map[string]interface{}{
  35079. "failed_code": -10,
  35080. "msg": res2.ErrMsg,
  35081. })
  35082. }
  35083. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35084. if err == nil {
  35085. c.ServeSuccessJSON(map[string]interface{}{
  35086. "msg": "撤销明细成功",
  35087. })
  35088. return
  35089. } else {
  35090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35091. return
  35092. }
  35093. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35094. var api3 string
  35095. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  35096. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35097. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35098. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35099. resp3, requestErr3 := http.Get(api3)
  35100. utils.ErrorLog("接口: %v", requestErr3)
  35101. if requestErr3 != nil {
  35102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35103. return
  35104. }
  35105. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35106. if ioErr3 != nil {
  35107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35109. return
  35110. }
  35111. var respJSON3 map[string]interface{}
  35112. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35115. return
  35116. }
  35117. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  35118. if status == "0" {
  35119. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  35120. c.ServeSuccessJSON(map[string]interface{}{
  35121. "failed_code": -10,
  35122. "msg": err_msg,
  35123. })
  35124. return
  35125. }
  35126. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35127. userJSONBytes3, _ := json.Marshal(respJSON3)
  35128. fmt.Println("log")
  35129. fmt.Println(string(userJSONBytes3))
  35130. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35131. utils.ErrorLog("解析失败:%v", err)
  35132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35133. return
  35134. }
  35135. fmt.Println(res2.Infcode)
  35136. if res2.Infcode == -1 {
  35137. c.ServeSuccessJSON(map[string]interface{}{
  35138. "failed_code": -10,
  35139. "msg": res2.ErrMsg,
  35140. })
  35141. return
  35142. }
  35143. if res2.Infcode == 0 {
  35144. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35145. if err == nil {
  35146. c.ServeSuccessJSON(map[string]interface{}{
  35147. "msg": "撤销明细成功",
  35148. })
  35149. return
  35150. } else {
  35151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35152. return
  35153. }
  35154. } else {
  35155. c.ServeSuccessJSON(map[string]interface{}{
  35156. "failed_code": -10,
  35157. "msg": res2.ErrMsg,
  35158. })
  35159. }
  35160. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35161. if err == nil {
  35162. c.ServeSuccessJSON(map[string]interface{}{
  35163. "msg": "撤销明细成功",
  35164. })
  35165. return
  35166. } else {
  35167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35168. return
  35169. }
  35170. } else if miConfig.MdtrtareaAdmvs == "150404" {
  35171. var resSix10265 ResultSix10265
  35172. new_chrg_bchno := order.Number
  35173. if adminUser.CurrentOrgId == 10265 {
  35174. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  35175. new_chrg_bchno = "0000"
  35176. }
  35177. }
  35178. var api3 string
  35179. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  35180. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35181. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35182. resp3, requestErr3 := http.Get(api3)
  35183. if requestErr3 != nil {
  35184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35185. return
  35186. }
  35187. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35188. if ioErr3 != nil {
  35189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35191. return
  35192. }
  35193. var respJSON3 map[string]interface{}
  35194. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35197. return
  35198. }
  35199. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35200. userJSONBytes3, _ := json.Marshal(respJSON3)
  35201. fmt.Println("log")
  35202. fmt.Println(string(userJSONBytes3))
  35203. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  35204. utils.ErrorLog("解析失败:%v", err)
  35205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35206. return
  35207. }
  35208. res2.InfRefmsgid = resSix10265.InfRefmsgid
  35209. res2.Output = resSix10265.Output
  35210. res2.ErrMsg = resSix10265.ErrMsg
  35211. res2.Cainfo = resSix10265.Cainfo
  35212. res2.WarnMsg = resSix10265.WarnMsg
  35213. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35214. res2.Infcode = infocode
  35215. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35216. if err == nil {
  35217. c.ServeSuccessJSON(map[string]interface{}{
  35218. "msg": "撤销明细成功",
  35219. })
  35220. return
  35221. } else {
  35222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35223. return
  35224. }
  35225. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35226. 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)
  35227. var dat map[string]interface{}
  35228. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35229. fmt.Println(dat)
  35230. } else {
  35231. fmt.Println(err)
  35232. }
  35233. saveLog(result2, src_request, "2205", "撤销明细")
  35234. userJSONBytes, _ := json.Marshal(dat)
  35235. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35236. utils.ErrorLog("解析失败:%v", err)
  35237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35238. return
  35239. }
  35240. if res2.Infcode == 0 {
  35241. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35242. if err == nil {
  35243. c.ServeSuccessJSON(map[string]interface{}{
  35244. "msg": "撤销明细成功",
  35245. })
  35246. return
  35247. } else {
  35248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35249. return
  35250. }
  35251. } else {
  35252. c.ServeSuccessJSON(map[string]interface{}{
  35253. "failed_code": -10,
  35254. "msg": res2.ErrMsg,
  35255. })
  35256. }
  35257. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35258. 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, "")
  35259. var dat map[string]interface{}
  35260. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35261. fmt.Println(dat)
  35262. } else {
  35263. fmt.Println(err)
  35264. }
  35265. saveLog(result2, src_request, "2205", "撤销明细")
  35266. userJSONBytes, _ := json.Marshal(dat)
  35267. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35268. utils.ErrorLog("解析失败:%v", err)
  35269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35270. return
  35271. }
  35272. if res2.Infcode == 0 {
  35273. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35274. if err == nil {
  35275. c.ServeSuccessJSON(map[string]interface{}{
  35276. "msg": "撤销明细成功",
  35277. })
  35278. return
  35279. } else {
  35280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35281. return
  35282. }
  35283. } else {
  35284. c.ServeSuccessJSON(map[string]interface{}{
  35285. "failed_code": -10,
  35286. "msg": res2.ErrMsg,
  35287. })
  35288. }
  35289. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35290. 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, "")
  35291. var dat map[string]interface{}
  35292. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35293. fmt.Println(dat)
  35294. } else {
  35295. fmt.Println(err)
  35296. }
  35297. saveLog(result2, src_request, "2205", "撤销明细")
  35298. userJSONBytes, _ := json.Marshal(dat)
  35299. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35300. utils.ErrorLog("解析失败:%v", err)
  35301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35302. return
  35303. }
  35304. if res2.Infcode == 0 {
  35305. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35306. if err == nil {
  35307. c.ServeSuccessJSON(map[string]interface{}{
  35308. "msg": "撤销明细成功",
  35309. })
  35310. return
  35311. } else {
  35312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35313. return
  35314. }
  35315. } else {
  35316. c.ServeSuccessJSON(map[string]interface{}{
  35317. "failed_code": -10,
  35318. "msg": res2.ErrMsg,
  35319. })
  35320. }
  35321. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35322. 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, "")
  35323. var dat map[string]interface{}
  35324. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35325. fmt.Println(dat)
  35326. } else {
  35327. fmt.Println(err)
  35328. }
  35329. saveLog(result2, src_request, "2205", "撤销明细")
  35330. userJSONBytes, _ := json.Marshal(dat)
  35331. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35332. utils.ErrorLog("解析失败:%v", err)
  35333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35334. return
  35335. }
  35336. if res2.Infcode == 0 {
  35337. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35338. if err == nil {
  35339. c.ServeSuccessJSON(map[string]interface{}{
  35340. "msg": "撤销明细成功",
  35341. })
  35342. return
  35343. } else {
  35344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35345. return
  35346. }
  35347. } else {
  35348. c.ServeSuccessJSON(map[string]interface{}{
  35349. "failed_code": -10,
  35350. "msg": res2.ErrMsg,
  35351. })
  35352. }
  35353. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35354. 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, "")
  35355. var dat map[string]interface{}
  35356. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35357. fmt.Println(dat)
  35358. } else {
  35359. fmt.Println(err)
  35360. }
  35361. saveLog(result2, src_request, "2205", "撤销明细")
  35362. userJSONBytes, _ := json.Marshal(dat)
  35363. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35364. utils.ErrorLog("解析失败:%v", err)
  35365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35366. return
  35367. }
  35368. if res2.Infcode == 0 {
  35369. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35370. if err == nil {
  35371. c.ServeSuccessJSON(map[string]interface{}{
  35372. "msg": "撤销明细成功",
  35373. })
  35374. return
  35375. } else {
  35376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35377. return
  35378. }
  35379. } else {
  35380. c.ServeSuccessJSON(map[string]interface{}{
  35381. "failed_code": -10,
  35382. "msg": res2.ErrMsg,
  35383. })
  35384. }
  35385. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35386. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  35387. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35388. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35389. resp2, requestErr2 := http.Get(api2)
  35390. if requestErr2 != nil {
  35391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35392. return
  35393. }
  35394. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35395. if ioErr2 != nil {
  35396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35398. return
  35399. }
  35400. var respJSON2 map[string]interface{}
  35401. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35404. return
  35405. }
  35406. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35407. userJSONBytes3, _ := json.Marshal(respJSON2)
  35408. fmt.Println("log")
  35409. fmt.Println(string(userJSONBytes3))
  35410. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35411. utils.ErrorLog("解析失败:%v", err)
  35412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35413. return
  35414. }
  35415. if res2.Infcode == 0 {
  35416. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35417. if err == nil {
  35418. c.ServeSuccessJSON(map[string]interface{}{
  35419. "msg": "撤销明细成功",
  35420. })
  35421. return
  35422. } else {
  35423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35424. return
  35425. }
  35426. } else {
  35427. c.ServeSuccessJSON(map[string]interface{}{
  35428. "failed_code": -10,
  35429. "msg": res2.ErrMsg,
  35430. })
  35431. }
  35432. } else {
  35433. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35434. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35435. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35436. resp2, requestErr2 := http.Get(api2)
  35437. if requestErr2 != nil {
  35438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35439. return
  35440. }
  35441. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35442. if ioErr2 != nil {
  35443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35445. return
  35446. }
  35447. var respJSON2 map[string]interface{}
  35448. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35451. return
  35452. }
  35453. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35454. userJSONBytes3, _ := json.Marshal(respJSON2)
  35455. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35456. utils.ErrorLog("解析失败:%v", err)
  35457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35458. return
  35459. }
  35460. if res2.Infcode == -1 {
  35461. c.ServeSuccessJSON(map[string]interface{}{
  35462. "failed_code": -10,
  35463. "msg": res2.ErrMsg,
  35464. })
  35465. return
  35466. } else {
  35467. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35468. if err == nil {
  35469. c.ServeSuccessJSON(map[string]interface{}{
  35470. "msg": "撤销明细成功",
  35471. })
  35472. return
  35473. } else {
  35474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35475. return
  35476. }
  35477. }
  35478. }
  35479. } else {
  35480. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35481. if err == nil {
  35482. c.ServeSuccessJSON(map[string]interface{}{
  35483. "msg": "退费成功",
  35484. })
  35485. } else {
  35486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35487. return
  35488. }
  35489. }
  35490. }
  35491. // 对账
  35492. func (c *HisApiController) GetCheckAccount() {
  35493. start_time := c.GetString("start_time")
  35494. end_time := c.GetString("end_time")
  35495. insutype := c.GetString("insutype")
  35496. clr_type := c.GetString("clr_type")
  35497. clr_org := c.GetString("clr_optins")
  35498. admin_user_id, _ := c.GetInt64("admin_user_id")
  35499. adminUser := c.GetAdminUserInfo()
  35500. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35501. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35502. if len(clr_org) == 0 {
  35503. clr_org = miConfig.InsuplcAdmdvs
  35504. }
  35505. timeLayout := "2006-01-02"
  35506. loc, _ := time.LoadLocation("Local")
  35507. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35508. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35509. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35510. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35511. fixmedins_setl_cnt := int64(len(orders))
  35512. var medfee_sumamt float64
  35513. var acct_pay float64
  35514. var fund_pay_sumamt float64
  35515. for _, item := range orders {
  35516. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35517. acct_pay = acct_pay + item.AcctPay
  35518. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35519. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35520. } else {
  35521. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35522. }
  35523. }
  35524. var user_name string
  35525. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35526. if role.ID == 0 {
  35527. user_name = "xxx"
  35528. } else {
  35529. user_name = role.UserName
  35530. }
  35531. var res ResultEight
  35532. var res10188 ResultEightFor10188
  35533. if config.IsOpen == 1 {
  35534. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35535. api := miConfig.AppSecret + "jsyb/3201?" +
  35536. "insutype=" + insutype +
  35537. "&clr_type=" + clr_type +
  35538. "&setl_optins=" + clr_org +
  35539. "&stmt_begndate=" + start_time +
  35540. "&stm_enddate=" + end_time +
  35541. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35542. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35543. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35544. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35545. "&fixmedins_code=" + miConfig.Code +
  35546. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35547. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35548. "&secret_key=" + miConfig.SecretKey +
  35549. "&org_name=" + miConfig.OrgName +
  35550. "&doctor=" + user_name +
  35551. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35552. fmt.Println(api)
  35553. resp, requestErr := http.Get(api)
  35554. if requestErr != nil {
  35555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35556. return
  35557. }
  35558. body, ioErr := ioutil.ReadAll(resp.Body)
  35559. fmt.Println(body)
  35560. if ioErr != nil {
  35561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35563. return
  35564. }
  35565. var respJSON map[string]interface{}
  35566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35569. return
  35570. }
  35571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35572. userJSONBytes, _ := json.Marshal(respJSON)
  35573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35574. utils.ErrorLog("解析失败:%v", err)
  35575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35576. return
  35577. }
  35578. res.InfRefmsgid = res10188.InfRefmsgid
  35579. res.Output = res10188.Output
  35580. res.ErrMsg = res10188.ErrMsg
  35581. res.Cainfo = res10188.Cainfo
  35582. res.WarnMsg = res10188.WarnMsg
  35583. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35584. res.Infcode = infocode
  35585. } else if miConfig.MdtrtareaAdmvs == "150404" {
  35586. if clr_type != "9903" {
  35587. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35588. }
  35589. if clr_type == "9903" {
  35590. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35591. }
  35592. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35593. "insutype=" + insutype +
  35594. "&clr_type=" + clr_type +
  35595. "&setl_optins=" + clr_org +
  35596. "&stmt_begndate=" + start_time +
  35597. "&stm_enddate=" + end_time +
  35598. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35599. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35600. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35601. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35602. "&fixmedins_code=" + miConfig.Code +
  35603. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35604. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35605. "&secret_key=" + miConfig.SecretKey +
  35606. "&org_name=" + miConfig.OrgName +
  35607. "&doctor=" + user_name
  35608. resp, requestErr := http.Get(api)
  35609. if requestErr != nil {
  35610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35611. return
  35612. }
  35613. body, ioErr := ioutil.ReadAll(resp.Body)
  35614. if ioErr != nil {
  35615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35617. return
  35618. }
  35619. var respJSON map[string]interface{}
  35620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35623. return
  35624. }
  35625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35626. result, _ := json.Marshal(respJSON)
  35627. fmt.Println("log")
  35628. fmt.Println(string(result))
  35629. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35630. utils.ErrorLog("解析失败:%v", err)
  35631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35632. return
  35633. }
  35634. res.InfRefmsgid = res10188.InfRefmsgid
  35635. res.Output = res10188.Output
  35636. res.ErrMsg = res10188.ErrMsg
  35637. res.Cainfo = res10188.Cainfo
  35638. res.WarnMsg = res10188.WarnMsg
  35639. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35640. res.Infcode = infocode
  35641. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35642. var baseParams models.BaseParams
  35643. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35644. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35645. baseParams.SecretKey = miConfig.SecretKey
  35646. baseParams.OrgName = miConfig.OrgName
  35647. baseParams.FixmedinsCode = miConfig.Code
  35648. baseParams.EncKey = miConfig.EncKey
  35649. baseParams.AppSecret = miConfig.AppSecret
  35650. baseParams.SignKey = miConfig.SignKey
  35651. baseParams.AppID = miConfig.Code
  35652. baseParams.Doctor = role.UserName
  35653. baseParams.RequestUrl = miConfig.Url
  35654. businessParams := models.BusinessParams{
  35655. Insutype: insutype,
  35656. ClrType: clr_type,
  35657. SetlOptins: clr_org,
  35658. StmtBegndate: start_time,
  35659. StmtEnddate: end_time,
  35660. MedfeeSumamt: medfee_sumamt,
  35661. FundPaySumamt: fund_pay_sumamt,
  35662. AcctPay: acct_pay,
  35663. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35664. }
  35665. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35666. fmt.Println(requestLog)
  35667. fmt.Println(result)
  35668. fmt.Println(err_msg)
  35669. var dat map[string]interface{}
  35670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35671. fmt.Println(dat)
  35672. } else {
  35673. fmt.Println(err)
  35674. }
  35675. userJSONBytes, _ := json.Marshal(dat)
  35676. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35677. utils.ErrorLog("解析失败:%v", err)
  35678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35679. return
  35680. }
  35681. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35682. var baseParams models.BaseParams
  35683. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35684. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35685. baseParams.SecretKey = miConfig.SecretKey
  35686. baseParams.OrgName = miConfig.OrgName
  35687. baseParams.FixmedinsCode = miConfig.Code
  35688. baseParams.EncKey = miConfig.EncKey
  35689. baseParams.AppSecret = miConfig.AppSecret
  35690. baseParams.SignKey = miConfig.SignKey
  35691. baseParams.AppID = miConfig.Code
  35692. baseParams.Doctor = role.UserName
  35693. baseParams.RequestUrl = miConfig.Url
  35694. baseParams.AccessKey = miConfig.AccessKey
  35695. businessParams := models.BusinessParams{
  35696. Insutype: insutype,
  35697. ClrType: clr_type,
  35698. SetlOptins: "430822",
  35699. StmtBegndate: start_time,
  35700. StmtEnddate: end_time,
  35701. MedfeeSumamt: medfee_sumamt,
  35702. FundPaySumamt: fund_pay_sumamt,
  35703. AcctPay: acct_pay,
  35704. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35705. }
  35706. 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)
  35707. fmt.Println(requestLog)
  35708. fmt.Println(result)
  35709. var dat map[string]interface{}
  35710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35711. fmt.Println(dat)
  35712. } else {
  35713. fmt.Println(err)
  35714. }
  35715. userJSONBytes, _ := json.Marshal(dat)
  35716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35717. utils.ErrorLog("解析失败:%v", err)
  35718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35719. return
  35720. }
  35721. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35722. var baseParams models.BaseParams
  35723. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35724. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35725. baseParams.SecretKey = miConfig.SecretKey
  35726. baseParams.OrgName = miConfig.OrgName
  35727. baseParams.FixmedinsCode = miConfig.Code
  35728. baseParams.EncKey = miConfig.EncKey
  35729. baseParams.AppSecret = miConfig.AppSecret
  35730. baseParams.SignKey = miConfig.SignKey
  35731. baseParams.AppID = miConfig.Code
  35732. baseParams.Doctor = role.UserName
  35733. baseParams.RequestUrl = miConfig.Url
  35734. businessParams := models.BusinessParams{
  35735. Insutype: insutype,
  35736. ClrType: clr_type,
  35737. SetlOptins: clr_org,
  35738. StmtBegndate: start_time,
  35739. StmtEnddate: end_time,
  35740. MedfeeSumamt: medfee_sumamt,
  35741. FundPaySumamt: fund_pay_sumamt,
  35742. AcctPay: acct_pay,
  35743. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35744. }
  35745. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35746. fmt.Println(requestLog)
  35747. fmt.Println(result)
  35748. fmt.Println(err_msg)
  35749. var dat map[string]interface{}
  35750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35751. fmt.Println(dat)
  35752. } else {
  35753. fmt.Println(err)
  35754. }
  35755. userJSONBytes, _ := json.Marshal(dat)
  35756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35757. utils.ErrorLog("解析失败:%v", err)
  35758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35759. return
  35760. }
  35761. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35762. if len(clr_type) == 0 {
  35763. clr_type = "11"
  35764. }
  35765. api := miConfig.Url + "gdyb/ten?" +
  35766. "insutype=" + insutype +
  35767. "&clr_type=" + clr_type +
  35768. "&setl_optins=" + clr_org +
  35769. "&stmt_begndate=" + start_time +
  35770. "&stm_enddate=" + end_time +
  35771. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35772. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35773. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35774. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35775. "&fixmedins_code=" + miConfig.Code +
  35776. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35777. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35778. "&secret_key=" + miConfig.SecretKey +
  35779. "&org_name=" + miConfig.OrgName +
  35780. "&doctor=" + user_name
  35781. fmt.Println(api)
  35782. resp, requestErr := http.Get(api)
  35783. if requestErr != nil {
  35784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35785. return
  35786. }
  35787. body, ioErr := ioutil.ReadAll(resp.Body)
  35788. fmt.Println(body)
  35789. if ioErr != nil {
  35790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35792. return
  35793. }
  35794. var respJSON map[string]interface{}
  35795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35798. return
  35799. }
  35800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35801. userJSONBytes, _ := json.Marshal(respJSON)
  35802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35803. utils.ErrorLog("解析失败:%v", err)
  35804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35805. return
  35806. }
  35807. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35808. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35809. //fixmedins_setl_cnt := int64(len(orders_two))
  35810. //var medfee_sumamt float64
  35811. //var acct_pay float64
  35812. //var fund_pay_sumamt float64
  35813. //for _, item := range orders_two {
  35814. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35815. // acct_pay = acct_pay + item.AcctPay
  35816. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35817. //}
  35818. var baseParams models.BaseParams
  35819. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35820. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35821. baseParams.SecretKey = miConfig.SecretKey
  35822. baseParams.OrgName = miConfig.OrgName
  35823. baseParams.FixmedinsCode = miConfig.Code
  35824. baseParams.EncKey = miConfig.EncKey
  35825. baseParams.AppSecret = miConfig.AppSecret
  35826. baseParams.SignKey = miConfig.SignKey
  35827. baseParams.AppID = miConfig.Code
  35828. baseParams.Doctor = role.UserName
  35829. baseParams.RequestUrl = miConfig.Url
  35830. businessParams := models.BusinessParams{
  35831. Insutype: insutype,
  35832. ClrType: clr_type,
  35833. SetlOptins: "360102",
  35834. StmtBegndate: start_time,
  35835. StmtEnddate: end_time,
  35836. MedfeeSumamt: 0,
  35837. FundPaySumamt: 0,
  35838. AcctPay: 0,
  35839. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35840. }
  35841. 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))
  35842. fmt.Println(requestLog)
  35843. fmt.Println(result)
  35844. var dat map[string]interface{}
  35845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35846. fmt.Println(dat)
  35847. } else {
  35848. fmt.Println(err)
  35849. }
  35850. userJSONBytes, _ := json.Marshal(dat)
  35851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35852. utils.ErrorLog("解析失败:%v", err)
  35853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35854. return
  35855. }
  35856. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35857. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35858. //fixmedins_setl_cnt := int64(len(orders_two))
  35859. //var medfee_sumamt float64
  35860. //var acct_pay float64
  35861. //var fund_pay_sumamt float64
  35862. //for _, item := range orders_two {
  35863. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35864. // acct_pay = acct_pay + item.AcctPay
  35865. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35866. //}
  35867. var baseParams models.BaseParams
  35868. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35869. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35870. baseParams.SecretKey = miConfig.SecretKey
  35871. baseParams.OrgName = miConfig.OrgName
  35872. baseParams.FixmedinsCode = miConfig.Code
  35873. baseParams.EncKey = miConfig.EncKey
  35874. baseParams.AppSecret = miConfig.AppSecret
  35875. baseParams.SignKey = miConfig.SignKey
  35876. baseParams.AppID = miConfig.Code
  35877. baseParams.Doctor = role.UserName
  35878. baseParams.RequestUrl = miConfig.Url
  35879. if clr_type == "9903" {
  35880. clr_type = "9994"
  35881. }
  35882. businessParams := models.BusinessParams{
  35883. Insutype: insutype,
  35884. ClrType: clr_type,
  35885. SetlOptins: "361025",
  35886. StmtBegndate: start_time,
  35887. StmtEnddate: end_time,
  35888. MedfeeSumamt: 0,
  35889. FundPaySumamt: 0,
  35890. AcctPay: 0,
  35891. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35892. }
  35893. result, requestLog := service.Jxyb32012(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  35894. fmt.Println(requestLog)
  35895. fmt.Println(result)
  35896. var dat map[string]interface{}
  35897. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35898. fmt.Println(dat)
  35899. } else {
  35900. fmt.Println(err)
  35901. }
  35902. userJSONBytes, _ := json.Marshal(dat)
  35903. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35904. utils.ErrorLog("解析失败:%v", err)
  35905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35906. return
  35907. }
  35908. } else if miConfig.MdtrtareaAdmvs == "360106" {
  35909. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35910. //fixmedins_setl_cnt := int64(len(orders_two))
  35911. //var medfee_sumamt float64
  35912. //var acct_pay float64
  35913. //var fund_pay_sumamt float64
  35914. //for _, item := range orders_two {
  35915. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35916. // acct_pay = acct_pay + item.AcctPay
  35917. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35918. //}
  35919. var baseParams models.BaseParams
  35920. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35921. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35922. baseParams.SecretKey = miConfig.SecretKey
  35923. baseParams.OrgName = miConfig.OrgName
  35924. baseParams.FixmedinsCode = miConfig.Code
  35925. baseParams.EncKey = miConfig.EncKey
  35926. baseParams.AppSecret = miConfig.AppSecret
  35927. baseParams.SignKey = miConfig.SignKey
  35928. baseParams.AppID = miConfig.Code
  35929. baseParams.Doctor = role.UserName
  35930. baseParams.RequestUrl = miConfig.Url
  35931. if clr_type == "9903" {
  35932. clr_type = "9994"
  35933. }
  35934. businessParams := models.BusinessParams{
  35935. Insutype: insutype,
  35936. ClrType: clr_type,
  35937. SetlOptins: "360102",
  35938. StmtBegndate: start_time,
  35939. StmtEnddate: end_time,
  35940. MedfeeSumamt: 0,
  35941. FundPaySumamt: 0,
  35942. AcctPay: 0,
  35943. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35944. }
  35945. result, requestLog := service.Jxyb32012(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  35946. fmt.Println(requestLog)
  35947. fmt.Println(result)
  35948. var dat map[string]interface{}
  35949. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35950. fmt.Println(dat)
  35951. } else {
  35952. fmt.Println(err)
  35953. }
  35954. userJSONBytes, _ := json.Marshal(dat)
  35955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35956. utils.ErrorLog("解析失败:%v", err)
  35957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35958. return
  35959. }
  35960. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35961. var api string
  35962. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35963. "&clr_type=" + clr_type +
  35964. "&setl_optins=" + clr_org +
  35965. "&stmt_begndate=" + start_time +
  35966. "&stm_enddate=" + end_time +
  35967. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35968. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35969. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35970. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35971. "&fixmedins_code=" + miConfig.Code +
  35972. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35973. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35974. "&secret_key=" + miConfig.SecretKey +
  35975. "&org_name=" + miConfig.OrgName +
  35976. "&doctor=" + user_name + "&url=" + miConfig.Url
  35977. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35978. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35979. resp, requestErr := http.Get(api)
  35980. if requestErr != nil {
  35981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35982. return
  35983. }
  35984. body, ioErr := ioutil.ReadAll(resp.Body)
  35985. if ioErr != nil {
  35986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35988. return
  35989. }
  35990. var respJSON map[string]interface{}
  35991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35994. return
  35995. }
  35996. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35997. if status == "0" {
  35998. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35999. c.ServeSuccessJSON(map[string]interface{}{
  36000. "failed_code": -10,
  36001. "msg": err_msg,
  36002. })
  36003. return
  36004. }
  36005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36006. userJSONBytes, _ := json.Marshal(respJSON)
  36007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36008. utils.ErrorLog("解析失败:%v", err)
  36009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36010. return
  36011. }
  36012. } else if miConfig.MdtrtareaAdmvs == "340699" {
  36013. var api string
  36014. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  36015. "&clr_type=" + clr_type +
  36016. "&setl_optins=" + clr_org +
  36017. "&stmt_begndate=" + start_time +
  36018. "&stm_enddate=" + end_time +
  36019. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36020. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36021. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  36022. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  36023. "&fixmedins_code=" + miConfig.Code +
  36024. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36025. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36026. "&secret_key=" + miConfig.SecretKey +
  36027. "&org_name=" + miConfig.OrgName +
  36028. "&doctor=" + user_name + "&url=" + miConfig.Url
  36029. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36030. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36031. resp, requestErr := http.Get(api)
  36032. if requestErr != nil {
  36033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36034. return
  36035. }
  36036. body, ioErr := ioutil.ReadAll(resp.Body)
  36037. if ioErr != nil {
  36038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36040. return
  36041. }
  36042. var respJSON map[string]interface{}
  36043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36046. return
  36047. }
  36048. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36049. if status == "0" {
  36050. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36051. c.ServeSuccessJSON(map[string]interface{}{
  36052. "failed_code": -10,
  36053. "msg": err_msg,
  36054. })
  36055. return
  36056. }
  36057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36058. userJSONBytes, _ := json.Marshal(respJSON)
  36059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36060. utils.ErrorLog("解析失败:%v", err)
  36061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36062. return
  36063. }
  36064. } else {
  36065. if len(clr_type) == 0 {
  36066. clr_type = "11"
  36067. }
  36068. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36069. "insutype=" + insutype +
  36070. "&clr_type=" + clr_type +
  36071. "&setl_optins=" + clr_org +
  36072. "&stmt_begndate=" + start_time +
  36073. "&stm_enddate=" + end_time +
  36074. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36075. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36076. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  36077. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36078. "&fixmedins_code=" + miConfig.Code +
  36079. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36080. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36081. "&secret_key=" + miConfig.SecretKey +
  36082. "&org_name=" + miConfig.OrgName +
  36083. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  36084. fmt.Println(api)
  36085. resp, requestErr := http.Get(api)
  36086. if requestErr != nil {
  36087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36088. return
  36089. }
  36090. body, ioErr := ioutil.ReadAll(resp.Body)
  36091. fmt.Println(body)
  36092. if ioErr != nil {
  36093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36095. return
  36096. }
  36097. var respJSON map[string]interface{}
  36098. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36101. return
  36102. }
  36103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36104. userJSONBytes, _ := json.Marshal(respJSON)
  36105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36106. utils.ErrorLog("解析失败:%v", err)
  36107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36108. return
  36109. }
  36110. }
  36111. if res.Infcode == 0 {
  36112. if res.Output.Stmtinfo.StmtRslt == "0" {
  36113. micc := &models.MedicalInsuranceCostCompare{
  36114. StartTime: startime.Unix(),
  36115. EndTime: endtime.Unix(),
  36116. Insutype: insutype,
  36117. CheckType: 1,
  36118. Num: fixmedins_setl_cnt,
  36119. Mtime: time.Now().Unix(),
  36120. Status: 1,
  36121. UserOrgId: adminUser.CurrentOrgId,
  36122. CostTotal: medfee_sumamt,
  36123. FuncTotal: fund_pay_sumamt,
  36124. PsnPay: acct_pay,
  36125. Creator: admin_user_id,
  36126. Ctime: time.Now().Unix(),
  36127. ClrType: clr_type,
  36128. }
  36129. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  36130. if err == nil {
  36131. c.ServeSuccessJSON(map[string]interface{}{
  36132. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  36133. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  36134. })
  36135. } else {
  36136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36137. }
  36138. } else {
  36139. c.ServeSuccessJSON(map[string]interface{}{
  36140. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  36141. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  36142. })
  36143. }
  36144. } else {
  36145. c.ServeSuccessJSON(map[string]interface{}{
  36146. "failed_code": -10,
  36147. "msg": res.ErrMsg,
  36148. })
  36149. }
  36150. }
  36151. }
  36152. func (c *HisApiController) Check310() {
  36153. adminUser := c.GetAdminUserInfo()
  36154. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36155. var user_name string
  36156. user_name = "高慧裕"
  36157. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36158. "insutype=" + "310" +
  36159. "&clr_type=" + "" +
  36160. "&setl_optins=" + "441202" +
  36161. "&stmt_begndate=" + "2022-03-01" +
  36162. "&stm_enddate=" + "2022-03-31" +
  36163. "&medfee_sumamt=" + "194930.12" +
  36164. "&fund_pay_sumamt=" + "188741.46" +
  36165. "&acct_pay=" + "0" +
  36166. "&fixmedins_setl_cnt=" + "452" +
  36167. "&fixmedins_code=" + miConfig.Code +
  36168. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36169. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36170. "&secret_key=" + miConfig.SecretKey +
  36171. "&org_name=" + miConfig.OrgName +
  36172. "&doctor=" + user_name
  36173. fmt.Println(api)
  36174. resp, requestErr := http.Get(api)
  36175. if requestErr != nil {
  36176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36177. return
  36178. }
  36179. body, ioErr := ioutil.ReadAll(resp.Body)
  36180. fmt.Println(body)
  36181. if ioErr != nil {
  36182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36184. return
  36185. }
  36186. var respJSON map[string]interface{}
  36187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36190. return
  36191. }
  36192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36193. userJSONBytes, _ := json.Marshal(respJSON)
  36194. var res ResultEight
  36195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36196. utils.ErrorLog("解析失败:%v", err)
  36197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36198. return
  36199. }
  36200. }
  36201. func (c *HisApiController) Check390() {
  36202. adminUser := c.GetAdminUserInfo()
  36203. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36204. var user_name string
  36205. user_name = "高慧裕"
  36206. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36207. "insutype=" + "390" +
  36208. "&clr_type=" + "" +
  36209. "&setl_optins=" + "441202" +
  36210. "&stmt_begndate=" + "2022-03-01" +
  36211. "&stm_enddate=" + "2022-03-31" +
  36212. "&medfee_sumamt=" + "1068448.89" +
  36213. "&fund_pay_sumamt=" + "1014677.62" +
  36214. "&acct_pay=" + "0" +
  36215. "&fixmedins_setl_cnt=" + "1950" +
  36216. "&fixmedins_code=" + miConfig.Code +
  36217. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36218. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36219. "&secret_key=" + miConfig.SecretKey +
  36220. "&org_name=" + miConfig.OrgName +
  36221. "&doctor=" + user_name
  36222. fmt.Println(api)
  36223. resp, requestErr := http.Get(api)
  36224. if requestErr != nil {
  36225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36226. return
  36227. }
  36228. body, ioErr := ioutil.ReadAll(resp.Body)
  36229. fmt.Println(body)
  36230. if ioErr != nil {
  36231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36233. return
  36234. }
  36235. var respJSON map[string]interface{}
  36236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36239. return
  36240. }
  36241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36242. userJSONBytes, _ := json.Marshal(respJSON)
  36243. var res ResultEight
  36244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36245. utils.ErrorLog("解析失败:%v", err)
  36246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36247. return
  36248. }
  36249. }
  36250. // 对账明细
  36251. func (c *HisApiController) GetCheckDetailAccount() {
  36252. start_time := c.GetString("start_time")
  36253. end_time := c.GetString("end_time")
  36254. admin_user_id, _ := c.GetInt64("admin_user_id")
  36255. adminUser := c.GetAdminUserInfo()
  36256. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36257. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36258. timeLayout := "2006-01-02"
  36259. loc, _ := time.LoadLocation("Local")
  36260. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36261. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36262. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36263. rand.Seed(time.Now().UnixNano())
  36264. num := rand.Intn(30000)
  36265. Mkdir(miConfig.OrgName)
  36266. file := strconv.FormatInt(int64(num), 10)
  36267. file_name := file + ".txt"
  36268. zip_name := file + ".zip"
  36269. zip_path := miConfig.OrgName + "/" + zip_name
  36270. file_path := miConfig.OrgName + "/" + file_name
  36271. decimal.DivisionPrecision = 2
  36272. var medfee_sumamt float64
  36273. var psn_cash_pay float64
  36274. var fund_pay_sumamt float64
  36275. fixmedins_setl_cnt := int64(len(orders))
  36276. for _, item := range orders {
  36277. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36278. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  36279. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  36280. }
  36281. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  36282. defer f.Close()
  36283. if err != nil {
  36284. fmt.Println(err.Error())
  36285. } else {
  36286. for _, item := range orders {
  36287. var refd_setl_flag string
  36288. if item.OrderStatus == 2 {
  36289. refd_setl_flag = "0"
  36290. var str string
  36291. str = item.SetlId + " " +
  36292. item.MdtrtId + " " +
  36293. item.PsnNo + " " +
  36294. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36295. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36296. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  36297. _, err = f.Write([]byte(str))
  36298. }
  36299. if item.OrderStatus == 3 {
  36300. var str string
  36301. str = item.SetlId + " " +
  36302. item.MdtrtId + " " +
  36303. item.PsnNo + " " +
  36304. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36305. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36306. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  36307. _, err = f.Write([]byte(str))
  36308. var str2 string
  36309. str2 = item.SetlId + " " +
  36310. item.MdtrtId + " " +
  36311. item.PsnNo + " " +
  36312. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  36313. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  36314. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  36315. _, err = f.Write([]byte(str2))
  36316. }
  36317. }
  36318. }
  36319. Zip(file_path, zip_path)
  36320. fmt.Println(ReadFile(zip_path))
  36321. fmt.Println(string(ReadFile(zip_path)))
  36322. if config.IsOpen == 1 {
  36323. var user_name string
  36324. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36325. if role.ID == 0 {
  36326. user_name = "管理员"
  36327. } else {
  36328. user_name = role.UserName
  36329. }
  36330. baseParams := models.BaseParams{
  36331. SecretKey: miConfig.SecretKey,
  36332. FixmedinsCode: miConfig.Code,
  36333. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36334. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36335. OrgName: miConfig.OrgName,
  36336. Doctor: user_name,
  36337. }
  36338. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  36339. var dat map[string]interface{}
  36340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36341. fmt.Println(dat)
  36342. } else {
  36343. fmt.Println(err)
  36344. }
  36345. userJSONBytes, _ := json.Marshal(dat)
  36346. var res ResultNine
  36347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36348. utils.ErrorLog("解析失败:%v", err)
  36349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36350. return
  36351. }
  36352. if res.Infcode == 0 {
  36353. fileNo := res.Output.FileQuryNo
  36354. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  36355. "file_qury_no=" + fileNo +
  36356. "&setl_optins=" + "定点医保中心" +
  36357. "&stmt_begndate=" + start_time +
  36358. "&stm_enddate=" + end_time +
  36359. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36360. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36361. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  36362. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36363. "&fixmedins_code=" + miConfig.Code +
  36364. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36365. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36366. "&secret_key=" + miConfig.SecretKey +
  36367. "&org_name=" + miConfig.OrgName +
  36368. "&doctor=" + user_name
  36369. resp, requestErr := http.Get(api)
  36370. if requestErr != nil {
  36371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36372. return
  36373. }
  36374. body, ioErr := ioutil.ReadAll(resp.Body)
  36375. if ioErr != nil {
  36376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36378. return
  36379. }
  36380. var respJSON map[string]interface{}
  36381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36384. return
  36385. }
  36386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36387. userJSONBytes, _ := json.Marshal(respJSON)
  36388. var res ResultTen
  36389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36390. utils.ErrorLog("解析失败:%v", err)
  36391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36392. return
  36393. }
  36394. if res.Infcode == 0 {
  36395. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36396. micc := &models.MedicalInsuranceCostCompare{
  36397. StartTime: startime.Unix(),
  36398. EndTime: endtime.Unix(),
  36399. Insutype: "0",
  36400. CheckType: 2,
  36401. Num: fixmedins_setl_cnt,
  36402. Mtime: time.Now().Unix(),
  36403. Status: 1,
  36404. UserOrgId: adminUser.CurrentOrgId,
  36405. CostTotal: medfee_sumamt,
  36406. FuncTotal: fund_pay_sumamt,
  36407. PsnPay: psn_cash_pay,
  36408. Creator: admin_user_id,
  36409. Ctime: time.Now().Unix(),
  36410. }
  36411. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36412. c.ServeSuccessJSON(map[string]interface{}{
  36413. "msg": "明细对账成功",
  36414. })
  36415. }
  36416. } else {
  36417. }
  36418. }
  36419. }
  36420. type CustomOrderInfo struct {
  36421. Name string
  36422. Spec string
  36423. Unit string
  36424. Count float64
  36425. Price float64
  36426. Total float64
  36427. }
  36428. func (c *HisApiController) GetBatchSettleAccounts() {
  36429. admin_user_id, _ := c.GetInt64("admin_user_id")
  36430. order_ids := c.GetString("order_ids")
  36431. order_ids_arr := strings.Split(order_ids, ",")
  36432. data3 := []map[string]interface{}{}
  36433. for _, item := range order_ids_arr {
  36434. id, _ := strconv.ParseInt(item, 10, 64)
  36435. order_id := id
  36436. adminUser := c.GetAdminUserInfo()
  36437. order, _ := service.GetHisOrderByID(order_id)
  36438. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36439. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36440. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36441. orderInfos = append(orderInfos, orderInfos_two...)
  36442. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36443. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36444. var diagnosis_ids []string
  36445. if his.ID > 0 {
  36446. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36447. } else {
  36448. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36449. }
  36450. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36451. var dia_config []*models.HisXtDiagnoseConfig
  36452. var name string
  36453. for _, item := range diagnosis_ids {
  36454. id, _ := strconv.ParseInt(item, 10, 64)
  36455. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36456. dia_config = append(dia_config, &diagnosisConfig)
  36457. if len(name) == 0 {
  36458. name = diagnosisConfig.ClassName
  36459. }
  36460. //} else {
  36461. // name = name + "," + diagnosisConfig.ClassName
  36462. //}
  36463. }
  36464. var bedCostTotal float64 = 0 //床位总费
  36465. var bedCostSelfTotal float64 = 0 //床位自费
  36466. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36467. var bedSelfTotal float64 = 0 //床位部分项目自费
  36468. var bedInscpTotal float64 = 0 //床位部分项目自费
  36469. var operationCostTotal float64 = 0 //手术费
  36470. var operationCostSelfTotal float64 = 0 //手术费
  36471. var operationCostPartSelfTotal float64 = 0 //手术费
  36472. var operationSelfTotal float64 = 0 //床位部分项目自费
  36473. var operationInscpTotal float64 = 0 //床位部分项目自费
  36474. var otherCostTotal float64 = 0 //其他费用
  36475. var otherCostSelfTotal float64 = 0 //其他费用
  36476. var otherCostPartSelfTotal float64 = 0 //其他费用
  36477. var otherSelfTotal float64 = 0 //床位部分项目自费
  36478. var otherInscpTotal float64 = 0 //床位部分项目自费
  36479. var materialCostTotal float64 = 0 //材料费
  36480. var materialCostSelfTotal float64 = 0 //材料费
  36481. var materialCostPartSelfTotal float64 = 0 //材料费
  36482. var materialSelfTotal float64 = 0 //床位部分项目自费
  36483. var materialInscpTotal float64 = 0 //床位部分项目自费
  36484. var westernMedicineCostTotal float64 = 0 //西药费
  36485. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36486. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36487. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36488. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36489. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36490. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36491. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36492. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36493. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36494. var checkCostTotal float64 = 0 //检查费
  36495. var checkCostSelfTotal float64 = 0 //检查费
  36496. var checkCostPartSelfTotal float64 = 0 //检查费
  36497. var checkSelfTotal float64 = 0 //床位部分项目自费
  36498. var checkInscpTotal float64 = 0 //床位部分项目自费
  36499. var laboratoryCostTotal float64 = 0 //化验费
  36500. var laboratoryCostSelfTotal float64 = 0 //化验费
  36501. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36502. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36503. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36504. var treatCostTotal float64 = 0 //治疗费用
  36505. var treatCostSelfTotal float64 = 0 //治疗费用
  36506. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36507. var treatSelfTotal float64 = 0 //床位部分项目自费
  36508. var treatInscpTotal float64 = 0 //床位部分项目自费
  36509. decimal.DivisionPrecision = 2
  36510. for _, item := range orderInfos {
  36511. if item.MedChrgitmType == "01" { //床位费
  36512. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36513. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36514. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36515. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36516. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36517. }
  36518. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36519. if item.MedChrgitmType == "03" { //检查费
  36520. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36521. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36522. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36523. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36524. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36525. }
  36526. } else {
  36527. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36528. fmt.Println("------------")
  36529. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36530. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36531. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36532. }
  36533. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36534. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36535. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36536. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36537. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36538. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36539. }
  36540. }
  36541. if item.MedChrgitmType == "04" { //化验费
  36542. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36543. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36544. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36545. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36546. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36547. }
  36548. if item.MedChrgitmType == "05" { //治疗费
  36549. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36550. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36551. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36552. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36553. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36554. }
  36555. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36556. fmt.Println("------------")
  36557. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36558. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36559. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36560. }
  36561. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36562. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36563. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36564. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36565. }
  36566. //if item.MedChrgitmType == "06" { //手术费
  36567. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36568. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36569. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36570. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36571. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36572. //
  36573. //}
  36574. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36575. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36576. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36577. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36578. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36579. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36580. }
  36581. if item.MedChrgitmType == "09" { //西药费
  36582. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36583. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36584. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36585. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36586. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36587. }
  36588. if item.MedChrgitmType == "11" { //中成费
  36589. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36590. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36591. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36592. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36593. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36594. }
  36595. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36596. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36597. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36598. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36599. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36600. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36601. }
  36602. }
  36603. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36604. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36605. var user_name string
  36606. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36607. if role.ID == 0 {
  36608. user_name = "管理员"
  36609. } else {
  36610. user_name = role.UserName
  36611. }
  36612. baseParams := models.BaseParams{
  36613. SecretKey: miConfig.SecretKey,
  36614. FixmedinsCode: miConfig.Code,
  36615. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36616. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36617. OrgName: miConfig.OrgName,
  36618. Doctor: user_name,
  36619. RequestUrl: miConfig.Url,
  36620. AccessKey: miConfig.AccessKey,
  36621. }
  36622. businessParams := models.BusinessParams{
  36623. PsnNo: order.PsnNo,
  36624. MdtrtId: order.MdtrtId,
  36625. SetlId: order.SetlId,
  36626. }
  36627. var res ResultEleven
  36628. var resEleven10265 ResultEleven10265
  36629. if config.IsOpen == 1 {
  36630. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36631. result := service.Gdyb5203(baseParams, businessParams)
  36632. service.Gdyb5204(baseParams, businessParams)
  36633. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36634. var dat map[string]interface{}
  36635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36636. fmt.Println(dat)
  36637. } else {
  36638. fmt.Println(err)
  36639. }
  36640. userJSONBytes, _ := json.Marshal(dat)
  36641. if miConfig.Code == "H15049901371" {
  36642. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36643. utils.ErrorLog("解析失败:%v", err)
  36644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36645. return
  36646. }
  36647. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36648. res.Output = resEleven10265.Output
  36649. res.ErrMsg = resEleven10265.ErrMsg
  36650. res.Cainfo = resEleven10265.Cainfo
  36651. res.WarnMsg = resEleven10265.WarnMsg
  36652. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36653. res.Infcode = infocode
  36654. } else {
  36655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36656. utils.ErrorLog("解析失败:%v", err)
  36657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36658. return
  36659. }
  36660. }
  36661. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36662. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36663. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36664. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36665. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36666. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36667. var doctor_name string
  36668. if roles.ID == 0 {
  36669. doctor_name = "管理员"
  36670. } else {
  36671. doctor_name = roles.UserName
  36672. }
  36673. yiliao_leibie := ""
  36674. switch order.MedType {
  36675. case "11":
  36676. yiliao_leibie = "普通门诊"
  36677. break
  36678. case "12":
  36679. yiliao_leibie = "门诊挂号"
  36680. break
  36681. case "13":
  36682. yiliao_leibie = "急诊"
  36683. break
  36684. case "14":
  36685. yiliao_leibie = "门诊特殊病"
  36686. break
  36687. case "15":
  36688. yiliao_leibie = "门诊统筹"
  36689. break
  36690. case "16":
  36691. yiliao_leibie = "门诊慢性病"
  36692. break
  36693. case "21":
  36694. yiliao_leibie = "普通住院"
  36695. break
  36696. }
  36697. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36698. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36699. if res.Infcode == 0 {
  36700. data2 := map[string]interface{}{
  36701. "diagnosis": name,
  36702. "order_infos": orderInfos,
  36703. "number": order.MdtrtId,
  36704. "date": order.SettleAccountsDate,
  36705. "charge_admin": charge_admin,
  36706. "printor_admin": printor_admin,
  36707. "info": res.Output.Setlinfo,
  36708. "order": order,
  36709. "bedCostTotal": bedCostTotal,
  36710. "bedCostSelfTotal": bedCostSelfTotal,
  36711. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36712. "bedSelfTotal": bedSelfTotal,
  36713. "bedInscpTotal": bedInscpTotal,
  36714. "operationCostTotal": operationCostTotal,
  36715. "operationCostSelfTotal": operationCostSelfTotal,
  36716. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36717. "operationSelfTotal": operationSelfTotal,
  36718. "operationInscpTotal": operationInscpTotal,
  36719. "otherCostTotal": otherCostTotal,
  36720. "otherCostSelfTotal": otherCostSelfTotal,
  36721. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36722. "otherSelfTotal": otherSelfTotal,
  36723. "otherInscpTotal": otherInscpTotal,
  36724. "materialCostTotal": materialCostTotal,
  36725. "materialCostSelfTotal": materialCostSelfTotal,
  36726. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36727. "materialSelfTotal": materialSelfTotal,
  36728. "materialInscpTotal": materialInscpTotal,
  36729. "westernMedicineCostTotal": westernMedicineCostTotal,
  36730. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36731. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36732. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36733. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36734. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36735. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36736. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36737. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36738. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36739. "checkCostTotal": checkCostTotal,
  36740. "checkCostSelfTotal": checkCostSelfTotal,
  36741. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36742. "checkSelfTotal": checkSelfTotal,
  36743. "checkInscpTotal": checkInscpTotal,
  36744. "laboratoryCostTotal": laboratoryCostTotal,
  36745. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36746. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36747. "laboratorySelfTotal": laboratorySelfTotal,
  36748. "laboratoryInscpTotal": laboratoryInscpTotal,
  36749. "treatCostTotal": treatCostTotal,
  36750. "treatCostSelfTotal": treatCostSelfTotal,
  36751. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36752. "treatSelfTotal": treatSelfTotal,
  36753. "treatInscpTotal": treatInscpTotal,
  36754. "doctor_info": doctor_info,
  36755. "doctor_code": adminRole_two.DoctorCode,
  36756. "doctor_name": doctor_name,
  36757. "health_card_no": order.PsnNo,
  36758. "department": departments.Name,
  36759. "yiliao_leibie": yiliao_leibie,
  36760. "after_money": order.AccountPrice,
  36761. "patient": patient,
  36762. "org_name": miConfig.OrgName,
  36763. "org_code": miConfig.Code,
  36764. "order_number": order.Number,
  36765. "his_hospital": his_hospital,
  36766. "his": his,
  36767. "dia_config": dia_config,
  36768. "psn_cash_pay": order.PsnCashPay,
  36769. //"check_order_info": cus_slice,
  36770. }
  36771. data3 = append(data3, data2)
  36772. }
  36773. }
  36774. }
  36775. c.ServeSuccessJSON(map[string]interface{}{
  36776. "infos": data3,
  36777. })
  36778. }
  36779. func (c *HisApiController) GetSettleAccounts() {
  36780. //id, _ := c.GetInt64("id")
  36781. //record_time := c.GetString("record_time")
  36782. order_id, _ := c.GetInt64("order_id")
  36783. admin_user_id, _ := c.GetInt64("admin_user_id")
  36784. //timeLayout := "2006-01-02"
  36785. //loc, _ := time.LoadLocation("Local")
  36786. //
  36787. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36788. //if err != nil {
  36789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36790. // return
  36791. //}Hbyb5203
  36792. //recordDateTime := theTime.Unix()
  36793. adminUser := c.GetAdminUserInfo()
  36794. order, _ := service.GetHisOrderByID(order_id)
  36795. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36796. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36797. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36798. orderInfos = append(orderInfos, orderInfos_two...)
  36799. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36800. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36801. var diagnosis_ids []string
  36802. if his.ID > 0 {
  36803. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36804. } else {
  36805. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36806. }
  36807. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36808. var dia_config []*models.HisXtDiagnoseConfig
  36809. var name string
  36810. for _, item := range diagnosis_ids {
  36811. id, _ := strconv.ParseInt(item, 10, 64)
  36812. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36813. dia_config = append(dia_config, &diagnosisConfig)
  36814. if len(name) == 0 {
  36815. name = diagnosisConfig.ClassName
  36816. } else {
  36817. name = name + "," + diagnosisConfig.ClassName
  36818. }
  36819. }
  36820. if patient.UserOrgId == 10215 {
  36821. name = "慢性肾功能不全(血透治疗)"
  36822. }
  36823. var bedCostTotal float64 = 0 //床位总费
  36824. var bedCostSelfTotal float64 = 0 //床位自费
  36825. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36826. var bedSelfTotal float64 = 0 //床位部分项目自费
  36827. var bedInscpTotal float64 = 0 //床位部分项目自费
  36828. var operationCostTotal float64 = 0 //手术费
  36829. var operationCostSelfTotal float64 = 0 //手术费
  36830. var operationCostPartSelfTotal float64 = 0 //手术费
  36831. var operationSelfTotal float64 = 0 //床位部分项目自费
  36832. var operationInscpTotal float64 = 0 //床位部分项目自费
  36833. var otherCostTotal float64 = 0 //其他费用
  36834. var otherCostSelfTotal float64 = 0 //其他费用
  36835. var otherCostPartSelfTotal float64 = 0 //其他费用
  36836. var otherSelfTotal float64 = 0 //床位部分项目自费
  36837. var otherInscpTotal float64 = 0 //床位部分项目自费
  36838. var materialCostTotal float64 = 0 //材料费
  36839. var materialCostSelfTotal float64 = 0 //材料费
  36840. var materialCostPartSelfTotal float64 = 0 //材料费
  36841. var materialSelfTotal float64 = 0 //床位部分项目自费
  36842. var materialInscpTotal float64 = 0 //床位部分项目自费
  36843. var westernMedicineCostTotal float64 = 0 //西药费
  36844. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36845. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36846. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36847. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36848. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36849. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36850. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36851. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36852. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36853. var checkCostTotal float64 = 0 //检查费
  36854. var checkCostSelfTotal float64 = 0 //检查费
  36855. var checkCostPartSelfTotal float64 = 0 //检查费
  36856. var checkSelfTotal float64 = 0 //床位部分项目自费
  36857. var checkInscpTotal float64 = 0 //床位部分项目自费
  36858. var laboratoryCostTotal float64 = 0 //化验费
  36859. var laboratoryCostSelfTotal float64 = 0 //化验费
  36860. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36861. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36862. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36863. var treatCostTotal float64 = 0 //治疗费用
  36864. var treatCostSelfTotal float64 = 0 //治疗费用
  36865. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36866. var treatSelfTotal float64 = 0 //床位部分项目自费
  36867. var treatInscpTotal float64 = 0 //床位部分项目自费
  36868. var zcCostTotal float64 = 0 //治疗费用
  36869. var zcCostSelfTotal float64 = 0 //治疗费用
  36870. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36871. var zcSelfTotal float64 = 0 //床位部分项目自费
  36872. var zcInscpTotal float64 = 0 //床位部分项目自费
  36873. var huliCostTotal float64 = 0 //治疗费用
  36874. var huliCostSelfTotal float64 = 0 //治疗费用
  36875. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36876. var huliSelfTotal float64 = 0 //床位部分项目自费
  36877. var huliInscpTotal float64 = 0 //床位部分项目自费
  36878. decimal.DivisionPrecision = 2
  36879. for _, item := range orderInfos {
  36880. if item.MedChrgitmType == "01" { //床位费
  36881. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36882. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36883. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36884. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36885. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36886. }
  36887. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36888. if item.MedChrgitmType == "03" { //检查费
  36889. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36890. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36891. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36892. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36893. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36894. }
  36895. } else {
  36896. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36897. fmt.Println("------------")
  36898. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36899. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36900. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36901. }
  36902. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36903. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36904. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36905. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36906. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36907. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36908. }
  36909. }
  36910. if item.MedChrgitmType == "04" { //化验费
  36911. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36912. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36913. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36914. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36915. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36916. }
  36917. if item.MedChrgitmType == "05" { //治疗费
  36918. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36919. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36920. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36921. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36922. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36923. }
  36924. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36925. fmt.Println("------------")
  36926. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36927. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36928. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36929. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36930. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36931. }
  36932. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36933. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36934. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36935. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36936. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36937. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36938. }
  36939. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36940. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36941. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36942. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36943. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36944. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36945. }
  36946. if item.MedChrgitmType == "09" { //西药费
  36947. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36948. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36949. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36950. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36951. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36952. }
  36953. if item.MedChrgitmType == "11" { //中成费
  36954. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36955. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36956. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36957. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36958. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36959. }
  36960. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36961. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36962. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36963. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36964. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36965. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36966. }
  36967. if item.MedChrgitmType == "02" { //其他费
  36968. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36969. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36970. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36971. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36972. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36973. }
  36974. if item.MedChrgitmType == "07" { //其他费
  36975. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36976. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36977. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36978. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36979. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36980. }
  36981. }
  36982. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36983. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36984. var user_name string
  36985. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36986. if role.ID == 0 {
  36987. user_name = "管理员"
  36988. } else {
  36989. user_name = role.UserName
  36990. }
  36991. baseParams := models.BaseParams{
  36992. SecretKey: miConfig.SecretKey,
  36993. FixmedinsCode: miConfig.Code,
  36994. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36995. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36996. OrgName: miConfig.OrgName,
  36997. Doctor: user_name,
  36998. RequestUrl: miConfig.Url,
  36999. AccessKey: miConfig.AccessKey,
  37000. }
  37001. businessParams := models.BusinessParams{
  37002. PsnNo: order.PsnNo,
  37003. MdtrtId: order.MdtrtId,
  37004. SetlId: order.SetlId,
  37005. }
  37006. var res ResultEleven
  37007. var resah ResultElevenah
  37008. var resEleven10265 ResultEleven10265
  37009. if config.IsOpen == 1 {
  37010. if miConfig.MdtrtareaAdmvs == "421300" {
  37011. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37012. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37014. resp, requestErr := http.Get(api)
  37015. if requestErr != nil {
  37016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37017. return
  37018. }
  37019. body, ioErr := ioutil.ReadAll(resp.Body)
  37020. if ioErr != nil {
  37021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37023. return
  37024. }
  37025. var respJSON map[string]interface{}
  37026. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37029. return
  37030. }
  37031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37032. result, _ := json.Marshal(respJSON)
  37033. fmt.Println("log")
  37034. fmt.Println(string(result))
  37035. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37036. utils.ErrorLog("解析失败:%v", err)
  37037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37038. return
  37039. }
  37040. } else if miConfig.MdtrtareaAdmvs == "420200" {
  37041. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37042. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37043. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37044. resp, requestErr := http.Get(api)
  37045. if requestErr != nil {
  37046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37047. return
  37048. }
  37049. body, ioErr := ioutil.ReadAll(resp.Body)
  37050. if ioErr != nil {
  37051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37053. return
  37054. }
  37055. var respJSON map[string]interface{}
  37056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37059. return
  37060. }
  37061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37062. result, _ := json.Marshal(respJSON)
  37063. fmt.Println("log")
  37064. fmt.Println(string(result))
  37065. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37066. utils.ErrorLog("解析失败:%v", err)
  37067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37068. return
  37069. }
  37070. } else if miConfig.MdtrtareaAdmvs == "420902" {
  37071. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37072. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37073. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37074. resp, requestErr := http.Get(api)
  37075. if requestErr != nil {
  37076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37077. return
  37078. }
  37079. body, ioErr := ioutil.ReadAll(resp.Body)
  37080. if ioErr != nil {
  37081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37083. return
  37084. }
  37085. var respJSON map[string]interface{}
  37086. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37089. return
  37090. }
  37091. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37092. result, _ := json.Marshal(respJSON)
  37093. fmt.Println("log")
  37094. fmt.Println(string(result))
  37095. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37096. utils.ErrorLog("解析失败:%v", err)
  37097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37098. return
  37099. }
  37100. } else if miConfig.MdtrtareaAdmvs == "421182" {
  37101. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37102. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37103. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  37104. resp, requestErr := http.Get(api)
  37105. if requestErr != nil {
  37106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37107. return
  37108. }
  37109. body, ioErr := ioutil.ReadAll(resp.Body)
  37110. if ioErr != nil {
  37111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37113. return
  37114. }
  37115. var respJSON map[string]interface{}
  37116. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37119. return
  37120. }
  37121. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37122. result, _ := json.Marshal(respJSON)
  37123. fmt.Println("log")
  37124. fmt.Println(string(result))
  37125. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37126. utils.ErrorLog("解析失败:%v", err)
  37127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37128. return
  37129. }
  37130. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  37131. var api string
  37132. if miConfig.MdtrtareaAdmvs == "320830" {
  37133. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37134. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37135. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37136. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37137. } else if miConfig.MdtrtareaAdmvs == "320921" {
  37138. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37139. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37140. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37141. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37142. } else {
  37143. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37144. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37145. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37146. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37147. }
  37148. resp, requestErr := http.Get(api)
  37149. if requestErr != nil {
  37150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37151. return
  37152. }
  37153. body, ioErr := ioutil.ReadAll(resp.Body)
  37154. if ioErr != nil {
  37155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37157. return
  37158. }
  37159. var respJSON map[string]interface{}
  37160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37163. return
  37164. }
  37165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37166. result, _ := json.Marshal(respJSON)
  37167. fmt.Println("log")
  37168. fmt.Println(string(result))
  37169. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37170. utils.ErrorLog("解析失败:%v", err)
  37171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37172. return
  37173. }
  37174. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37175. res.Output = resEleven10265.Output
  37176. res.ErrMsg = resEleven10265.ErrMsg
  37177. res.Cainfo = resEleven10265.Cainfo
  37178. res.WarnMsg = resEleven10265.WarnMsg
  37179. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37180. res.Infcode = infocode
  37181. } else if miConfig.MdtrtareaAdmvs == "350500" {
  37182. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  37183. saveLog(result, requestLog, "5203", "结算单")
  37184. var dat map[string]interface{}
  37185. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37186. fmt.Println(dat)
  37187. } else {
  37188. fmt.Println(err)
  37189. }
  37190. userJSONBytes, _ := json.Marshal(dat)
  37191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37192. utils.ErrorLog("解析失败:%v", err)
  37193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37194. return
  37195. }
  37196. } else if miConfig.MdtrtareaAdmvs == "360302" {
  37197. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37198. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37199. saveLog(result, requestLog, "5203", "结算单")
  37200. var dat map[string]interface{}
  37201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37202. fmt.Println(dat)
  37203. } else {
  37204. fmt.Println(err)
  37205. }
  37206. userJSONBytes, _ := json.Marshal(dat)
  37207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37208. utils.ErrorLog("解析失败:%v", err)
  37209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37210. return
  37211. }
  37212. } else if miConfig.MdtrtareaAdmvs == "361025" {
  37213. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37214. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37215. saveLog(result, requestLog, "5203", "结算单")
  37216. var dat map[string]interface{}
  37217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37218. fmt.Println(dat)
  37219. } else {
  37220. fmt.Println(err)
  37221. }
  37222. userJSONBytes, _ := json.Marshal(dat)
  37223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37224. utils.ErrorLog("解析失败:%v", err)
  37225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37226. return
  37227. }
  37228. } else if miConfig.MdtrtareaAdmvs == "360100" {
  37229. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37230. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37231. saveLog(result, requestLog, "5203", "结算单")
  37232. var dat map[string]interface{}
  37233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37234. fmt.Println(dat)
  37235. } else {
  37236. fmt.Println(err)
  37237. }
  37238. userJSONBytes, _ := json.Marshal(dat)
  37239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37240. utils.ErrorLog("解析失败:%v", err)
  37241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37242. return
  37243. }
  37244. } else if miConfig.MdtrtareaAdmvs == "341203" {
  37245. var api string
  37246. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37247. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37248. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37249. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37250. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37251. resp, requestErr := http.Get(api)
  37252. if requestErr != nil {
  37253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37254. return
  37255. }
  37256. body, ioErr := ioutil.ReadAll(resp.Body)
  37257. if ioErr != nil {
  37258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37260. return
  37261. }
  37262. var respJSON map[string]interface{}
  37263. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37266. return
  37267. }
  37268. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37269. if status == "0" {
  37270. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37271. c.ServeSuccessJSON(map[string]interface{}{
  37272. "failed_code": -10,
  37273. "msg": err_msg,
  37274. })
  37275. return
  37276. }
  37277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37278. result, _ := json.Marshal(respJSON)
  37279. fmt.Println("log")
  37280. fmt.Println(string(result))
  37281. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37282. utils.ErrorLog("解析失败:%v", err)
  37283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37284. return
  37285. }
  37286. res.InfRefmsgid = resah.InfRefmsgid
  37287. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37288. // 创建对应的Time类型
  37289. t := time.UnixMilli(timestamp)
  37290. // 格式化成指定的日期字符串
  37291. str := t.Format("2006-01-02 15:04:05")
  37292. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37293. // 创建对应的Time类型
  37294. t3 := time.UnixMilli(timestamp2)
  37295. // 格式化成指定的日期字符串
  37296. str2 := t3.Format("2006-01-02 15:04:05")
  37297. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37298. // 创建对应的Time类型
  37299. t4 := time.UnixMilli(timestamp3)
  37300. // 格式化成指定的日期字符串
  37301. str3 := t4.Format("2006-01-02 15:04:05")
  37302. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37303. // 创建对应的Time类型
  37304. t5 := time.UnixMilli(timestamp4)
  37305. // 格式化成指定的日期字符串
  37306. str5 := t5.Format("2006-01-02 15:04:05")
  37307. res.Output.Setlinfo.Brdy = str2
  37308. res.Output.Setlinfo.SetlTime = str
  37309. res.Output.Setlinfo.Begndate = str3
  37310. res.Output.Setlinfo.Enddate = str5
  37311. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37312. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37313. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37314. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37315. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37316. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37317. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37318. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37319. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37320. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37321. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37322. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37323. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37324. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37325. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37326. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37327. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37328. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37329. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37330. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37331. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37332. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37333. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37334. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37335. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37336. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37337. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37338. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37339. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37340. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37341. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37342. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37343. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37344. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37345. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37346. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37347. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37348. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37349. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37350. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37351. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37352. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37353. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37354. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37355. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37356. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37357. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37358. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37359. //res.Output.Setldetail = resah.Output.Setldetail
  37360. res.ErrMsg = resah.ErrMsg
  37361. res.Cainfo = resah.Cainfo
  37362. res.WarnMsg = resah.WarnMsg
  37363. } else if miConfig.MdtrtareaAdmvs == "340699" {
  37364. var api string
  37365. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37366. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37367. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37368. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37369. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37370. resp, requestErr := http.Get(api)
  37371. if requestErr != nil {
  37372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37373. return
  37374. }
  37375. body, ioErr := ioutil.ReadAll(resp.Body)
  37376. if ioErr != nil {
  37377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37379. return
  37380. }
  37381. var respJSON map[string]interface{}
  37382. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37385. return
  37386. }
  37387. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37388. if status == "0" {
  37389. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37390. c.ServeSuccessJSON(map[string]interface{}{
  37391. "failed_code": -10,
  37392. "msg": err_msg,
  37393. })
  37394. return
  37395. }
  37396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37397. result, _ := json.Marshal(respJSON)
  37398. fmt.Println("log")
  37399. fmt.Println(string(result))
  37400. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37401. utils.ErrorLog("解析失败:%v", err)
  37402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37403. return
  37404. }
  37405. res.InfRefmsgid = resah.InfRefmsgid
  37406. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37407. // 创建对应的Time类型
  37408. t := time.UnixMilli(timestamp)
  37409. // 格式化成指定的日期字符串
  37410. str := t.Format("2006-01-02 15:04:05")
  37411. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37412. // 创建对应的Time类型
  37413. t3 := time.UnixMilli(timestamp2)
  37414. // 格式化成指定的日期字符串
  37415. str2 := t3.Format("2006-01-02 15:04:05")
  37416. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37417. // 创建对应的Time类型
  37418. t4 := time.UnixMilli(timestamp3)
  37419. // 格式化成指定的日期字符串
  37420. str3 := t4.Format("2006-01-02 15:04:05")
  37421. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37422. // 创建对应的Time类型
  37423. t5 := time.UnixMilli(timestamp4)
  37424. // 格式化成指定的日期字符串
  37425. str5 := t5.Format("2006-01-02 15:04:05")
  37426. res.Output.Setlinfo.Brdy = str2
  37427. res.Output.Setlinfo.SetlTime = str
  37428. res.Output.Setlinfo.Begndate = str3
  37429. res.Output.Setlinfo.Enddate = str5
  37430. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37431. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37432. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37433. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37434. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37435. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37436. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37437. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37438. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37439. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37440. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37441. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37442. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37443. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37444. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37445. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37446. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37447. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37448. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37449. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37450. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37451. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37452. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37453. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37454. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37455. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37456. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37457. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37458. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37459. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37460. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37461. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37462. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37463. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37464. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37465. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37466. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37467. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37468. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37469. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37470. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37471. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37472. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37473. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37474. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37475. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37476. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37477. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37478. //res.Output.Setldetail = resah.Output.Setldetail
  37479. res.ErrMsg = resah.ErrMsg
  37480. res.Cainfo = resah.Cainfo
  37481. res.WarnMsg = resah.WarnMsg
  37482. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37483. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37484. saveLog(result, requestLog, "5203", "结算单")
  37485. var dat map[string]interface{}
  37486. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37487. fmt.Println(dat)
  37488. } else {
  37489. fmt.Println(err)
  37490. }
  37491. userJSONBytes, _ := json.Marshal(dat)
  37492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37493. utils.ErrorLog("解析失败:%v", err)
  37494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37495. return
  37496. }
  37497. } else if miConfig.MdtrtareaAdmvs == "150404" {
  37498. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37499. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37500. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37501. resp, requestErr := http.Get(api)
  37502. if requestErr != nil {
  37503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37504. return
  37505. }
  37506. body, ioErr := ioutil.ReadAll(resp.Body)
  37507. if ioErr != nil {
  37508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37510. return
  37511. }
  37512. var respJSON map[string]interface{}
  37513. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37516. return
  37517. }
  37518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37519. result, _ := json.Marshal(respJSON)
  37520. fmt.Println("log")
  37521. fmt.Println(string(result))
  37522. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37523. utils.ErrorLog("解析失败:%v", err)
  37524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37525. return
  37526. }
  37527. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37528. res.Output = resEleven10265.Output
  37529. res.ErrMsg = resEleven10265.ErrMsg
  37530. res.Cainfo = resEleven10265.Cainfo
  37531. res.WarnMsg = resEleven10265.WarnMsg
  37532. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37533. res.Infcode = infocode
  37534. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37535. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37536. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37537. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37538. resp, requestErr := http.Get(api)
  37539. if requestErr != nil {
  37540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37541. return
  37542. }
  37543. body, ioErr := ioutil.ReadAll(resp.Body)
  37544. if ioErr != nil {
  37545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37547. return
  37548. }
  37549. var respJSON map[string]interface{}
  37550. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37553. return
  37554. }
  37555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37556. result, _ := json.Marshal(respJSON)
  37557. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37558. utils.ErrorLog("解析失败:%v", err)
  37559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37560. return
  37561. }
  37562. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37563. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37564. //return
  37565. } else {
  37566. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37567. if len(his.InsuplcAdmdvs) == 0 {
  37568. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37569. } else {
  37570. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37571. }
  37572. result := service.Gdyb5203(baseParams, businessParams)
  37573. //service.Gdyb5204(baseParams, businessParams)
  37574. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37575. var dat map[string]interface{}
  37576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37577. fmt.Println(dat)
  37578. } else {
  37579. fmt.Println(err)
  37580. }
  37581. userJSONBytes, _ := json.Marshal(dat)
  37582. if miConfig.Code == "H15049901371" {
  37583. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37584. utils.ErrorLog("解析失败:%v", err)
  37585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37586. return
  37587. }
  37588. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37589. res.Output = resEleven10265.Output
  37590. res.ErrMsg = resEleven10265.ErrMsg
  37591. res.Cainfo = resEleven10265.Cainfo
  37592. res.WarnMsg = resEleven10265.WarnMsg
  37593. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37594. res.Infcode = infocode
  37595. } else {
  37596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37597. utils.ErrorLog("解析失败:%v", err)
  37598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37599. return
  37600. }
  37601. }
  37602. }
  37603. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37604. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37605. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37606. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37607. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37608. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37609. var doctor_name string
  37610. if roles.ID == 0 {
  37611. doctor_name = "管理员"
  37612. } else {
  37613. doctor_name = roles.UserName
  37614. }
  37615. yiliao_leibie := ""
  37616. switch order.MedType {
  37617. case "11":
  37618. yiliao_leibie = "普通门诊"
  37619. break
  37620. case "12":
  37621. yiliao_leibie = "门诊挂号"
  37622. break
  37623. case "13":
  37624. yiliao_leibie = "急诊"
  37625. break
  37626. case "14":
  37627. yiliao_leibie = "门诊特殊病"
  37628. break
  37629. case "15":
  37630. yiliao_leibie = "门诊统筹"
  37631. break
  37632. case "16":
  37633. yiliao_leibie = "门诊慢性病"
  37634. break
  37635. case "21":
  37636. yiliao_leibie = "普通住院"
  37637. break
  37638. }
  37639. //var rf []CustomFundPay
  37640. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37641. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37642. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37643. if res.Infcode == 0 {
  37644. 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 || adminUser.CurrentOrgId == 10571 || adminUser.CurrentOrgId == 10752 {
  37645. c.ServeSuccessJSON(map[string]interface{}{
  37646. "diagnosis": name,
  37647. "order_infos": orderInfos,
  37648. "number": order.MdtrtId,
  37649. "date": order.SettleAccountsDate,
  37650. "charge_admin": charge_admin,
  37651. "printor_admin": printor_admin,
  37652. "info": res.Output.Setlinfo,
  37653. "order": order,
  37654. "bedCostTotal": bedCostTotal,
  37655. "bedCostSelfTotal": bedCostSelfTotal,
  37656. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37657. "bedSelfTotal": bedSelfTotal,
  37658. "bedInscpTotal": bedInscpTotal,
  37659. "operationCostTotal": operationCostTotal,
  37660. "operationCostSelfTotal": operationCostSelfTotal,
  37661. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37662. "operationSelfTotal": operationSelfTotal,
  37663. "operationInscpTotal": operationInscpTotal,
  37664. "otherCostTotal": otherCostTotal,
  37665. "otherCostSelfTotal": otherCostSelfTotal,
  37666. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37667. "otherSelfTotal": otherSelfTotal,
  37668. "otherInscpTotal": otherInscpTotal,
  37669. "materialCostTotal": materialCostTotal,
  37670. "materialCostSelfTotal": materialCostSelfTotal,
  37671. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37672. "materialSelfTotal": materialSelfTotal,
  37673. "materialInscpTotal": materialInscpTotal,
  37674. "westernMedicineCostTotal": westernMedicineCostTotal,
  37675. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37676. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37677. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37678. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37679. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37680. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37681. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37682. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37683. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37684. "checkCostTotal": checkCostTotal,
  37685. "checkCostSelfTotal": checkCostSelfTotal,
  37686. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37687. "checkSelfTotal": checkSelfTotal,
  37688. "checkInscpTotal": checkInscpTotal,
  37689. "laboratoryCostTotal": laboratoryCostTotal,
  37690. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37691. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37692. "laboratorySelfTotal": laboratorySelfTotal,
  37693. "laboratoryInscpTotal": laboratoryInscpTotal,
  37694. "treatCostTotal": treatCostTotal,
  37695. "treatCostSelfTotal": treatCostSelfTotal,
  37696. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37697. "treatSelfTotal": treatSelfTotal,
  37698. "treatInscpTotal": treatInscpTotal,
  37699. "doctor_info": doctor_info,
  37700. "doctor_code": adminRole_two.DoctorCode,
  37701. "doctor_name": doctor_name,
  37702. "health_card_no": order.PsnNo,
  37703. "department": departments.Name,
  37704. "yiliao_leibie": yiliao_leibie,
  37705. "after_money": order.AccountPrice,
  37706. "patient": patient,
  37707. "org_name": miConfig.OrgName,
  37708. "org_code": miConfig.Code,
  37709. "order_number": order.Number,
  37710. "his_hospital": his_hospital,
  37711. "his": his,
  37712. "dia_config": dia_config,
  37713. "psn_cash_pay": order.PsnCashPay,
  37714. "zcCostTotal": zcCostTotal,
  37715. "zcCostSelfTotal": zcCostSelfTotal,
  37716. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37717. "zcSelfTotal": zcSelfTotal,
  37718. "zcInscpTotal": zcInscpTotal,
  37719. "huliCostTotal": huliCostTotal,
  37720. "huliCostSelfTotal": huliCostSelfTotal,
  37721. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37722. "huliSelfTotal": huliSelfTotal,
  37723. "huliInscpTotal": huliInscpTotal,
  37724. //"funds": rf,
  37725. //"check_order_info": cus_slice,
  37726. })
  37727. } else {
  37728. c.ServeSuccessJSON(map[string]interface{}{
  37729. "diagnosis": name,
  37730. "order_infos": orderInfos,
  37731. "number": order.MdtrtId,
  37732. "date": order.SettleAccountsDate,
  37733. "charge_admin": charge_admin,
  37734. "printor_admin": printor_admin,
  37735. "info": order,
  37736. "order": order,
  37737. "bedCostTotal": bedCostTotal,
  37738. "bedCostSelfTotal": bedCostSelfTotal,
  37739. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37740. "bedSelfTotal": bedSelfTotal,
  37741. "bedInscpTotal": bedInscpTotal,
  37742. "operationCostTotal": operationCostTotal,
  37743. "operationCostSelfTotal": operationCostSelfTotal,
  37744. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37745. "operationSelfTotal": operationSelfTotal,
  37746. "operationInscpTotal": operationInscpTotal,
  37747. "otherCostTotal": otherCostTotal,
  37748. "otherCostSelfTotal": otherCostSelfTotal,
  37749. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37750. "otherSelfTotal": otherSelfTotal,
  37751. "otherInscpTotal": otherInscpTotal,
  37752. "materialCostTotal": materialCostTotal,
  37753. "materialCostSelfTotal": materialCostSelfTotal,
  37754. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37755. "materialSelfTotal": materialSelfTotal,
  37756. "materialInscpTotal": materialInscpTotal,
  37757. "westernMedicineCostTotal": westernMedicineCostTotal,
  37758. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37759. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37760. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37761. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37762. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37763. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37764. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37765. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37766. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37767. "checkCostTotal": checkCostTotal,
  37768. "checkCostSelfTotal": checkCostSelfTotal,
  37769. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37770. "checkSelfTotal": checkSelfTotal,
  37771. "checkInscpTotal": checkInscpTotal,
  37772. "laboratoryCostTotal": laboratoryCostTotal,
  37773. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37774. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37775. "laboratorySelfTotal": laboratorySelfTotal,
  37776. "laboratoryInscpTotal": laboratoryInscpTotal,
  37777. "treatCostTotal": treatCostTotal,
  37778. "treatCostSelfTotal": treatCostSelfTotal,
  37779. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37780. "treatSelfTotal": treatSelfTotal,
  37781. "treatInscpTotal": treatInscpTotal,
  37782. "doctor_info": doctor_info,
  37783. "doctor_code": adminRole_two.DoctorCode,
  37784. "doctor_name": doctor_name,
  37785. "health_card_no": order.PsnNo,
  37786. "department": departments.Name,
  37787. "yiliao_leibie": yiliao_leibie,
  37788. "after_money": order.AccountPrice,
  37789. "patient": patient,
  37790. "org_name": miConfig.OrgName,
  37791. "org_code": miConfig.Code,
  37792. "order_number": order.Number,
  37793. "his_hospital": his_hospital,
  37794. "his": his,
  37795. "dia_config": dia_config,
  37796. "psn_cash_pay": order.PsnCashPay,
  37797. "zcCostTotal": zcCostTotal,
  37798. "zcCostSelfTotal": zcCostSelfTotal,
  37799. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37800. "zcSelfTotal": zcSelfTotal,
  37801. "zcInscpTotal": zcInscpTotal,
  37802. "huliCostTotal": huliCostTotal,
  37803. "huliCostSelfTotal": huliCostSelfTotal,
  37804. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37805. "huliSelfTotal": huliSelfTotal,
  37806. "huliInscpTotal": huliInscpTotal,
  37807. //"funds": rf,
  37808. //"check_order_info": cus_slice,
  37809. })
  37810. }
  37811. }
  37812. }
  37813. }
  37814. //func (c *HisApiController) CheckTreatment() {
  37815. // patient_id, _ := c.GetInt64("patient_id")
  37816. // id_card_no := c.GetString("id_card_no")
  37817. // insutype := c.GetString("insutype")
  37818. // med_type := c.GetString("med_type")
  37819. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37820. //
  37821. // adminUser := c.GetAdminUserInfo()
  37822. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37823. //
  37824. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37825. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37826. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37827. //
  37828. // if miConfig.MdtrtareaAdmvs == "421300" {
  37829. // var res ResultTwo
  37830. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37831. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37832. // "&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)
  37833. // resp, requestErr := http.Get(api)
  37834. // if requestErr != nil {
  37835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37836. // return
  37837. // }
  37838. //
  37839. // body, ioErr := ioutil.ReadAll(resp.Body)
  37840. // if ioErr != nil {
  37841. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37843. // return
  37844. // }
  37845. // var respJSON map[string]interface{}
  37846. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37847. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37849. // return
  37850. // }
  37851. //
  37852. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37853. // result, _ := json.Marshal(respJSON)
  37854. //
  37855. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37856. // utils.ErrorLog("解析失败:%v", err)
  37857. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37858. // return
  37859. // }
  37860. //
  37861. // if res.Infcode == 0 {
  37862. //
  37863. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37864. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37865. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37866. // resp, requestErr := http.Get(api)
  37867. // if requestErr != nil {
  37868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37869. // return
  37870. // }
  37871. //
  37872. // body, ioErr := ioutil.ReadAll(resp.Body)
  37873. // if ioErr != nil {
  37874. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37876. // return
  37877. // }
  37878. // var respJSON map[string]interface{}
  37879. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37880. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37882. // return
  37883. // }
  37884. // var res Result2001
  37885. //
  37886. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37887. // result2, _ := json.Marshal(respJSON)
  37888. //
  37889. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37890. // utils.ErrorLog("解析失败:%v", err)
  37891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37892. // return
  37893. // }
  37894. //
  37895. // if res.Infcode == 0 {
  37896. // c.ServeSuccessJSON(map[string]interface{}{
  37897. // "msg": res.Output.Trtinfo,
  37898. // })
  37899. // }
  37900. //
  37901. // } else {
  37902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37903. // return
  37904. // }
  37905. //
  37906. // } else {
  37907. //
  37908. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37909. // var dat map[string]interface{}
  37910. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37911. // fmt.Println(dat)
  37912. // } else {
  37913. // fmt.Println(err)
  37914. // }
  37915. // userJSONBytes, _ := json.Marshal(dat)
  37916. // var res ResultTwo
  37917. // var res10265 ResultTwo10265
  37918. // if miConfig.Code == "H15049901371" {
  37919. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37920. // utils.ErrorLog("解析失败:%v", err)
  37921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37922. // return
  37923. // }
  37924. // res.ErrMsg = res10265.ErrMsg
  37925. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37926. // res.Infcode = infocode
  37927. // res.Output = res10265.Output
  37928. // res.InfRefmsgid = res10265.InfRefmsgid
  37929. // } else {
  37930. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37931. // utils.ErrorLog("解析失败:%v", err)
  37932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37933. // return
  37934. // }
  37935. // }
  37936. //
  37937. // var user_name string
  37938. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37939. // if role.ID == 0 {
  37940. // user_name = "xxx"
  37941. // } else {
  37942. // user_name = role.UserName
  37943. // }
  37944. //
  37945. // baseParams := models.BaseParams{
  37946. // SecretKey: miConfig.SecretKey,
  37947. // FixmedinsCode: miConfig.Code,
  37948. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37949. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37950. // OrgName: miConfig.OrgName,
  37951. // Doctor: user_name,
  37952. // }
  37953. //
  37954. // if config.IsOpen == 1 {
  37955. // if miConfig.Code == "H15049901371" {
  37956. // if med_type == "14" {
  37957. // if insutype == "390" {
  37958. // med_type = "9933"
  37959. // } else if insutype == "310" {
  37960. // med_type = "990502"
  37961. // }
  37962. // } else if med_type == "11" {
  37963. // med_type = "11"
  37964. // }
  37965. // }
  37966. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37967. // var dat map[string]interface{}
  37968. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37969. // fmt.Println(dat)
  37970. // } else {
  37971. // fmt.Println(err)
  37972. // }
  37973. // var res Result2001
  37974. // var res10265 Result2001Org10265
  37975. // if miConfig.Code == "H15049901371" {
  37976. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37977. // utils.ErrorLog("解析失败:%v", err)
  37978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37979. // return
  37980. // }
  37981. // res.ErrMsg = res10265.ErrMsg
  37982. // res.Output = res10265.Output
  37983. // res.InfRefmsgid = res10265.InfRefmsgid
  37984. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37985. // res.Infcode = infocode
  37986. // } else {
  37987. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37988. // utils.ErrorLog("解析失败:%v", err)
  37989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37990. // return
  37991. // }
  37992. // }
  37993. // if res.Infcode == 0 {
  37994. // c.ServeSuccessJSON(map[string]interface{}{
  37995. // "msg": res.Output.Trtinfo,
  37996. // })
  37997. // }
  37998. // }
  37999. // }
  38000. //}
  38001. //func (c *HisApiController) PutRecord() {
  38002. // id, _ := c.GetInt64("id")
  38003. // record_time := c.GetString("record_time")
  38004. // timeLayout := "2006-01-02"
  38005. // loc, _ := time.LoadLocation("Local")
  38006. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  38007. // if err != nil {
  38008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  38009. // return
  38010. // }
  38011. // recordDateTime := theTime.Unix()
  38012. //
  38013. // adminInfo := c.GetAdminUserInfo()
  38014. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  38015. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38016. //
  38017. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  38018. //
  38019. // fmt.Println(miConfig.SecretKey)
  38020. //
  38021. // if patient == nil {
  38022. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38023. // return
  38024. // }
  38025. // if len(patient.IdCardNo) == 0 {
  38026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  38027. // return
  38028. // }
  38029. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  38030. // if config.IsOpen == 1 {
  38031. // 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
  38032. // resp, requestErr := http.Get(api)
  38033. // if requestErr != nil {
  38034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38035. // return
  38036. // }
  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. //
  38046. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38047. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38049. // return
  38050. // }
  38051. //
  38052. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38053. // userJSONBytes, _ := json.Marshal(userJSON)
  38054. // var res ResultTwo
  38055. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38056. // utils.ErrorLog("解析失败:%v", err)
  38057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38058. // return
  38059. // }
  38060. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38061. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38062. // infoStr := string(Iinfos)
  38063. // idetinfoStr := string(Idetinfos)
  38064. //
  38065. // if res.Infcode == 0 {
  38066. // his := models.VMHisPatient{
  38067. // Status: 1,
  38068. // Ctime: time.Now().Unix(),
  38069. // Mtime: time.Now().Unix(),
  38070. // PsnNo: res.Output.Baseinfo.PsnNo,
  38071. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  38072. // Certno: res.Output.Baseinfo.Certno,
  38073. // PsnName: res.Output.Baseinfo.PsnName,
  38074. // Gend: res.Output.Baseinfo.Gend,
  38075. // Naty: res.Output.Baseinfo.Naty,
  38076. // Brdy: res.Output.Baseinfo.Brdy,
  38077. // Age: res.Output.Baseinfo.Age,
  38078. // Iinfo: infoStr,
  38079. // Idetinfo: idetinfoStr,
  38080. // PatientId: patient.ID,
  38081. // RecordDate: theTime.Unix(),
  38082. // UserOrgId: adminInfo.CurrentOrgId,
  38083. // AdminUserId: adminInfo.AdminUser.Id,
  38084. // IsReturn: 1,
  38085. // }
  38086. //
  38087. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  38088. // //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")
  38089. // //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")
  38090. //
  38091. // //var dat map[string]interface{}
  38092. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38093. // // fmt.Println(dat)
  38094. // //} else {
  38095. // // fmt.Println(err)
  38096. // //}
  38097. //
  38098. // var dat2 map[string]interface{}
  38099. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38100. // fmt.Println(dat2)
  38101. // } else {
  38102. // fmt.Println(err)
  38103. // }
  38104. //
  38105. // } else {
  38106. // adminUser := c.GetAdminUserInfo()
  38107. // errlog := &models.HisOrderError{
  38108. // UserOrgId: adminUser.CurrentOrgId,
  38109. // Ctime: time.Now().Unix(),
  38110. // Mtime: time.Now().Unix(),
  38111. // ErrMsg: res.ErrMsg,
  38112. // Status: 1,
  38113. // PatientId: id,
  38114. // RecordTime: recordDateTime,
  38115. // Stage: 1,
  38116. // }
  38117. // service.CreateErrMsgLog(errlog)
  38118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  38119. // return
  38120. // }
  38121. // }
  38122. //
  38123. //}
  38124. //func (c *HisApiController) GetUploadDiag() {
  38125. // id, _ := c.GetInt64("id")
  38126. // record_time := c.GetString("record_time")
  38127. //
  38128. // diagnosis_id, _ := c.GetInt64("diagnosis")
  38129. // sick_type, _ := c.GetInt64("sick_type")
  38130. // reg_type, _ := c.GetInt64("reg_type")
  38131. //
  38132. // timeLayout := "2006-01-02"
  38133. // loc, _ := time.LoadLocation("Local")
  38134. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  38135. // if err != nil {
  38136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  38137. // return
  38138. // }
  38139. //
  38140. // var patientPrescription models.HisPrescriptionInfo
  38141. // recordDateTime := theTime.Unix()
  38142. // adminInfo := c.GetAdminUserInfo()
  38143. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38144. //
  38145. // if patientPrescription.ID == 0 {
  38146. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38147. // }
  38148. //
  38149. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  38150. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  38151. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38152. // sickConfig, _ := service.FindSickById(sick_type)
  38153. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  38154. //
  38155. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  38156. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  38157. // "&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 +
  38158. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  38159. // resp2, requestErr2 := http.Get(api2)
  38160. // if requestErr2 != nil {
  38161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38162. // return
  38163. // }
  38164. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  38165. // if ioErr2 != nil {
  38166. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  38167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38168. // return
  38169. // }
  38170. // var respJSON2 map[string]interface{}
  38171. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  38172. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38174. // return
  38175. // }
  38176. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38177. // userJSONBytes2, _ := json.Marshal(respJSON2)
  38178. //
  38179. // var res2 ResultSix
  38180. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38181. // utils.ErrorLog("解析失败:%v", err)
  38182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38183. // return
  38184. // }
  38185. // if res2.Infcode != 0 {
  38186. // adminUser := c.GetAdminUserInfo()
  38187. // errlog := &models.HisOrderError{
  38188. // UserOrgId: adminUser.CurrentOrgId,
  38189. // Ctime: time.Now().Unix(),
  38190. // Mtime: time.Now().Unix(),
  38191. // ErrMsg: res2.ErrMsg,
  38192. // Status: 1,
  38193. // PatientId: id,
  38194. // RecordTime: recordDateTime,
  38195. // Stage: 3,
  38196. // }
  38197. // service.CreateErrMsgLog(errlog)
  38198. //
  38199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  38200. // return
  38201. // }
  38202. //
  38203. // c.ServeSuccessJSON(map[string]interface{}{
  38204. // "msg": "上传成功",
  38205. // })
  38206. //
  38207. //}
  38208. type QueryResult struct {
  38209. ID int64
  38210. Name string
  38211. Code string
  38212. List_type_code string
  38213. }
  38214. func (c *HisApiController) GetCheckCode() {
  38215. ids_str := c.GetString("ids")
  38216. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38217. ids_arr := strings.Split(ids_str, ",")
  38218. var queryResult []QueryResult
  38219. ids := make([]int64, 0)
  38220. for _, item := range ids_arr {
  38221. id, _ := strconv.ParseInt(item, 10, 64)
  38222. ids = append(ids, id)
  38223. }
  38224. if record_type == 1 {
  38225. drugs, _ := service.GetBatchDrugList(ids)
  38226. for _, item := range drugs {
  38227. result := QueryResult{
  38228. ID: item.ID,
  38229. Name: item.DrugName,
  38230. Code: item.MedicalInsuranceNumber,
  38231. List_type_code: "101",
  38232. }
  38233. queryResult = append(queryResult, result)
  38234. }
  38235. } else if record_type == 2 {
  38236. goods, _ := service.GetBatchGoodInformationList(ids)
  38237. fmt.Println(goods)
  38238. for _, item := range goods {
  38239. result := QueryResult{
  38240. ID: item.ID,
  38241. Name: item.GoodName,
  38242. Code: item.SocialSecurityDirectoryCode,
  38243. List_type_code: "301",
  38244. }
  38245. queryResult = append(queryResult, result)
  38246. }
  38247. } else if record_type == 3 {
  38248. projects, _ := service.GetBathchMyPorjecgList(ids)
  38249. for _, item := range projects {
  38250. result := QueryResult{
  38251. ID: item.ID,
  38252. Name: item.ProjectName,
  38253. Code: item.MedicalCode,
  38254. List_type_code: "201",
  38255. }
  38256. queryResult = append(queryResult, result)
  38257. }
  38258. }
  38259. admin_user_id, _ := c.GetInt64("admin_user_id")
  38260. adminUser := c.GetAdminUserInfo()
  38261. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38262. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38263. var user_name string
  38264. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38265. if role.ID == 0 {
  38266. user_name = "管理员"
  38267. } else {
  38268. user_name = role.UserName
  38269. }
  38270. baseParams := models.BaseParams{
  38271. SecretKey: miConfig.SecretKey,
  38272. FixmedinsCode: miConfig.Code,
  38273. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38274. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38275. OrgName: miConfig.OrgName,
  38276. Doctor: user_name,
  38277. }
  38278. var result string
  38279. if miConfig.MdtrtareaAdmvs == "430800" {
  38280. for _, item := range queryResult {
  38281. if record_type == 1 {
  38282. 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)
  38283. } else if record_type == 2 {
  38284. fmt.Println(item.Code)
  38285. 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)
  38286. } else if record_type == 3 {
  38287. 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)
  38288. }
  38289. var dat map[string]interface{}
  38290. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38291. fmt.Println(dat)
  38292. } else {
  38293. fmt.Println(err)
  38294. }
  38295. userJSONBytes, _ := json.Marshal(dat)
  38296. var res ResultSix
  38297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38298. utils.ErrorLog("解析失败:%v", err)
  38299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38300. return
  38301. }
  38302. if res.Infcode == 0 {
  38303. if record_type == 1 {
  38304. service.UpdateBaseDrugById(item.ID)
  38305. } else if record_type == 2 {
  38306. service.UpdateGoodInformaitonByDetail(item.ID)
  38307. } else if record_type == 3 {
  38308. service.UpdateProjectById(item.ID)
  38309. }
  38310. c.ServeSuccessJSON(map[string]interface{}{
  38311. "failed_code": 0,
  38312. "msg": "目录对照成功",
  38313. })
  38314. } else {
  38315. c.ServeSuccessJSON(map[string]interface{}{
  38316. "failed_code": -10,
  38317. "msg": res.ErrMsg,
  38318. })
  38319. }
  38320. }
  38321. } else {
  38322. for _, item := range queryResult {
  38323. var result string
  38324. if record_type == 1 {
  38325. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38326. } else if record_type == 2 {
  38327. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38328. } else if record_type == 3 {
  38329. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38330. }
  38331. var dat map[string]interface{}
  38332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38333. fmt.Println(dat)
  38334. } else {
  38335. fmt.Println(err)
  38336. }
  38337. userJSONBytes, _ := json.Marshal(dat)
  38338. var res ResultSix
  38339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38340. utils.ErrorLog("解析失败:%v", err)
  38341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38342. return
  38343. }
  38344. if res.Infcode == 0 {
  38345. if record_type == 1 {
  38346. service.UpdateBaseDrugById(item.ID)
  38347. } else if record_type == 2 {
  38348. service.UpdateGoodInformaitonByDetail(item.ID)
  38349. } else if record_type == 3 {
  38350. service.UpdateProjectById(item.ID)
  38351. }
  38352. c.ServeSuccessJSON(map[string]interface{}{
  38353. "failed_code": 0,
  38354. "msg": "目录对照成功",
  38355. })
  38356. } else {
  38357. c.ServeSuccessJSON(map[string]interface{}{
  38358. "failed_code": -10,
  38359. "msg": res.ErrMsg,
  38360. })
  38361. }
  38362. }
  38363. }
  38364. }
  38365. func (c *HisApiController) UnCheckCode() {
  38366. ids_str := c.GetString("ids")
  38367. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38368. admin_user_id, _ := c.GetInt64("admin_user_id")
  38369. ids_arr := strings.Split(ids_str, ",")
  38370. var queryResult []QueryResult
  38371. ids := make([]int64, 0)
  38372. for _, item := range ids_arr {
  38373. id, _ := strconv.ParseInt(item, 10, 64)
  38374. ids = append(ids, id)
  38375. }
  38376. if record_type == 1 {
  38377. drugs, _ := service.GetBatchDrugList(ids)
  38378. for _, item := range drugs {
  38379. result := QueryResult{
  38380. ID: item.ID,
  38381. Name: item.DrugName,
  38382. Code: item.MedicalInsuranceNumber,
  38383. List_type_code: "101",
  38384. }
  38385. queryResult = append(queryResult, result)
  38386. }
  38387. } else if record_type == 2 {
  38388. goods, _ := service.GetBatchGoodInformationList(ids)
  38389. for _, item := range goods {
  38390. result := QueryResult{
  38391. ID: item.ID,
  38392. Name: item.GoodName,
  38393. Code: item.SocialSecurityDirectoryCode,
  38394. List_type_code: "301",
  38395. }
  38396. queryResult = append(queryResult, result)
  38397. }
  38398. } else if record_type == 3 {
  38399. projects, _ := service.GetBathchMyPorjecgList(ids)
  38400. for _, item := range projects {
  38401. result := QueryResult{
  38402. ID: item.ID,
  38403. Name: item.ProjectName,
  38404. Code: item.MedicalCode,
  38405. List_type_code: "201",
  38406. }
  38407. queryResult = append(queryResult, result)
  38408. }
  38409. }
  38410. adminUser := c.GetAdminUserInfo()
  38411. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38412. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38413. var user_name string
  38414. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38415. if role.ID == 0 {
  38416. user_name = "xxx"
  38417. } else {
  38418. user_name = role.UserName
  38419. }
  38420. baseParams := &models.BaseParams{
  38421. SecretKey: miConfig.SecretKey,
  38422. FixmedinsCode: miConfig.Code,
  38423. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38424. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38425. OrgName: miConfig.OrgName,
  38426. Doctor: user_name,
  38427. }
  38428. if config.IsOpen == 1 {
  38429. if miConfig.MdtrtareaAdmvs == "430800" {
  38430. for _, item := range queryResult {
  38431. var result string
  38432. if record_type == 1 {
  38433. 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)
  38434. } else if record_type == 2 {
  38435. fmt.Println(item.Code)
  38436. 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)
  38437. } else if record_type == 3 {
  38438. 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)
  38439. }
  38440. var dat map[string]interface{}
  38441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38442. fmt.Println(dat)
  38443. } else {
  38444. fmt.Println(err)
  38445. }
  38446. userJSONBytes, _ := json.Marshal(dat)
  38447. var res ResultSix
  38448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38449. utils.ErrorLog("解析失败:%v", err)
  38450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38451. return
  38452. }
  38453. if res.Infcode == 0 {
  38454. if record_type == 1 {
  38455. service.UpdateBaseDrugById(item.ID)
  38456. } else if record_type == 2 {
  38457. service.UpdateGoodInformaitonByDetail(item.ID)
  38458. } else if record_type == 3 {
  38459. service.UpdateProjectById(item.ID)
  38460. }
  38461. c.ServeSuccessJSON(map[string]interface{}{
  38462. "failed_code": 0,
  38463. "msg": "目录对照成功",
  38464. })
  38465. } else {
  38466. c.ServeSuccessJSON(map[string]interface{}{
  38467. "failed_code": -10,
  38468. "msg": res.ErrMsg,
  38469. })
  38470. }
  38471. }
  38472. } else {
  38473. for _, item := range queryResult {
  38474. var result string
  38475. if record_type == 1 {
  38476. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38477. } else if record_type == 2 {
  38478. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38479. } else if record_type == 3 {
  38480. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38481. }
  38482. var dat2 map[string]interface{}
  38483. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38484. fmt.Println(dat2)
  38485. } else {
  38486. fmt.Println(err)
  38487. }
  38488. userJSONBytes, _ := json.Marshal(dat2)
  38489. var res ResultSix
  38490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38491. utils.ErrorLog("解析失败:%v", err)
  38492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38493. return
  38494. }
  38495. if res.Infcode == 0 {
  38496. if record_type == 1 {
  38497. service.UpdateDrugByIdDetail(item.ID)
  38498. } else if record_type == 2 {
  38499. service.UpdateGoodInfoById(item.ID)
  38500. } else if record_type == 3 {
  38501. service.UpdateMyProjectById(item.ID)
  38502. }
  38503. c.ServeSuccessJSON(map[string]interface{}{
  38504. "failed_code": 0,
  38505. "msg": "撤销目录对照成功",
  38506. })
  38507. } else {
  38508. c.ServeSuccessJSON(map[string]interface{}{
  38509. "failed_code": -10,
  38510. "msg": res.ErrMsg,
  38511. })
  38512. }
  38513. }
  38514. }
  38515. }
  38516. }
  38517. func (c *HisApiController) GetPatientInfo() {
  38518. id_card_no := c.GetString("id_card_no")
  38519. admin_user_id, _ := c.GetInt64("admin_user_id")
  38520. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38521. if patient.ID == 0 {
  38522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38523. return
  38524. }
  38525. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38526. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38527. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38528. var res ResultTwo
  38529. var res10265 ResultTwo10265
  38530. if config.IsOpen == 1 {
  38531. if miConfig.MdtrtareaAdmvs == "150404" {
  38532. //请求内网数据
  38533. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38534. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38535. "&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
  38536. resp, requestErr := http.Get(api)
  38537. if requestErr != nil {
  38538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38539. return
  38540. }
  38541. body, ioErr := ioutil.ReadAll(resp.Body)
  38542. if ioErr != nil {
  38543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38545. return
  38546. }
  38547. var respJSON map[string]interface{}
  38548. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38551. return
  38552. }
  38553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38554. result_byte, _ := json.Marshal(respJSON)
  38555. result := string(result_byte)
  38556. var dat map[string]interface{}
  38557. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38558. fmt.Println(dat)
  38559. } else {
  38560. fmt.Println(err)
  38561. }
  38562. userJSONBytes, _ := json.Marshal(dat)
  38563. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38564. utils.ErrorLog("解析失败:%v", err)
  38565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38566. return
  38567. }
  38568. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38569. res.Infcode = Infcode
  38570. res.ErrMsg = res10265.ErrMsg
  38571. res.Output = res10265.Output
  38572. res.InfRefmsgid = res10265.InfRefmsgid
  38573. res.RespondTime = res10265.RespondTime
  38574. res.WarnInfo = res10265.WarnInfo
  38575. } else {
  38576. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38577. var dat map[string]interface{}
  38578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38579. fmt.Println(dat)
  38580. } else {
  38581. fmt.Println(err)
  38582. }
  38583. userJSONBytes, _ := json.Marshal(dat)
  38584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38585. utils.ErrorLog("解析失败:%v", err)
  38586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38587. return
  38588. }
  38589. }
  38590. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38591. // utils.ErrorLog("解析失败:%v", err)
  38592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38593. // return
  38594. //}
  38595. for index, item := range res.Output.Iinfo {
  38596. if item.PsnInsuStas == "2" {
  38597. fmt.Println("--------")
  38598. res.Output.Iinfo[index].Insutype = "300"
  38599. res.Output.Iinfo[index].PsnInsuStas = "1"
  38600. }
  38601. }
  38602. fmt.Println(res.Output.Iinfo)
  38603. if res.Infcode != 0 {
  38604. c.ServeSuccessJSON(map[string]interface{}{
  38605. "failed_code": -10,
  38606. "msg": res.ErrMsg,
  38607. })
  38608. } else {
  38609. c.ServeSuccessJSON(map[string]interface{}{
  38610. "failed_code": 0,
  38611. "info": res,
  38612. })
  38613. }
  38614. }
  38615. }
  38616. func (c *HisApiController) PsnPutOnRecord() {
  38617. record_type, _ := c.GetInt64("type")
  38618. patient_id, _ := c.GetInt64("patient_id")
  38619. admin_user_id, _ := c.GetInt64("admin_user_id")
  38620. start_time := c.GetString("start_time")
  38621. end_time := c.GetString("end_time")
  38622. adminUser := c.GetAdminUserInfo()
  38623. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38624. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38625. var patients []*models.Patients
  38626. if record_type == 1 { //全部备案
  38627. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38628. patients = append(patients, patient...)
  38629. } else { //单个备案
  38630. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38631. patients = append(patients, patient)
  38632. }
  38633. var user_name string
  38634. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38635. if role.ID == 0 {
  38636. user_name = "xxx"
  38637. } else {
  38638. user_name = role.UserName
  38639. }
  38640. if config.IsOpen == 1 {
  38641. for _, item := range patients {
  38642. 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
  38643. resp, requestErr := http.Get(api)
  38644. if requestErr != nil {
  38645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38646. return
  38647. }
  38648. defer resp.Body.Close()
  38649. body, ioErr := ioutil.ReadAll(resp.Body)
  38650. if ioErr != nil {
  38651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38653. return
  38654. }
  38655. var respJSON map[string]interface{}
  38656. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38659. return
  38660. }
  38661. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38662. userJSONBytes, _ := json.Marshal(userJSON)
  38663. var res ResultTwo
  38664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38665. utils.ErrorLog("解析失败:%v", err)
  38666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38667. return
  38668. }
  38669. if res.Infcode == 0 {
  38670. 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)
  38671. var dat map[string]interface{}
  38672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38673. fmt.Println(dat)
  38674. } else {
  38675. fmt.Println(err)
  38676. }
  38677. userJSONBytes, _ := json.Marshal(dat)
  38678. var res2 ResultThirteen
  38679. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38680. utils.ErrorLog("解析失败:%v", err)
  38681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38682. return
  38683. }
  38684. if res2.Infcode == 0 {
  38685. psnResult := &models.GdybPsnRecord{
  38686. UserOrgId: adminUser.CurrentOrgId,
  38687. PatientId: item.ID,
  38688. PsnNo: res.Output.Baseinfo.PsnNo,
  38689. Ctime: time.Now().Unix(),
  38690. Mtime: time.Now().Unix(),
  38691. Status: 1,
  38692. IsCancel: 1,
  38693. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38694. }
  38695. service.CreatePsnRecord(psnResult)
  38696. } else {
  38697. c.ServeSuccessJSON(map[string]interface{}{
  38698. "failed_code": -10,
  38699. "msg": res2.ErrMsg,
  38700. })
  38701. return
  38702. }
  38703. }
  38704. }
  38705. }
  38706. }
  38707. func (c *HisApiController) PsnUnPutOnRecord() {
  38708. id, _ := c.GetInt64("id")
  38709. //record_type, _ := c.GetInt64("type")
  38710. admin_user_id, _ := c.GetInt64("admin_user_id")
  38711. adminUser := c.GetAdminUserInfo()
  38712. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38713. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38714. var user_name string
  38715. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38716. if role.ID == 0 {
  38717. user_name = "xxx"
  38718. } else {
  38719. user_name = role.UserName
  38720. }
  38721. psn_record, _ := service.GetPsnRecordById(id)
  38722. if psn_record.ID == 0 {
  38723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38724. return
  38725. }
  38726. if config.IsOpen == 1 {
  38727. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38728. var dat map[string]interface{}
  38729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38730. fmt.Println(dat)
  38731. } else {
  38732. fmt.Println(err)
  38733. }
  38734. userJSONBytes, _ := json.Marshal(dat)
  38735. var res ResultFourteen
  38736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38737. utils.ErrorLog("解析失败:%v", err)
  38738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38739. return
  38740. }
  38741. if res.Infcode == 0 {
  38742. psn_record.IsCancel = 2
  38743. service.CreatePsnRecord(&psn_record)
  38744. } else {
  38745. c.ServeSuccessJSON(map[string]interface{}{
  38746. "failed_code": -10,
  38747. "msg": res.ErrMsg,
  38748. })
  38749. return
  38750. }
  38751. }
  38752. }
  38753. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38754. patient_id, _ := c.GetInt64("patient_id")
  38755. insutype_two := c.GetString("insutype")
  38756. psn_no := c.GetString("psn_no")
  38757. doctor_id, _ := c.GetInt64("doctor_id")
  38758. sick_id, _ := c.GetInt64("sick_id")
  38759. department_id, _ := c.GetInt64("department_id")
  38760. start_time := c.GetString("start_time")
  38761. end_time := c.GetString("end_time")
  38762. check_time := c.GetString("check_time")
  38763. hospital_code := c.GetString("hospital_code")
  38764. hospital_name := c.GetString("hospital_name")
  38765. adminUser := c.GetAdminUserInfo()
  38766. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38767. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38768. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38769. sick, _ := service.FindSickById(sick_id)
  38770. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38771. if len(hospital_code) == 0 {
  38772. hospital_code = miConfig.Code
  38773. }
  38774. if len(hospital_name) == 0 {
  38775. hospital_name = miConfig.OrgName
  38776. }
  38777. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38778. var res ResultTwo
  38779. var res10265 ResultTwo10265
  38780. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38781. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38782. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38783. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38784. "&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
  38785. resp, requestErr := http.Get(api)
  38786. if requestErr != nil {
  38787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38788. return
  38789. }
  38790. body, ioErr := ioutil.ReadAll(resp.Body)
  38791. if ioErr != nil {
  38792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38794. return
  38795. }
  38796. var respJSON map[string]interface{}
  38797. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38800. return
  38801. }
  38802. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38803. result, _ := json.Marshal(respJSON)
  38804. fmt.Println("log")
  38805. fmt.Println(string(result))
  38806. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38807. utils.ErrorLog("解析失败:%v", err)
  38808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38809. return
  38810. }
  38811. res.ErrMsg = res10265.ErrMsg
  38812. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38813. res.Infcode = infocode
  38814. res.Output = res10265.Output
  38815. res.InfRefmsgid = res10265.InfRefmsgid
  38816. } else {
  38817. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38818. if miConfig.Code == "H15049901371" {
  38819. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38820. utils.ErrorLog("解析失败:%v", err)
  38821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38822. return
  38823. }
  38824. res.ErrMsg = res10265.ErrMsg
  38825. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38826. res.Infcode = infocode
  38827. res.Output = res10265.Output
  38828. res.InfRefmsgid = res10265.InfRefmsgid
  38829. } else {
  38830. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38831. utils.ErrorLog("解析失败:%v", err)
  38832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38833. return
  38834. }
  38835. }
  38836. }
  38837. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38838. infoStr := string(Iinfos)
  38839. var rf []*ResultFive
  38840. json.Unmarshal([]byte(infoStr), &rf)
  38841. var insuplc_admdvs string
  38842. var insutype string
  38843. var is390 int = 0
  38844. var is310 int = 0
  38845. var insutypes []*ResultFive
  38846. for _, item := range rf {
  38847. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38848. insutypes = append(insutypes, item)
  38849. }
  38850. }
  38851. if len(insutypes) == 1 {
  38852. insutype = insutypes[0].Insutype
  38853. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38854. } else {
  38855. for _, i := range insutypes {
  38856. if i.Insutype == "390" {
  38857. is390 = 1
  38858. }
  38859. if i.Insutype == "310" {
  38860. is310 = 1
  38861. }
  38862. }
  38863. }
  38864. if is390 == 1 {
  38865. insutype = "390"
  38866. }
  38867. if is310 == 1 {
  38868. insutype = "310"
  38869. }
  38870. if len(insutypes) == 2 {
  38871. insutype = insutype_two
  38872. }
  38873. if len(insutypes) == 0 {
  38874. insutype = "310"
  38875. }
  38876. insutype = insutype_two
  38877. fmt.Println(insutype)
  38878. for _, item := range rf {
  38879. fmt.Println(item.Insutype)
  38880. fmt.Println(insutype)
  38881. if item.Insutype == insutype {
  38882. fmt.Println(item.Insutype)
  38883. fmt.Println(insutype)
  38884. insuplc_admdvs = item.InsuplcAdmdvs
  38885. }
  38886. }
  38887. fmt.Println(insuplc_admdvs)
  38888. var res2 ResultThirteen
  38889. var res10265_2 ResultThirteen10265
  38890. if config.IsOpen == 1 {
  38891. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38892. } else {
  38893. if miConfig.MdtrtareaAdmvs == "150404" {
  38894. //
  38895. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38896. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38897. // "&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
  38898. //resp, requestErr := http.Get(api)
  38899. //if requestErr != nil {
  38900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38901. // return
  38902. //}
  38903. //
  38904. //body, ioErr := ioutil.ReadAll(resp.Body)
  38905. //if ioErr != nil {
  38906. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38908. // return
  38909. //}
  38910. //var respJSON map[string]interface{}
  38911. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38912. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38914. // return
  38915. //}
  38916. //
  38917. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38918. //result, _ := json.Marshal(respJSON)
  38919. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38920. // utils.ErrorLog("解析失败:%v", err)
  38921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38922. // return
  38923. //}
  38924. //infocode = resThree.Infcode
  38925. //result, _ := json.Marshal(respJSON)
  38926. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38927. // utils.ErrorLog("解析失败:%v", err)
  38928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38929. // return
  38930. //}
  38931. //
  38932. //resThree.ErrMsg = resThree10265.ErrMsg
  38933. //
  38934. //resThree.Output = resThree10265.Output
  38935. //
  38936. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38937. //
  38938. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38939. //
  38940. } else {
  38941. 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)
  38942. var dat map[string]interface{}
  38943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38944. fmt.Println(dat)
  38945. } else {
  38946. fmt.Println(err)
  38947. }
  38948. userJSONBytes, _ := json.Marshal(dat)
  38949. if miConfig.Code == "H15049901371" {
  38950. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38951. utils.ErrorLog("解析失败:%v", err)
  38952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38953. return
  38954. }
  38955. res2.ErrMsg = res10265_2.ErrMsg
  38956. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38957. res2.Infcode = infocode
  38958. res2.Output = res10265_2.Output
  38959. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38960. } else {
  38961. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38962. utils.ErrorLog("解析失败:%v", err)
  38963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38964. return
  38965. }
  38966. }
  38967. }
  38968. }
  38969. if res2.Infcode == 0 {
  38970. psnResult := &models.GdybPsnNcdsRecord{
  38971. UserOrgId: adminUser.CurrentOrgId,
  38972. PatientId: patient.ID,
  38973. PsnNo: psn_no,
  38974. DoctorId: doctor.AdminUserId,
  38975. DepartmentId: department_id,
  38976. SickType: sick_id,
  38977. Insutype: insutype,
  38978. Ctime: time.Now().Unix(),
  38979. Mtime: time.Now().Unix(),
  38980. Status: 1,
  38981. IsCancel: 1,
  38982. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38983. }
  38984. service.CreatePsnNCDSRecord(psnResult)
  38985. c.ServeSuccessJSON(map[string]interface{}{
  38986. "failed_code": 0,
  38987. "msg": "备案成功",
  38988. "result": psnResult,
  38989. })
  38990. } else {
  38991. c.ServeSuccessJSON(map[string]interface{}{
  38992. "failed_code": -10,
  38993. "msg": res2.ErrMsg,
  38994. })
  38995. return
  38996. }
  38997. }
  38998. }
  38999. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  39000. id, _ := c.GetInt64("id")
  39001. admin_user_id, _ := c.GetInt64("admin_user_id")
  39002. adminUser := c.GetAdminUserInfo()
  39003. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39004. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39005. //config, _ := service.Ge(adminUser.CurrentOrgId)
  39006. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  39007. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39008. //var user_name string
  39009. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39010. //if role.ID == 0 {
  39011. // user_name = "xxx"
  39012. //} else {
  39013. // user_name = role.UserName
  39014. //}
  39015. psn_record, _ := service.GetPsnNCDSRecordById(id)
  39016. if psn_record.ID == 0 {
  39017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  39018. return
  39019. }
  39020. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  39021. var res ResultTwo
  39022. var res10265 ResultTwo10265
  39023. if miConfig.Code == "H15049901371" {
  39024. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39025. utils.ErrorLog("解析失败:%v", err)
  39026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39027. return
  39028. }
  39029. res.ErrMsg = res10265.ErrMsg
  39030. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39031. res.Infcode = infocode
  39032. res.Output = res10265.Output
  39033. res.InfRefmsgid = res10265.InfRefmsgid
  39034. } else {
  39035. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39036. utils.ErrorLog("解析失败:%v", err)
  39037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39038. return
  39039. }
  39040. }
  39041. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39042. infoStr := string(Iinfos)
  39043. var rf []*ResultFive
  39044. json.Unmarshal([]byte(infoStr), &rf)
  39045. var insuplc_admdvs string
  39046. var insutype string
  39047. var is390 int = 0
  39048. var is310 int = 0
  39049. var insutypes []*ResultFive
  39050. for _, item := range rf {
  39051. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  39052. insutypes = append(insutypes, item)
  39053. }
  39054. }
  39055. if len(insutypes) == 1 {
  39056. insutype = insutypes[0].Insutype
  39057. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  39058. } else {
  39059. for _, i := range insutypes {
  39060. if i.Insutype == "390" {
  39061. is390 = 1
  39062. }
  39063. if i.Insutype == "310" {
  39064. is310 = 1
  39065. }
  39066. }
  39067. }
  39068. if is390 == 1 {
  39069. insutype = "390"
  39070. }
  39071. if is310 == 1 {
  39072. insutype = "310"
  39073. }
  39074. if len(insutypes) == 0 {
  39075. insutype = "310"
  39076. }
  39077. insutype = psn_record.Insutype
  39078. for _, item := range rf {
  39079. if item.Insutype == insutype {
  39080. insuplc_admdvs = item.InsuplcAdmdvs
  39081. }
  39082. }
  39083. if config.IsOpen == 1 {
  39084. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  39085. var dat map[string]interface{}
  39086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39087. fmt.Println(dat)
  39088. } else {
  39089. fmt.Println(err)
  39090. }
  39091. userJSONBytes, _ := json.Marshal(dat)
  39092. var res ResultFourteen
  39093. var res10265 ResultFourteen10265
  39094. if miConfig.Code == "H15049901371" {
  39095. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  39096. utils.ErrorLog("解析失败:%v", err)
  39097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39098. return
  39099. }
  39100. res.ErrMsg = res10265.ErrMsg
  39101. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39102. res.Infcode = infocode
  39103. res.Output = res10265.Output
  39104. res.InfRefmsgid = res10265.InfRefmsgid
  39105. } else {
  39106. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39107. utils.ErrorLog("解析失败:%v", err)
  39108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39109. return
  39110. }
  39111. }
  39112. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39113. // utils.ErrorLog("解析失败:%v", err)
  39114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39115. // return
  39116. //}
  39117. if res.Infcode == 0 {
  39118. psn_record.IsCancel = 2
  39119. service.CreatePsnNCDSRecord(&psn_record)
  39120. c.ServeSuccessJSON(map[string]interface{}{
  39121. "failed_code": 0,
  39122. "msg": "撤销备案成功",
  39123. })
  39124. } else {
  39125. c.ServeSuccessJSON(map[string]interface{}{
  39126. "failed_code": -10,
  39127. "msg": res.ErrMsg,
  39128. })
  39129. return
  39130. }
  39131. }
  39132. }
  39133. func (c *HisApiController) TestTest() {
  39134. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  39135. fmt.Println(patient.Iinfo)
  39136. }
  39137. type CustomData struct {
  39138. MsgId string
  39139. PsnNo string
  39140. Info string
  39141. }
  39142. func (c *HisApiController) ReversalData() {
  39143. var customData []*CustomData
  39144. custom := &CustomData{
  39145. MsgId: "H44022900158202103301714472004",
  39146. PsnNo: "44020000001101329945",
  39147. Info: "2207",
  39148. }
  39149. customData = append(customData, custom)
  39150. custom1 := &CustomData{
  39151. MsgId: "H4402290015820210330172057803",
  39152. PsnNo: "44020000001101161813",
  39153. Info: "2207",
  39154. }
  39155. customData = append(customData, custom1)
  39156. custom2 := &CustomData{
  39157. MsgId: "H44022900158202103301705198813",
  39158. PsnNo: "44190000133097375417",
  39159. Info: "2207",
  39160. }
  39161. customData = append(customData, custom2)
  39162. custom3 := &CustomData{
  39163. MsgId: "H44022900158202103301715524756",
  39164. PsnNo: "44020000001100187221",
  39165. Info: "2207",
  39166. }
  39167. customData = append(customData, custom3)
  39168. custom4 := &CustomData{
  39169. MsgId: "H44022900158202103301730376224",
  39170. PsnNo: "44020000001101959155",
  39171. Info: "2207",
  39172. }
  39173. customData = append(customData, custom4)
  39174. custom5 := &CustomData{
  39175. MsgId: "H44022900158202103301748008725",
  39176. PsnNo: "44020000001104246641",
  39177. Info: "2207",
  39178. }
  39179. customData = append(customData, custom5)
  39180. custom6 := &CustomData{
  39181. MsgId: "H44022900158202103301718096755",
  39182. PsnNo: "44020000001102211860",
  39183. Info: "2207",
  39184. }
  39185. customData = append(customData, custom6)
  39186. custom7 := &CustomData{
  39187. MsgId: "H44022900158202103301736551640",
  39188. PsnNo: "44020000001102687718",
  39189. Info: "2207",
  39190. }
  39191. customData = append(customData, custom7)
  39192. custom8 := &CustomData{
  39193. MsgId: "H44022900158202103301743097676",
  39194. PsnNo: "44020000001102127785",
  39195. Info: "2207",
  39196. }
  39197. customData = append(customData, custom8)
  39198. custom9 := &CustomData{
  39199. MsgId: "H44022900158202103301712304203",
  39200. PsnNo: "44020000001101518097",
  39201. Info: "2207",
  39202. }
  39203. customData = append(customData, custom9)
  39204. custom10 := &CustomData{
  39205. MsgId: "H44022900158202103301738448785",
  39206. PsnNo: "44020000001100500813",
  39207. Info: "2207",
  39208. }
  39209. customData = append(customData, custom10)
  39210. custom11 := &CustomData{
  39211. MsgId: "H44022900158202103301732455843",
  39212. PsnNo: "44020000001102690557",
  39213. Info: "2207",
  39214. }
  39215. customData = append(customData, custom11)
  39216. custom12 := &CustomData{
  39217. MsgId: "H44022900158202103301745421708",
  39218. PsnNo: "44020000001102211928",
  39219. Info: "2207",
  39220. }
  39221. customData = append(customData, custom12)
  39222. custom1212 := &CustomData{
  39223. MsgId: "H440229001582021033017351627",
  39224. PsnNo: "44020000001102481733",
  39225. Info: "2207",
  39226. }
  39227. customData = append(customData, custom1212)
  39228. custom13 := &CustomData{
  39229. MsgId: "H44022900158202103301740327951",
  39230. PsnNo: "44020000001103174866",
  39231. Info: "2207",
  39232. }
  39233. customData = append(customData, custom13)
  39234. custom14 := &CustomData{
  39235. MsgId: "H4402290015820210330174922668",
  39236. PsnNo: "44020000001102927272",
  39237. Info: "2207",
  39238. }
  39239. customData = append(customData, custom14)
  39240. custom15 := &CustomData{
  39241. MsgId: "H44022900158202103301752362273",
  39242. PsnNo: "44020000001102942890",
  39243. Info: "2207",
  39244. }
  39245. customData = append(customData, custom15)
  39246. custom16 := &CustomData{
  39247. MsgId: "H44022900158202103301751082917",
  39248. PsnNo: "44020000001101662162",
  39249. Info: "2207",
  39250. }
  39251. customData = append(customData, custom16)
  39252. custom17 := &CustomData{
  39253. MsgId: "H44022900158202103301754147728",
  39254. PsnNo: "44020000000229014511",
  39255. Info: "2207",
  39256. }
  39257. customData = append(customData, custom17)
  39258. adminUser := c.GetAdminUserInfo()
  39259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39260. for _, item := range customData {
  39261. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39262. fmt.Println(result)
  39263. }
  39264. }
  39265. func (c *HisApiController) GetAllopatry() {
  39266. year := c.GetString("year")
  39267. month := c.GetString("month")
  39268. admin_user_id, _ := c.GetInt64("admin_user_id")
  39269. adminUser := c.GetAdminUserInfo()
  39270. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39271. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39272. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39273. var dat map[string]interface{}
  39274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39275. fmt.Println(dat)
  39276. } else {
  39277. fmt.Println(err)
  39278. }
  39279. userJSONBytes, _ := json.Marshal(dat)
  39280. var res models.Result9001
  39281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39282. utils.ErrorLog("解析失败:%v", err)
  39283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39284. return
  39285. }
  39286. fmt.Println(res.Output.Signinoutb)
  39287. fmt.Println(res.Output.Signinoutb.SignNo)
  39288. fmt.Println(string(userJSONBytes))
  39289. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39290. var dat3 map[string]interface{}
  39291. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  39292. fmt.Println(dat3)
  39293. } else {
  39294. fmt.Println(err)
  39295. }
  39296. userJSONBytes3, _ := json.Marshal(dat3)
  39297. var res3 models.Result3260
  39298. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  39299. utils.ErrorLog("解析失败:%v", err)
  39300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39301. return
  39302. }
  39303. var curpage int
  39304. var pagesize int = 100
  39305. var start int = 1
  39306. //var stop int
  39307. //pagecount := 10
  39308. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  39309. var res22 []models.Result3260
  39310. for curpage = 1; curpage <= pagecount; curpage++ {
  39311. if curpage == 1 {
  39312. start = 0
  39313. } else {
  39314. start = (curpage-1)*pagesize + 1
  39315. }
  39316. fmt.Println(start)
  39317. //stop = curpage * pagesize
  39318. //if stop > int(res3.Output.Totalrow) {
  39319. // stop =int(res3.Output.Totalrow)
  39320. //}
  39321. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  39322. var dat2 map[string]interface{}
  39323. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39324. fmt.Println(dat)
  39325. } else {
  39326. fmt.Println(err)
  39327. }
  39328. userJSONBytes2, _ := json.Marshal(dat2)
  39329. var res2 models.Result3260
  39330. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39331. utils.ErrorLog("解析失败:%v", err)
  39332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39333. return
  39334. }
  39335. if res2.Infcode == 0 {
  39336. res22 = append(res22, res2)
  39337. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39338. //var dat2 map[string]interface{}
  39339. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39340. // fmt.Println(dat)
  39341. //} else {
  39342. // fmt.Println(err)
  39343. //}
  39344. //c.ServeSuccessJSON(map[string]interface{}{
  39345. // "list": res2.Output.Data,
  39346. //})
  39347. //continue
  39348. }
  39349. }
  39350. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39351. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39352. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  39353. //var dat2 map[string]interface{}
  39354. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39355. // fmt.Println(dat)
  39356. //} else {
  39357. // fmt.Println(err)
  39358. //}
  39359. //userJSONBytes2, _ := json.Marshal(dat2)
  39360. //var res2 models.Result3260
  39361. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39362. // utils.ErrorLog("解析失败:%v", err)
  39363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39364. // return
  39365. //}
  39366. //if res2.Infcode == 0 {
  39367. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39368. // var dat2 map[string]interface{}
  39369. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39370. // fmt.Println(dat)
  39371. // } else {
  39372. // fmt.Println(err)
  39373. // }
  39374. // c.ServeSuccessJSON(map[string]interface{}{
  39375. // "list": res2.Output.Data,
  39376. // })
  39377. //}
  39378. }
  39379. func (c *HisApiController) ComfirmAllopatry() {
  39380. year := c.GetString("year")
  39381. month := c.GetString("month")
  39382. admin_user_id, _ := c.GetInt64("admin_user_id")
  39383. adminUser := c.GetAdminUserInfo()
  39384. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39385. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39386. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39387. var dat map[string]interface{}
  39388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39389. fmt.Println(dat)
  39390. } else {
  39391. fmt.Println(err)
  39392. }
  39393. userJSONBytes, _ := json.Marshal(dat)
  39394. var res models.Result9001
  39395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39396. utils.ErrorLog("解析失败:%v", err)
  39397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39398. return
  39399. }
  39400. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39401. var dat2 map[string]interface{}
  39402. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39403. fmt.Println(dat)
  39404. } else {
  39405. fmt.Println(err)
  39406. }
  39407. userJSONBytes2, _ := json.Marshal(dat2)
  39408. var res2 models.Result3260
  39409. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39410. utils.ErrorLog("解析失败:%v", err)
  39411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39412. return
  39413. }
  39414. //if res2.Infcode == 0 {
  39415. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39416. // var dat map[string]interface{}
  39417. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39418. // fmt.Println(dat)
  39419. // } else {
  39420. // fmt.Println(err)
  39421. // }
  39422. // userJSONBytes, _ := json.Marshal(dat)
  39423. // var res3 models.Result3261
  39424. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39425. // utils.ErrorLog("解析失败:%v", err)
  39426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39427. // return
  39428. // }
  39429. //
  39430. // if res3.Infcode == 0 {
  39431. // record := &models.HisYidiClearRecord{
  39432. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39433. // Ctime: time.Now().Unix(),
  39434. // Mtime: time.Now().Unix(),
  39435. // Status: 1,
  39436. // MsgId: msgId,
  39437. // }
  39438. // service.SaveClearRecord(record)
  39439. // c.ServeSuccessJSON(map[string]interface{}{
  39440. // "msg": "提取成功",
  39441. // })
  39442. // }
  39443. //}
  39444. }
  39445. func (c *HisApiController) RefundAllopatry() {
  39446. year := c.GetString("year")
  39447. month := c.GetString("month")
  39448. //id, _ := c.GetInt64("id")
  39449. admin_user_id, _ := c.GetInt64("admin_user_id")
  39450. adminUser := c.GetAdminUserInfo()
  39451. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39452. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39453. //record, _ := service.GetClearRecordById(id)
  39454. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39455. var dat map[string]interface{}
  39456. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39457. fmt.Println(dat)
  39458. } else {
  39459. fmt.Println(err)
  39460. }
  39461. userJSONBytes, _ := json.Marshal(dat)
  39462. var res models.Result9001
  39463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39464. utils.ErrorLog("解析失败:%v", err)
  39465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39466. return
  39467. }
  39468. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39469. var dat2 map[string]interface{}
  39470. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39471. fmt.Println(dat)
  39472. } else {
  39473. fmt.Println(err)
  39474. }
  39475. userJSONBytes2, _ := json.Marshal(dat2)
  39476. var empty ResultFourteen
  39477. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39478. utils.ErrorLog("解析失败:%v", err)
  39479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39480. return
  39481. }
  39482. if empty.Infcode == 0 {
  39483. c.ServeSuccessJSON(map[string]interface{}{
  39484. "msg": "撤销成功",
  39485. })
  39486. return
  39487. }
  39488. }
  39489. func (c *HisApiController) ReversalOtherData() {
  39490. var customData []*CustomData
  39491. custom := &CustomData{
  39492. MsgId: "H44022900158202103301714472004",
  39493. PsnNo: "44020000001101329945",
  39494. Info: "2208",
  39495. }
  39496. customData = append(customData, custom)
  39497. custom1 := &CustomData{
  39498. MsgId: "H4402290015820210330172057803",
  39499. PsnNo: "44020000001101161813",
  39500. Info: "2208",
  39501. }
  39502. customData = append(customData, custom1)
  39503. custom2 := &CustomData{
  39504. MsgId: "H44022900158202103301705198813",
  39505. PsnNo: "44190000133097375417",
  39506. Info: "2208",
  39507. }
  39508. customData = append(customData, custom2)
  39509. custom3 := &CustomData{
  39510. MsgId: "H44022900158202103301715524756",
  39511. PsnNo: "44020000001100187221",
  39512. Info: "2208",
  39513. }
  39514. customData = append(customData, custom3)
  39515. custom4 := &CustomData{
  39516. MsgId: "H44022900158202103301730376224",
  39517. PsnNo: "44020000001101959155",
  39518. Info: "2208",
  39519. }
  39520. customData = append(customData, custom4)
  39521. custom5 := &CustomData{
  39522. MsgId: "H44022900158202103301748008725",
  39523. PsnNo: "44020000001104246641",
  39524. Info: "2208",
  39525. }
  39526. customData = append(customData, custom5)
  39527. custom6 := &CustomData{
  39528. MsgId: "H44022900158202103301718096755",
  39529. PsnNo: "44020000001102211860",
  39530. Info: "2208",
  39531. }
  39532. customData = append(customData, custom6)
  39533. custom7 := &CustomData{
  39534. MsgId: "H44022900158202103301736551640",
  39535. PsnNo: "44020000001102687718",
  39536. Info: "2208",
  39537. }
  39538. customData = append(customData, custom7)
  39539. custom8 := &CustomData{
  39540. MsgId: "H44022900158202103301743097676",
  39541. PsnNo: "44020000001102127785",
  39542. Info: "2208",
  39543. }
  39544. customData = append(customData, custom8)
  39545. custom9 := &CustomData{
  39546. MsgId: "H44022900158202103301712304203",
  39547. PsnNo: "44020000001101518097",
  39548. Info: "2208",
  39549. }
  39550. customData = append(customData, custom9)
  39551. custom10 := &CustomData{
  39552. MsgId: "H44022900158202103301738448785",
  39553. PsnNo: "44020000001100500813",
  39554. Info: "2208",
  39555. }
  39556. customData = append(customData, custom10)
  39557. custom11 := &CustomData{
  39558. MsgId: "H44022900158202103301732455843",
  39559. PsnNo: "44020000001102690557",
  39560. Info: "2208",
  39561. }
  39562. customData = append(customData, custom11)
  39563. custom12 := &CustomData{
  39564. MsgId: "H44022900158202103301745421708",
  39565. PsnNo: "44020000001102211928",
  39566. Info: "2208",
  39567. }
  39568. customData = append(customData, custom12)
  39569. custom1212 := &CustomData{
  39570. MsgId: "H440229001582021033017351627",
  39571. PsnNo: "44020000001102481733",
  39572. Info: "2208",
  39573. }
  39574. customData = append(customData, custom1212)
  39575. custom13 := &CustomData{
  39576. MsgId: "H44022900158202103301740327951",
  39577. PsnNo: "44020000001103174866",
  39578. Info: "2208",
  39579. }
  39580. customData = append(customData, custom13)
  39581. custom14 := &CustomData{
  39582. MsgId: "H4402290015820210330174922668",
  39583. PsnNo: "44020000001102927272",
  39584. Info: "2208",
  39585. }
  39586. customData = append(customData, custom14)
  39587. custom15 := &CustomData{
  39588. MsgId: "H44022900158202103301752362273",
  39589. PsnNo: "44020000001102942890",
  39590. Info: "2208",
  39591. }
  39592. customData = append(customData, custom15)
  39593. custom16 := &CustomData{
  39594. MsgId: "H44022900158202103301751082917",
  39595. PsnNo: "44020000001101662162",
  39596. Info: "2208",
  39597. }
  39598. customData = append(customData, custom16)
  39599. custom17 := &CustomData{
  39600. MsgId: "H44022900158202103301754147728",
  39601. PsnNo: "44020000000229014511",
  39602. Info: "2208",
  39603. }
  39604. customData = append(customData, custom17)
  39605. adminUser := c.GetAdminUserInfo()
  39606. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39607. for _, item := range customData {
  39608. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39609. fmt.Println(result)
  39610. }
  39611. }
  39612. func PathExists(path string) (bool, error) {
  39613. _, err := os.Stat(path)
  39614. if err == nil {
  39615. return true, nil
  39616. }
  39617. if os.IsNotExist(err) {
  39618. return false, nil
  39619. }
  39620. return false, err
  39621. }
  39622. // 创建文件夹
  39623. func Mkdir(dir string) {
  39624. // 创建文件夹
  39625. exist, err := PathExists(dir)
  39626. if err != nil {
  39627. fmt.Println(err.Error())
  39628. } else {
  39629. if exist {
  39630. fmt.Println(dir + "文件夹已存在!")
  39631. } else {
  39632. // 文件夹名称,权限
  39633. err := os.Mkdir(dir, os.ModePerm)
  39634. if err != nil {
  39635. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39636. } else {
  39637. fmt.Println(dir + "文件夹创建成功!")
  39638. }
  39639. }
  39640. }
  39641. }
  39642. // 压缩文件
  39643. func Zip(srcFile string, destZip string) error {
  39644. zipfile, err := os.Create(destZip)
  39645. if err != nil {
  39646. return err
  39647. }
  39648. defer zipfile.Close()
  39649. archive := zip.NewWriter(zipfile)
  39650. defer archive.Close()
  39651. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39652. if err != nil {
  39653. return err
  39654. }
  39655. header, err := zip.FileInfoHeader(info)
  39656. if err != nil {
  39657. return err
  39658. }
  39659. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39660. // header.Name = path
  39661. if info.IsDir() {
  39662. header.Name += "/"
  39663. } else {
  39664. header.Method = zip.Deflate
  39665. }
  39666. writer, err := archive.CreateHeader(header)
  39667. if err != nil {
  39668. return err
  39669. }
  39670. if !info.IsDir() {
  39671. file, err := os.Open(path)
  39672. if err != nil {
  39673. return err
  39674. }
  39675. defer file.Close()
  39676. _, err = io.Copy(writer, file)
  39677. }
  39678. return err
  39679. })
  39680. return err
  39681. }
  39682. func ReadFile(filePath string) []byte {
  39683. f, err := os.Open(filePath)
  39684. if err != nil {
  39685. fmt.Println("read file fail", err)
  39686. return nil
  39687. }
  39688. defer f.Close()
  39689. fd, err := ioutil.ReadAll(f)
  39690. if err != nil {
  39691. fmt.Println("read to fd fail", err)
  39692. return nil
  39693. }
  39694. return fd
  39695. }
  39696. func saveLogq(result string, request string, infno string, desc string) {
  39697. dir := "日志"
  39698. utils.Mkdir(dir)
  39699. month := time.Unix(1557042972, 0).Format("1")
  39700. year := time.Now().Format("2006")
  39701. month = time.Now().Format("01")
  39702. day := time.Now().Format("02")
  39703. hour := time.Now().Format("15")
  39704. min := time.Now().Format("04")
  39705. sec := time.Now().Format("05")
  39706. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39707. file := year + month + day + "_log"
  39708. file_name := file + ".txt"
  39709. file_path := "日志" + "/" + file_name
  39710. exist, _ := utils.PathExists(file_path)
  39711. if exist { //存在
  39712. fmt.Println("存在")
  39713. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39714. if err != nil {
  39715. fmt.Println("read fail")
  39716. }
  39717. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39718. n, _ := f.Seek(0, 2)
  39719. _, err = f.WriteAt([]byte(content), n)
  39720. } else { //不存在
  39721. fmt.Println("文件不存在,创建文件")
  39722. f, err := os.Create("日志" + "/" + file_name)
  39723. defer f.Close()
  39724. if err != nil {
  39725. } else {
  39726. _, err = f.Write([]byte("记录日志"))
  39727. }
  39728. }
  39729. }
  39730. func saveLog(result string, request string, infno string, desc string) {
  39731. org_id, _ := beego.AppConfig.Int64("org_id")
  39732. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39733. dir := miConfig.OrgName + "日志"
  39734. utils.Mkdir(dir)
  39735. month := time.Unix(1557042972, 0).Format("1")
  39736. year := time.Now().Format("2006")
  39737. month = time.Now().Format("01")
  39738. day := time.Now().Format("02")
  39739. hour := time.Now().Format("15")
  39740. min := time.Now().Format("04")
  39741. sec := time.Now().Format("05")
  39742. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39743. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39744. file_name := file + ".txt"
  39745. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39746. exist, _ := utils.PathExists(file_path)
  39747. if exist { //存在
  39748. fmt.Println("存在")
  39749. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39750. if err != nil {
  39751. fmt.Println("read fail")
  39752. }
  39753. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39754. n, _ := f.Seek(0, 2)
  39755. _, err = f.WriteAt([]byte(content), n)
  39756. } else { //不存在
  39757. fmt.Println("文件不存在,创建文件")
  39758. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39759. defer f.Close()
  39760. if err != nil {
  39761. } else {
  39762. _, err = f.Write([]byte("记录日志"))
  39763. }
  39764. }
  39765. }
  39766. type Charset string
  39767. const (
  39768. UTF8 = Charset("UTF-8")
  39769. GB18030 = Charset("GB18030")
  39770. )
  39771. func ConvertToString(src string, srcCode string, tagCode string) string {
  39772. srcCoder := mahonia.NewDecoder(srcCode)
  39773. srcResult := srcCoder.ConvertString(src)
  39774. tagCoder := mahonia.NewDecoder(tagCode)
  39775. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39776. result := string(cdata)
  39777. return result
  39778. }
  39779. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39780. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39781. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39782. var token string
  39783. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39784. var api string
  39785. if miConfig.MdtrtareaAdmvs == "320830" {
  39786. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39787. "&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
  39788. fmt.Println(api)
  39789. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39790. 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 +
  39791. "&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
  39792. fmt.Println(api)
  39793. } else {
  39794. 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 +
  39795. "&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
  39796. }
  39797. resp, requestErr := http.Get(api)
  39798. if requestErr != nil {
  39799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39800. return ""
  39801. }
  39802. body, ioErr := ioutil.ReadAll(resp.Body)
  39803. if ioErr != nil {
  39804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39806. return ""
  39807. }
  39808. var respJSON map[string]interface{}
  39809. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39812. return ""
  39813. }
  39814. var status string
  39815. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39816. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39817. var res ResultTwo //1101结果
  39818. var res10265 ResultTwo10265 //1101结果
  39819. if status == "0" { //读卡成功
  39820. var card_info string //卡信息
  39821. var busi_card_info string
  39822. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39823. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39824. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39825. fmt.Println(card_info)
  39826. fmt.Println(busi_card_info)
  39827. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39828. result, _ := json.Marshal(respJSON)
  39829. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39830. utils.ErrorLog("解析失败:%v", err)
  39831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39832. return ""
  39833. }
  39834. res.ErrMsg = res10265.ErrMsg
  39835. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39836. res.Infcode = infocode
  39837. res.Output = res10265.Output
  39838. res.InfRefmsgid = res10265.InfRefmsgid
  39839. if res.Infcode == 0 {
  39840. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39841. if err == gorm.ErrRecordNotFound {
  39842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39843. return ""
  39844. } else if err != nil {
  39845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39846. return ""
  39847. } else {
  39848. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39849. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39850. infoStr := string(Iinfos)
  39851. idetinfoStr := string(Idetinfos)
  39852. psn := &models.HisPsn{
  39853. PsnNo: res.Output.Baseinfo.PsnNo,
  39854. PatientId: patient.ID,
  39855. Certno: res.Output.Baseinfo.Certno,
  39856. Gend: res.Output.Baseinfo.Gend,
  39857. Naty: res.Output.Baseinfo.Naty,
  39858. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39859. PsnName: res.Output.Baseinfo.PsnName,
  39860. Idetinfo: idetinfoStr,
  39861. Insuinfo: infoStr,
  39862. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39863. CardInfo: card_info,
  39864. VerifyNumber: token,
  39865. }
  39866. service.CreateHisPsn(psn)
  39867. return token
  39868. }
  39869. }
  39870. } else {
  39871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39872. return ""
  39873. }
  39874. } else { //读卡失败
  39875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39876. return ""
  39877. }
  39878. return token
  39879. }
  39880. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39881. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39882. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39883. var token string
  39884. var api string
  39885. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39886. "&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
  39887. fmt.Println(api)
  39888. resp, requestErr := http.Get(api)
  39889. if requestErr != nil {
  39890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39891. return ""
  39892. }
  39893. body, ioErr := ioutil.ReadAll(resp.Body)
  39894. if ioErr != nil {
  39895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39897. return ""
  39898. }
  39899. var respJSON map[string]interface{}
  39900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39903. return ""
  39904. }
  39905. var status string
  39906. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39907. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39908. var res ResultTwo //1101结果
  39909. if status == "1" { //读卡成功
  39910. var card_info string //卡信息
  39911. var busi_card_info string
  39912. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39913. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39914. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39915. fmt.Println(card_info)
  39916. fmt.Println(busi_card_info)
  39917. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39918. result, _ := json.Marshal(respJSON)
  39919. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39920. utils.ErrorLog("解析失败:%v", err)
  39921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39922. return ""
  39923. }
  39924. if res.Infcode == 0 {
  39925. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39926. if err == gorm.ErrRecordNotFound {
  39927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39928. return ""
  39929. } else if err != nil {
  39930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39931. return ""
  39932. } else {
  39933. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39934. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39935. infoStr := string(Iinfos)
  39936. idetinfoStr := string(Idetinfos)
  39937. psn := &models.HisPsn{
  39938. PsnNo: res.Output.Baseinfo.PsnNo,
  39939. PatientId: patient.ID,
  39940. Certno: res.Output.Baseinfo.Certno,
  39941. Gend: res.Output.Baseinfo.Gend,
  39942. Naty: res.Output.Baseinfo.Naty,
  39943. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39944. PsnName: res.Output.Baseinfo.PsnName,
  39945. Idetinfo: idetinfoStr,
  39946. Insuinfo: infoStr,
  39947. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39948. CardInfo: card_info,
  39949. VerifyNumber: token,
  39950. }
  39951. service.CreateHisPsn(psn)
  39952. return token
  39953. }
  39954. }
  39955. } else {
  39956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39957. return ""
  39958. }
  39959. return token
  39960. }
  39961. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39962. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39963. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39964. var token string
  39965. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39966. var api string
  39967. if miConfig.MdtrtareaAdmvs == "320830" {
  39968. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39969. "&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
  39970. fmt.Println(api)
  39971. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39972. 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 +
  39973. "&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
  39974. fmt.Println(api)
  39975. } else {
  39976. 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 +
  39977. "&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
  39978. }
  39979. resp, requestErr := http.Get(api)
  39980. if requestErr != nil {
  39981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39982. return ""
  39983. }
  39984. body, ioErr := ioutil.ReadAll(resp.Body)
  39985. if ioErr != nil {
  39986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39988. return ""
  39989. }
  39990. var respJSON map[string]interface{}
  39991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39994. return ""
  39995. }
  39996. var status string
  39997. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39998. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39999. var res ResultTwo //1101结果
  40000. var res10265 ResultTwo10265 //1101结果
  40001. if status == "0" { //读卡成功
  40002. var card_info string //卡信息
  40003. var busi_card_info string
  40004. token = respJSON["data"].(map[string]interface{})["token"].(string)
  40005. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  40006. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  40007. fmt.Println(card_info)
  40008. fmt.Println(busi_card_info)
  40009. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  40010. result, _ := json.Marshal(respJSON)
  40011. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  40012. utils.ErrorLog("解析失败:%v", err)
  40013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40014. return ""
  40015. }
  40016. res.ErrMsg = res10265.ErrMsg
  40017. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  40018. res.Infcode = infocode
  40019. res.Output = res10265.Output
  40020. res.InfRefmsgid = res10265.InfRefmsgid
  40021. if res.Infcode == 0 {
  40022. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  40023. if err == gorm.ErrRecordNotFound {
  40024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  40025. return ""
  40026. } else if err != nil {
  40027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  40028. return ""
  40029. } else {
  40030. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  40031. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  40032. infoStr := string(Iinfos)
  40033. idetinfoStr := string(Idetinfos)
  40034. psn := &models.HisPsn{
  40035. PsnNo: res.Output.Baseinfo.PsnNo,
  40036. PatientId: patient.ID,
  40037. Certno: res.Output.Baseinfo.Certno,
  40038. Gend: res.Output.Baseinfo.Gend,
  40039. Naty: res.Output.Baseinfo.Naty,
  40040. PsnCertType: res.Output.Baseinfo.PsnCertType,
  40041. PsnName: res.Output.Baseinfo.PsnName,
  40042. Idetinfo: idetinfoStr,
  40043. Insuinfo: infoStr,
  40044. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  40045. CardInfo: card_info,
  40046. VerifyNumber: token,
  40047. }
  40048. service.CreateHisPsn(psn)
  40049. return token
  40050. }
  40051. }
  40052. } else {
  40053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  40054. return ""
  40055. }
  40056. } else { //读卡失败
  40057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  40058. return ""
  40059. }
  40060. return token
  40061. }
  40062. func DeleteExtraSpaceTwo(s string) string {
  40063. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  40064. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  40065. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  40066. reg, _ := regexp.Compile(regstr) //编译正则表达式
  40067. s2 := make([]byte, len(s1)) //定义字符数组切片
  40068. copy(s2, s1) //将字符串复制到切片
  40069. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  40070. for len(spc_index) > 0 { //找到适配项
  40071. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  40072. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  40073. }
  40074. return string(s2)
  40075. }
  40076. func Remove0000(s string) string {
  40077. str := make([]rune, 0, len(s))
  40078. for _, v := range []rune(s) {
  40079. if v == 0 {
  40080. continue
  40081. }
  40082. str = append(str, v)
  40083. }
  40084. return string(str)
  40085. }
  40086. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  40087. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  40088. readCard := DllDef.MustFindProc("EcQuery")
  40089. pCardInfo := make([]byte, 8192)
  40090. pBusiCardInfo := make([]byte, 8192)
  40091. data := make(map[string]interface{})
  40092. //pData := make(map[string]interface{})
  40093. inputData := make(map[string]interface{})
  40094. inputData["orgId"] = code
  40095. inputData["businessType"] = "01101"
  40096. inputData["operatorId"] = operator_id
  40097. inputData["operatorName"] = operator_name
  40098. inputData["officeId"] = "001"
  40099. inputData["officeName"] = "血透室"
  40100. //
  40101. data["data"] = inputData
  40102. data["transType"] = "ec.query"
  40103. data["orgId"] = code
  40104. bytesData, _ := json.Marshal(data)
  40105. pCardInfo = bytesData
  40106. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  40107. fmt.Println(ret2)
  40108. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  40109. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  40110. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  40111. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  40112. if ret2 != 0 {
  40113. return "", ""
  40114. }
  40115. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  40116. }
  40117. func DeleteExtraSpace(s string) string {
  40118. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  40119. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  40120. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  40121. reg, _ := regexp.Compile(regstr) //编译正则表达式
  40122. s2 := make([]byte, len(s1)) //定义字符数组切片
  40123. copy(s2, s1) //将字符串复制到切片
  40124. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  40125. for len(spc_index) > 0 { //找到适配项
  40126. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  40127. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  40128. }
  40129. return string(s2)
  40130. }
  40131. // 对账
  40132. func (c *HisApiController) Post3202() {
  40133. start_time := c.GetString("start_time")
  40134. end_time := c.GetString("end_time")
  40135. //insutype := c.GetString("insutype")
  40136. clr_type := c.GetString("clr_type")
  40137. clr_org := c.GetString("clr_optins")
  40138. admin_user_id, _ := c.GetInt64("admin_user_id")
  40139. adminUser := c.GetAdminUserInfo()
  40140. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40141. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40142. if len(clr_org) == 0 {
  40143. clr_org = miConfig.MdtrtareaAdmvs
  40144. }
  40145. timeLayout := "2006-01-02"
  40146. loc, _ := time.LoadLocation("Local")
  40147. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40148. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40149. var orders []*models.HisOrder
  40150. if clr_org == "421300" {
  40151. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40152. } else if clr_org == "420902" {
  40153. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40154. } else {
  40155. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40156. }
  40157. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40158. //fixmedins_setl_cnt := int64(len(orders))
  40159. var medfee_sumamt float64
  40160. var acct_pay float64
  40161. var fund_pay_sumamt float64
  40162. for _, item := range orders {
  40163. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40164. acct_pay = acct_pay + item.AcctPay
  40165. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40166. }
  40167. //var medfee_sumamt_two float64
  40168. //var acct_pay_two float64
  40169. //var fund_pay_sumamt_two float64
  40170. //for _, item := range orders_two {
  40171. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40172. // acct_pay_two = acct_pay_two + item.AcctPay
  40173. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40174. //}
  40175. //var user_name string
  40176. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40177. //if role.ID == 0 {
  40178. // user_name = "xxx"
  40179. //} else {
  40180. // user_name = role.UserName
  40181. //}
  40182. var res ResultSix
  40183. if config.IsOpen == 1 {
  40184. var bps []*models.BusinessParamsTwo
  40185. var bp models.BusinessParamsTwo
  40186. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40187. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40188. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40189. bp.MedfeeSumamt = medfee_sumamt_str
  40190. bp.AcctPay = acct_pay_str
  40191. bp.FundPaySumamt = fund_pay_sumamt_str
  40192. bp.Insutype = ""
  40193. bp.StmtBegndate = start_time
  40194. bp.ClrType = clr_type
  40195. bp.SetlOptins = clr_org
  40196. bp.StmtEnddate = end_time
  40197. bps = append(bps, &bp)
  40198. data := make(map[string]interface{})
  40199. data["bps"] = bps
  40200. data["org_name"] = miConfig.OrgName
  40201. data["doctor"] = role.UserName
  40202. data["fixmedins_code"] = miConfig.Code
  40203. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40204. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40206. if miConfig.MdtrtareaAdmvs == "421300" {
  40207. client := &http.Client{}
  40208. bytesData, _ := json.Marshal(data)
  40209. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  40210. resp, _ := client.Do(req)
  40211. defer resp.Body.Close()
  40212. body, ioErr := ioutil.ReadAll(resp.Body)
  40213. if ioErr != nil {
  40214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40216. return
  40217. }
  40218. var respJSON map[string]interface{}
  40219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40222. return
  40223. }
  40224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40225. userJSONBytes, _ := json.Marshal(respJSON)
  40226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40227. utils.ErrorLog("解析失败:%v", err)
  40228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40229. return
  40230. }
  40231. }
  40232. if miConfig.MdtrtareaAdmvs == "420200" {
  40233. client := &http.Client{}
  40234. bytesData, _ := json.Marshal(data)
  40235. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  40236. resp, _ := client.Do(req)
  40237. defer resp.Body.Close()
  40238. body, ioErr := ioutil.ReadAll(resp.Body)
  40239. if ioErr != nil {
  40240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40242. return
  40243. }
  40244. var respJSON map[string]interface{}
  40245. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40248. return
  40249. }
  40250. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40251. userJSONBytes, _ := json.Marshal(respJSON)
  40252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40253. utils.ErrorLog("解析失败:%v", err)
  40254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40255. return
  40256. }
  40257. }
  40258. if miConfig.MdtrtareaAdmvs == "421182" {
  40259. client := &http.Client{}
  40260. bytesData, _ := json.Marshal(data)
  40261. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40262. resp, _ := client.Do(req)
  40263. defer resp.Body.Close()
  40264. body, ioErr := ioutil.ReadAll(resp.Body)
  40265. if ioErr != nil {
  40266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40268. return
  40269. }
  40270. var respJSON map[string]interface{}
  40271. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40274. return
  40275. }
  40276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40277. userJSONBytes, _ := json.Marshal(respJSON)
  40278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40279. utils.ErrorLog("解析失败:%v", err)
  40280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40281. return
  40282. }
  40283. }
  40284. if miConfig.MdtrtareaAdmvs == "420902" {
  40285. client := &http.Client{}
  40286. bytesData, _ := json.Marshal(data)
  40287. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40288. resp, _ := client.Do(req)
  40289. defer resp.Body.Close()
  40290. body, ioErr := ioutil.ReadAll(resp.Body)
  40291. if ioErr != nil {
  40292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40294. return
  40295. }
  40296. var respJSON map[string]interface{}
  40297. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40300. return
  40301. }
  40302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40303. userJSONBytes, _ := json.Marshal(respJSON)
  40304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40305. utils.ErrorLog("解析失败:%v", err)
  40306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40307. return
  40308. }
  40309. }
  40310. if res.Infcode == 0 {
  40311. c.ServeSuccessJSON(map[string]interface{}{
  40312. "msg": "发起成功",
  40313. })
  40314. } else {
  40315. c.ServeSuccessJSON(map[string]interface{}{
  40316. "failed_code": -10,
  40317. "msg": res.ErrMsg,
  40318. })
  40319. }
  40320. }
  40321. }
  40322. func (c *HisApiController) Post3204a() {
  40323. start_time := c.GetString("start_time")
  40324. end_time := c.GetString("end_time")
  40325. //insutype := c.GetString("insutype")
  40326. clr_type := c.GetString("clr_type")
  40327. clr_org := c.GetString("clr_optins")
  40328. admin_user_id, _ := c.GetInt64("admin_user_id")
  40329. adminUser := c.GetAdminUserInfo()
  40330. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40331. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40332. if len(clr_org) == 0 {
  40333. clr_org = miConfig.MdtrtareaAdmvs
  40334. }
  40335. timeLayout := "2006-01-02"
  40336. loc, _ := time.LoadLocation("Local")
  40337. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40338. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40339. var orders []*models.HisOrder
  40340. if clr_org == "421300" {
  40341. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40342. } else if clr_org == "420902" {
  40343. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40344. } else {
  40345. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40346. }
  40347. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40348. //fixmedins_setl_cnt := int64(len(orders))
  40349. var medfee_sumamt float64
  40350. var acct_pay float64
  40351. var fund_pay_sumamt float64
  40352. for _, item := range orders {
  40353. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40354. acct_pay = acct_pay + item.AcctPay
  40355. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40356. }
  40357. //var medfee_sumamt_two float64
  40358. //var acct_pay_two float64
  40359. //var fund_pay_sumamt_two float64
  40360. //for _, item := range orders_two {
  40361. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40362. // acct_pay_two = acct_pay_two + item.AcctPay
  40363. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40364. //}
  40365. //var user_name string
  40366. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40367. //if role.ID == 0 {
  40368. // user_name = "xxx"
  40369. //} else {
  40370. // user_name = role.UserName
  40371. //}
  40372. var res ResultSix
  40373. if config.IsOpen == 1 {
  40374. var bps []*models.BusinessParamsTwo
  40375. var bp models.BusinessParamsTwo
  40376. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40377. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40378. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40379. bp.MedfeeSumamt = medfee_sumamt_str
  40380. bp.AcctPay = acct_pay_str
  40381. bp.FundPaySumamt = fund_pay_sumamt_str
  40382. bp.Insutype = ""
  40383. bp.StmtBegndate = start_time
  40384. bp.ClrType = clr_type
  40385. bp.SetlOptins = clr_org
  40386. bp.StmtEnddate = end_time
  40387. bps = append(bps, &bp)
  40388. data := make(map[string]interface{})
  40389. data["bps"] = bps
  40390. data["org_name"] = miConfig.OrgName
  40391. data["doctor"] = role.UserName
  40392. data["fixmedins_code"] = miConfig.Code
  40393. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40394. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40395. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40396. if miConfig.MdtrtareaAdmvs == "421300" {
  40397. client := &http.Client{}
  40398. bytesData, _ := json.Marshal(data)
  40399. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40400. resp, _ := client.Do(req)
  40401. defer resp.Body.Close()
  40402. body, ioErr := ioutil.ReadAll(resp.Body)
  40403. if ioErr != nil {
  40404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40406. return
  40407. }
  40408. var respJSON map[string]interface{}
  40409. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40412. return
  40413. }
  40414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40415. userJSONBytes, _ := json.Marshal(respJSON)
  40416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40417. utils.ErrorLog("解析失败:%v", err)
  40418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40419. return
  40420. }
  40421. }
  40422. if miConfig.MdtrtareaAdmvs == "420200" {
  40423. client := &http.Client{}
  40424. bytesData, _ := json.Marshal(data)
  40425. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40426. resp, _ := client.Do(req)
  40427. defer resp.Body.Close()
  40428. body, ioErr := ioutil.ReadAll(resp.Body)
  40429. if ioErr != nil {
  40430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40432. return
  40433. }
  40434. var respJSON map[string]interface{}
  40435. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40438. return
  40439. }
  40440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40441. userJSONBytes, _ := json.Marshal(respJSON)
  40442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40443. utils.ErrorLog("解析失败:%v", err)
  40444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40445. return
  40446. }
  40447. }
  40448. if miConfig.MdtrtareaAdmvs == "421182" {
  40449. client := &http.Client{}
  40450. bytesData, _ := json.Marshal(data)
  40451. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40452. resp, _ := client.Do(req)
  40453. defer resp.Body.Close()
  40454. body, ioErr := ioutil.ReadAll(resp.Body)
  40455. if ioErr != nil {
  40456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40458. return
  40459. }
  40460. var respJSON map[string]interface{}
  40461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40464. return
  40465. }
  40466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40467. userJSONBytes, _ := json.Marshal(respJSON)
  40468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40469. utils.ErrorLog("解析失败:%v", err)
  40470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40471. return
  40472. }
  40473. }
  40474. if miConfig.MdtrtareaAdmvs == "420902" {
  40475. client := &http.Client{}
  40476. bytesData, _ := json.Marshal(data)
  40477. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40478. resp, _ := client.Do(req)
  40479. defer resp.Body.Close()
  40480. body, ioErr := ioutil.ReadAll(resp.Body)
  40481. if ioErr != nil {
  40482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40484. return
  40485. }
  40486. var respJSON map[string]interface{}
  40487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40490. return
  40491. }
  40492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40493. userJSONBytes, _ := json.Marshal(respJSON)
  40494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40495. utils.ErrorLog("解析失败:%v", err)
  40496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40497. return
  40498. }
  40499. }
  40500. if res.Infcode == 0 {
  40501. c.ServeSuccessJSON(map[string]interface{}{
  40502. "msg": "撤销成功",
  40503. })
  40504. } else {
  40505. c.ServeSuccessJSON(map[string]interface{}{
  40506. "failed_code": -10,
  40507. "msg": res.ErrMsg,
  40508. })
  40509. }
  40510. }
  40511. }
  40512. func (c *HisApiController) Post3204() {
  40513. admin_user_id, _ := c.GetInt64("admin_user_id")
  40514. id := c.GetString("id")
  40515. adminUser := c.GetAdminUserInfo()
  40516. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40517. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40518. //clr_org := miConfig.MdtrtareaAdmvs
  40519. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40520. var res ResultSix
  40521. if config.IsOpen == 1 {
  40522. data := make(map[string]interface{})
  40523. data["id"] = id
  40524. data["org_name"] = miConfig.OrgName
  40525. data["doctor"] = role.UserName
  40526. data["fixmedins_code"] = miConfig.Code
  40527. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40528. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40529. client := &http.Client{}
  40530. bytesData, _ := json.Marshal(data)
  40531. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40532. resp, _ := client.Do(req)
  40533. defer resp.Body.Close()
  40534. body, ioErr := ioutil.ReadAll(resp.Body)
  40535. if ioErr != nil {
  40536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40538. return
  40539. }
  40540. var respJSON map[string]interface{}
  40541. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40544. return
  40545. }
  40546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40547. userJSONBytes, _ := json.Marshal(respJSON)
  40548. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40549. utils.ErrorLog("解析失败:%v", err)
  40550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40551. return
  40552. }
  40553. if res.Infcode == 0 {
  40554. c.ServeSuccessJSON(map[string]interface{}{
  40555. "msg": "发起成功",
  40556. })
  40557. } else {
  40558. c.ServeSuccessJSON(map[string]interface{}{
  40559. "failed_code": -10,
  40560. "msg": res.ErrMsg,
  40561. })
  40562. }
  40563. }
  40564. }
  40565. func (c *HisApiController) Post8404() {
  40566. admin_user_id, _ := c.GetInt64("admin_user_id")
  40567. month := c.GetString("month")
  40568. adminUser := c.GetAdminUserInfo()
  40569. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40570. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40571. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40572. var res ResultSix
  40573. if config.IsOpen == 1 {
  40574. data := make(map[string]interface{})
  40575. data["month"] = month
  40576. data["org_name"] = miConfig.OrgName
  40577. data["doctor"] = role.UserName
  40578. data["fixmedins_code"] = miConfig.Code
  40579. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40580. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40581. client := &http.Client{}
  40582. bytesData, _ := json.Marshal(data)
  40583. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40584. resp, _ := client.Do(req)
  40585. defer resp.Body.Close()
  40586. body, ioErr := ioutil.ReadAll(resp.Body)
  40587. if ioErr != nil {
  40588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40590. return
  40591. }
  40592. var respJSON map[string]interface{}
  40593. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40596. return
  40597. }
  40598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40599. userJSONBytes, _ := json.Marshal(respJSON)
  40600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40601. utils.ErrorLog("解析失败:%v", err)
  40602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40603. return
  40604. }
  40605. if res.Infcode == 0 {
  40606. c.ServeSuccessJSON(map[string]interface{}{
  40607. "msg": "查询成功",
  40608. })
  40609. } else {
  40610. c.ServeSuccessJSON(map[string]interface{}{
  40611. "failed_code": -10,
  40612. "msg": res.ErrMsg,
  40613. })
  40614. }
  40615. }
  40616. }
  40617. func (c *HisApiController) Post3202b() {
  40618. start_time := c.GetString("start_time")
  40619. end_time := c.GetString("end_time")
  40620. //insutype := c.GetString("insutype")
  40621. clr_type := c.GetString("clr_type")
  40622. clr_org := c.GetString("clr_optins")
  40623. admin_user_id, _ := c.GetInt64("admin_user_id")
  40624. adminUser := c.GetAdminUserInfo()
  40625. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40626. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40627. if len(clr_org) == 0 {
  40628. clr_org = miConfig.MdtrtareaAdmvs
  40629. }
  40630. timeLayout := "2006-01-02"
  40631. loc, _ := time.LoadLocation("Local")
  40632. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40633. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40634. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40635. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40636. //fixmedins_setl_cnt := int64(len(orders))
  40637. var medfee_sumamt float64
  40638. var acct_pay float64
  40639. var fund_pay_sumamt float64
  40640. for _, item := range orders {
  40641. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40642. acct_pay = acct_pay + item.AcctPay
  40643. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40644. }
  40645. //var medfee_sumamt_two float64
  40646. //var acct_pay_two float64
  40647. //var fund_pay_sumamt_two float64
  40648. //for _, item := range orders_two {
  40649. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40650. // acct_pay_two = acct_pay_two + item.AcctPay
  40651. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40652. //}
  40653. //var user_name string
  40654. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40655. //if role.ID == 0 {
  40656. // user_name = "xxx"
  40657. //} else {
  40658. // user_name = role.UserName
  40659. //}
  40660. var res ResultSix
  40661. if config.IsOpen == 1 {
  40662. var bps []*models.BusinessParamsTwo
  40663. var bp models.BusinessParamsTwo
  40664. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40665. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40666. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40667. bp.MedfeeSumamt = medfee_sumamt_str
  40668. bp.AcctPay = acct_pay_str
  40669. bp.FundPaySumamt = fund_pay_sumamt_str
  40670. bp.Insutype = "390"
  40671. bp.StmtBegndate = start_time
  40672. bp.ClrType = clr_type
  40673. bp.SetlOptins = clr_org
  40674. bp.StmtEnddate = end_time
  40675. bps = append(bps, &bp)
  40676. data := make(map[string]interface{})
  40677. data["bps"] = bps
  40678. data["org_name"] = miConfig.OrgName
  40679. data["doctor"] = role.UserName
  40680. data["fixmedins_code"] = miConfig.Code
  40681. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40682. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40683. if miConfig.MdtrtareaAdmvs == "421300" {
  40684. client := &http.Client{}
  40685. bytesData, _ := json.Marshal(data)
  40686. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40687. resp, _ := client.Do(req)
  40688. defer resp.Body.Close()
  40689. body, ioErr := ioutil.ReadAll(resp.Body)
  40690. if ioErr != nil {
  40691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40693. return
  40694. }
  40695. var respJSON map[string]interface{}
  40696. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40699. return
  40700. }
  40701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40702. userJSONBytes, _ := json.Marshal(respJSON)
  40703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40704. utils.ErrorLog("解析失败:%v", err)
  40705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40706. return
  40707. }
  40708. }
  40709. if miConfig.MdtrtareaAdmvs == "420200" {
  40710. client := &http.Client{}
  40711. bytesData, _ := json.Marshal(data)
  40712. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40713. resp, _ := client.Do(req)
  40714. defer resp.Body.Close()
  40715. body, ioErr := ioutil.ReadAll(resp.Body)
  40716. if ioErr != nil {
  40717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40719. return
  40720. }
  40721. var respJSON map[string]interface{}
  40722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40725. return
  40726. }
  40727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40728. userJSONBytes, _ := json.Marshal(respJSON)
  40729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40730. utils.ErrorLog("解析失败:%v", err)
  40731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40732. return
  40733. }
  40734. }
  40735. if miConfig.MdtrtareaAdmvs == "421182" {
  40736. client := &http.Client{}
  40737. bytesData, _ := json.Marshal(data)
  40738. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40739. resp, _ := client.Do(req)
  40740. defer resp.Body.Close()
  40741. body, ioErr := ioutil.ReadAll(resp.Body)
  40742. if ioErr != nil {
  40743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40745. return
  40746. }
  40747. var respJSON map[string]interface{}
  40748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40751. return
  40752. }
  40753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40754. userJSONBytes, _ := json.Marshal(respJSON)
  40755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40756. utils.ErrorLog("解析失败:%v", err)
  40757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40758. return
  40759. }
  40760. }
  40761. if res.Infcode == 0 {
  40762. c.ServeSuccessJSON(map[string]interface{}{
  40763. "msg": "发起成功",
  40764. })
  40765. } else {
  40766. c.ServeSuccessJSON(map[string]interface{}{
  40767. "failed_code": -10,
  40768. "msg": res.ErrMsg,
  40769. })
  40770. }
  40771. }
  40772. }
  40773. func (c *HisApiController) Post1608() {
  40774. start_time := c.GetString("start_time")
  40775. end_time := c.GetString("end_time")
  40776. admin_user_id, _ := c.GetInt64("admin_user_id")
  40777. adminUser := c.GetAdminUserInfo()
  40778. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40779. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40780. timeLayout := "2006-01-02"
  40781. loc, _ := time.LoadLocation("Local")
  40782. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40783. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40784. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40785. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40786. fixmedins_setl_cnt := int64(len(orders))
  40787. var medfee_sumamt float64
  40788. var func_smamt float64
  40789. for _, item := range orders {
  40790. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40791. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40792. }
  40793. times := strings.Split(start_time, "-")
  40794. time_tows := strings.Split(end_time, "-")
  40795. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40796. var res ResultSix
  40797. if config.IsOpen == 1 {
  40798. //var bps []*models.BusinessParamsTwo
  40799. //var bp models.BusinessParamsTwo
  40800. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40801. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40802. data := make(map[string]interface{})
  40803. data["org_name"] = miConfig.OrgName
  40804. data["doctor"] = role.UserName
  40805. data["func_smamt"] = func_smamt_str
  40806. data["fixmedins_code"] = miConfig.Code
  40807. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40808. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40809. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40810. data["medfee_sumamt"] = medfee_sumamt_str
  40811. data["start_time"] = times[0] + times[1] + times[2]
  40812. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40813. if miConfig.MdtrtareaAdmvs == "421300" {
  40814. client := &http.Client{}
  40815. bytesData, _ := json.Marshal(data)
  40816. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40817. resp, _ := client.Do(req)
  40818. defer resp.Body.Close()
  40819. body, ioErr := ioutil.ReadAll(resp.Body)
  40820. if ioErr != nil {
  40821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40823. return
  40824. }
  40825. var respJSON map[string]interface{}
  40826. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40829. return
  40830. }
  40831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40832. userJSONBytes, _ := json.Marshal(respJSON)
  40833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40834. utils.ErrorLog("解析失败:%v", err)
  40835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40836. return
  40837. }
  40838. }
  40839. if miConfig.MdtrtareaAdmvs == "420200" {
  40840. client := &http.Client{}
  40841. bytesData, _ := json.Marshal(data)
  40842. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40843. resp, _ := client.Do(req)
  40844. defer resp.Body.Close()
  40845. body, ioErr := ioutil.ReadAll(resp.Body)
  40846. if ioErr != nil {
  40847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40849. return
  40850. }
  40851. var respJSON map[string]interface{}
  40852. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40855. return
  40856. }
  40857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40858. userJSONBytes, _ := json.Marshal(respJSON)
  40859. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40860. utils.ErrorLog("解析失败:%v", err)
  40861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40862. return
  40863. }
  40864. }
  40865. if miConfig.MdtrtareaAdmvs == "421182" {
  40866. client := &http.Client{}
  40867. bytesData, _ := json.Marshal(data)
  40868. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40869. resp, _ := client.Do(req)
  40870. defer resp.Body.Close()
  40871. body, ioErr := ioutil.ReadAll(resp.Body)
  40872. if ioErr != nil {
  40873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40875. return
  40876. }
  40877. var respJSON map[string]interface{}
  40878. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40881. return
  40882. }
  40883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40884. userJSONBytes, _ := json.Marshal(respJSON)
  40885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40886. utils.ErrorLog("解析失败:%v", err)
  40887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40888. return
  40889. }
  40890. }
  40891. if res.Infcode == 0 {
  40892. c.ServeSuccessJSON(map[string]interface{}{
  40893. "msg": "发起成功",
  40894. })
  40895. } else {
  40896. c.ServeSuccessJSON(map[string]interface{}{
  40897. "failed_code": -10,
  40898. "msg": res.ErrMsg,
  40899. })
  40900. }
  40901. }
  40902. }
  40903. // 5.11.1.1【5262】结算信息按时间段查询
  40904. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40905. admin_user_id, _ := c.GetInt64("admin_user_id")
  40906. adminUser := c.GetAdminUserInfo()
  40907. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40908. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40909. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40910. var res Result5262
  40911. if config.IsOpen == 1 {
  40912. if miConfig.MdtrtareaAdmvs == "421300" {
  40913. data := make(map[string]interface{})
  40914. data["bps"] = bp
  40915. data["org_name"] = miConfig.OrgName
  40916. data["doctor"] = role.UserName
  40917. data["fixmedins_code"] = miConfig.Code
  40918. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40919. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40920. data["page"] = strconv.FormatInt(page, 10)
  40921. data["limit"] = strconv.FormatInt(limit, 10)
  40922. fmt.Println(data)
  40923. client := &http.Client{}
  40924. bytesData, _ := json.Marshal(data)
  40925. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40926. resp, _ := client.Do(req)
  40927. defer resp.Body.Close()
  40928. body, ioErr := ioutil.ReadAll(resp.Body)
  40929. if ioErr != nil {
  40930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40932. return
  40933. }
  40934. var respJSON map[string]interface{}
  40935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40938. return
  40939. }
  40940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40941. userJSONBytes, _ := json.Marshal(respJSON)
  40942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40943. utils.ErrorLog("解析失败:%v", err)
  40944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40945. return
  40946. }
  40947. }
  40948. if miConfig.MdtrtareaAdmvs == "420200" {
  40949. data := make(map[string]interface{})
  40950. data["bps"] = bp
  40951. data["org_name"] = miConfig.OrgName
  40952. data["doctor"] = role.UserName
  40953. data["fixmedins_code"] = miConfig.Code
  40954. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40955. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40956. data["page"] = strconv.FormatInt(page, 10)
  40957. data["limit"] = strconv.FormatInt(limit, 10)
  40958. fmt.Println(data)
  40959. client := &http.Client{}
  40960. bytesData, _ := json.Marshal(data)
  40961. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40962. resp, _ := client.Do(req)
  40963. defer resp.Body.Close()
  40964. body, ioErr := ioutil.ReadAll(resp.Body)
  40965. if ioErr != nil {
  40966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40968. return
  40969. }
  40970. var respJSON map[string]interface{}
  40971. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40974. return
  40975. }
  40976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40977. userJSONBytes, _ := json.Marshal(respJSON)
  40978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40979. utils.ErrorLog("解析失败:%v", err)
  40980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40981. return
  40982. }
  40983. }
  40984. if miConfig.MdtrtareaAdmvs == "421182" {
  40985. data := make(map[string]interface{})
  40986. data["bps"] = bp
  40987. data["org_name"] = miConfig.OrgName
  40988. data["doctor"] = role.UserName
  40989. data["fixmedins_code"] = miConfig.Code
  40990. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40991. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40992. data["page"] = strconv.FormatInt(page, 10)
  40993. data["limit"] = strconv.FormatInt(limit, 10)
  40994. fmt.Println(data)
  40995. client := &http.Client{}
  40996. bytesData, _ := json.Marshal(data)
  40997. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40998. resp, _ := client.Do(req)
  40999. defer resp.Body.Close()
  41000. body, ioErr := ioutil.ReadAll(resp.Body)
  41001. if ioErr != nil {
  41002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41004. return
  41005. }
  41006. var respJSON map[string]interface{}
  41007. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41010. return
  41011. }
  41012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41013. userJSONBytes, _ := json.Marshal(respJSON)
  41014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41015. utils.ErrorLog("解析失败:%v", err)
  41016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41017. return
  41018. }
  41019. }
  41020. if miConfig.MdtrtareaAdmvs == "420902" {
  41021. data := make(map[string]interface{})
  41022. data["bps"] = bp
  41023. data["org_name"] = miConfig.OrgName
  41024. data["doctor"] = role.UserName
  41025. data["fixmedins_code"] = miConfig.Code
  41026. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41027. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41028. data["page"] = strconv.FormatInt(page, 10)
  41029. data["limit"] = strconv.FormatInt(limit, 10)
  41030. fmt.Println(data)
  41031. client := &http.Client{}
  41032. bytesData, _ := json.Marshal(data)
  41033. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  41034. resp, _ := client.Do(req)
  41035. defer resp.Body.Close()
  41036. body, ioErr := ioutil.ReadAll(resp.Body)
  41037. if ioErr != nil {
  41038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41040. return
  41041. }
  41042. var respJSON map[string]interface{}
  41043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41046. return
  41047. }
  41048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41049. userJSONBytes, _ := json.Marshal(respJSON)
  41050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41051. utils.ErrorLog("解析失败:%v", err)
  41052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41053. return
  41054. }
  41055. }
  41056. if res.Infcode == 0 {
  41057. c.ServeSuccessJSON(map[string]interface{}{
  41058. "order": res.Output.Result,
  41059. "total": res.Output.PageInfo.RecordCounts,
  41060. })
  41061. } else {
  41062. c.ServeSuccessJSON(map[string]interface{}{
  41063. "failed_code": -10,
  41064. "msg": res.ErrMsg,
  41065. })
  41066. }
  41067. }
  41068. }
  41069. // 5.11.1.2【5267】异地结算信息时间段查询
  41070. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  41071. admin_user_id, _ := c.GetInt64("admin_user_id")
  41072. adminUser := c.GetAdminUserInfo()
  41073. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  41074. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  41075. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  41076. var res Result5267
  41077. if config.IsOpen == 1 {
  41078. if miConfig.MdtrtareaAdmvs == "421300" {
  41079. data := make(map[string]interface{})
  41080. data["bps"] = bp
  41081. data["org_name"] = miConfig.OrgName
  41082. data["doctor"] = role.UserName
  41083. data["fixmedins_code"] = miConfig.Code
  41084. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41085. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41086. data["page"] = page
  41087. data["limit"] = limit
  41088. fmt.Println(data)
  41089. client := &http.Client{}
  41090. bytesData, _ := json.Marshal(data)
  41091. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  41092. resp, _ := client.Do(req)
  41093. defer resp.Body.Close()
  41094. body, ioErr := ioutil.ReadAll(resp.Body)
  41095. if ioErr != nil {
  41096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41098. return
  41099. }
  41100. var respJSON map[string]interface{}
  41101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41104. return
  41105. }
  41106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41107. userJSONBytes, _ := json.Marshal(respJSON)
  41108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41109. utils.ErrorLog("解析失败:%v", err)
  41110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41111. return
  41112. }
  41113. }
  41114. if miConfig.MdtrtareaAdmvs == "420200" {
  41115. data := make(map[string]interface{})
  41116. data["bps"] = bp
  41117. data["org_name"] = miConfig.OrgName
  41118. data["doctor"] = role.UserName
  41119. data["fixmedins_code"] = miConfig.Code
  41120. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41121. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41122. data["page"] = page
  41123. data["limit"] = limit
  41124. fmt.Println(data)
  41125. client := &http.Client{}
  41126. bytesData, _ := json.Marshal(data)
  41127. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  41128. resp, _ := client.Do(req)
  41129. defer resp.Body.Close()
  41130. body, ioErr := ioutil.ReadAll(resp.Body)
  41131. if ioErr != nil {
  41132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41134. return
  41135. }
  41136. var respJSON map[string]interface{}
  41137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41140. return
  41141. }
  41142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41143. userJSONBytes, _ := json.Marshal(respJSON)
  41144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41145. utils.ErrorLog("解析失败:%v", err)
  41146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41147. return
  41148. }
  41149. }
  41150. if miConfig.MdtrtareaAdmvs == "421182" {
  41151. data := make(map[string]interface{})
  41152. data["bps"] = bp
  41153. data["org_name"] = miConfig.OrgName
  41154. data["doctor"] = role.UserName
  41155. data["fixmedins_code"] = miConfig.Code
  41156. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41157. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41158. data["page"] = page
  41159. data["limit"] = limit
  41160. fmt.Println(data)
  41161. client := &http.Client{}
  41162. bytesData, _ := json.Marshal(data)
  41163. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  41164. resp, _ := client.Do(req)
  41165. defer resp.Body.Close()
  41166. body, ioErr := ioutil.ReadAll(resp.Body)
  41167. if ioErr != nil {
  41168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41170. return
  41171. }
  41172. var respJSON map[string]interface{}
  41173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41176. return
  41177. }
  41178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41179. userJSONBytes, _ := json.Marshal(respJSON)
  41180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41181. utils.ErrorLog("解析失败:%v", err)
  41182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41183. return
  41184. }
  41185. }
  41186. if res.Infcode == 0 {
  41187. c.ServeSuccessJSON(map[string]interface{}{
  41188. "order": res.Output.Result,
  41189. "total": res.Output.PageInfo.RecordCounts,
  41190. })
  41191. } else {
  41192. c.ServeSuccessJSON(map[string]interface{}{
  41193. "failed_code": -10,
  41194. "msg": res.ErrMsg,
  41195. })
  41196. }
  41197. }
  41198. }
  41199. func (c *HisApiController) Post3501() {
  41200. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41201. data := make(map[string]interface{})
  41202. var struct3501s []models.Struct3501
  41203. var struct3501 models.Struct3501
  41204. struct3501.OrgName = miConfig.OrgName
  41205. struct3501.AccessKey = miConfig.AccessKey
  41206. struct3501.RequestUrl = miConfig.Url
  41207. struct3501.SecretKey = miConfig.SecretKey
  41208. struct3501.ManuDate = "2022-08-17"
  41209. struct3501.FixmedinsBchno = ""
  41210. struct3501.ManuLotnum = ""
  41211. struct3501.RxFlag = "0"
  41212. struct3501.ExpyEnd = "2022-08-17"
  41213. struct3501.Invdate = "2022-08-17"
  41214. struct3501.InvCnt = "20.25"
  41215. struct3501.Memo = ""
  41216. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41217. struct3501.FixmedinsHilistId = miConfig.Code
  41218. struct3501.FixmedinsHilistName = miConfig.OrgName
  41219. struct3501s = append(struct3501s, struct3501)
  41220. data["struct_3501s"] = struct3501s
  41221. client := &http.Client{}
  41222. bytesData, _ := json.Marshal(data)
  41223. var req *http.Request
  41224. if miConfig.MdtrtareaAdmvs == "320830" {
  41225. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41226. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41227. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41228. } else {
  41229. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41230. }
  41231. resp, _ := client.Do(req)
  41232. defer resp.Body.Close()
  41233. body, ioErr := ioutil.ReadAll(resp.Body)
  41234. if ioErr != nil {
  41235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41237. return
  41238. }
  41239. var respJSON map[string]interface{}
  41240. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41243. return
  41244. }
  41245. var res ResultSix
  41246. var resSix10265 ResultSix10265 //1101结果
  41247. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41248. result, _ := json.Marshal(respJSON)
  41249. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41250. utils.ErrorLog("解析失败:%v", err)
  41251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41252. return
  41253. }
  41254. res.InfRefmsgid = resSix10265.InfRefmsgid
  41255. res.Output = resSix10265.Output
  41256. res.ErrMsg = resSix10265.ErrMsg
  41257. res.Cainfo = resSix10265.Cainfo
  41258. res.WarnMsg = resSix10265.WarnMsg
  41259. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41260. res.Infcode = infocode
  41261. if infocode == 0 {
  41262. c.ServeSuccessJSON(map[string]interface{}{
  41263. "msg": "上传成功",
  41264. })
  41265. return
  41266. } else {
  41267. c.ServeSuccessJSON(map[string]interface{}{
  41268. "failed_code": -10,
  41269. "msg": res.ErrMsg,
  41270. })
  41271. return
  41272. }
  41273. }
  41274. func (c *HisApiController) Post3502() {
  41275. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41276. data := make(map[string]interface{})
  41277. var struct3502s []models.Struct3502
  41278. var struct3502 models.Struct3502
  41279. struct3502.OrgName = miConfig.OrgName
  41280. struct3502.AccessKey = miConfig.AccessKey
  41281. struct3502.RequestUrl = miConfig.Url
  41282. struct3502.SecretKey = miConfig.SecretKey
  41283. struct3502.ManuDate = "2022-08-15"
  41284. struct3502.FixmedinsBchno = ""
  41285. struct3502.ManuLotnum = ""
  41286. struct3502.RxFlag = "0"
  41287. struct3502.ExpyEnd = "2022-08-15"
  41288. struct3502.Invdate = "2022-08-15"
  41289. struct3502.InvCnt = "20.25"
  41290. struct3502.Memo = ""
  41291. struct3502.MedListCodg = "XB01ABD056B002020200517"
  41292. struct3502.FixmedinsHilistId = miConfig.Code
  41293. struct3502.FixmedinsHilistName = miConfig.OrgName
  41294. struct3502s = append(struct3502s, struct3502)
  41295. data["struct_3502s"] = struct3502s
  41296. client := &http.Client{}
  41297. bytesData, _ := json.Marshal(data)
  41298. var req *http.Request
  41299. if miConfig.MdtrtareaAdmvs == "320830" {
  41300. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41301. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41302. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41303. } else {
  41304. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41305. }
  41306. resp, _ := client.Do(req)
  41307. defer resp.Body.Close()
  41308. body, ioErr := ioutil.ReadAll(resp.Body)
  41309. if ioErr != nil {
  41310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41312. return
  41313. }
  41314. var respJSON map[string]interface{}
  41315. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41318. return
  41319. }
  41320. var res ResultSix
  41321. var resSix10265 ResultSix10265 //1101结果
  41322. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41323. result, _ := json.Marshal(respJSON)
  41324. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41325. utils.ErrorLog("解析失败:%v", err)
  41326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41327. return
  41328. }
  41329. res.InfRefmsgid = resSix10265.InfRefmsgid
  41330. res.Output = resSix10265.Output
  41331. res.ErrMsg = resSix10265.ErrMsg
  41332. res.Cainfo = resSix10265.Cainfo
  41333. res.WarnMsg = resSix10265.WarnMsg
  41334. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41335. res.Infcode = infocode
  41336. if infocode == 0 {
  41337. c.ServeSuccessJSON(map[string]interface{}{
  41338. "msg": "上传成功",
  41339. })
  41340. return
  41341. } else {
  41342. c.ServeSuccessJSON(map[string]interface{}{
  41343. "failed_code": -10,
  41344. "msg": res.ErrMsg,
  41345. })
  41346. return
  41347. }
  41348. }
  41349. func (c *HisApiController) Post3503() {
  41350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41351. data := make(map[string]interface{})
  41352. var struct3501s []models.Struct3501
  41353. var struct3501 models.Struct3501
  41354. struct3501.OrgName = miConfig.OrgName
  41355. struct3501.AccessKey = miConfig.AccessKey
  41356. struct3501.RequestUrl = miConfig.Url
  41357. struct3501.SecretKey = miConfig.SecretKey
  41358. struct3501.ManuDate = "2022-08-15"
  41359. struct3501.FixmedinsBchno = ""
  41360. struct3501.ManuLotnum = ""
  41361. struct3501.RxFlag = "0"
  41362. struct3501.ExpyEnd = "2022-08-15"
  41363. struct3501.Invdate = "2022-08-15"
  41364. struct3501.InvCnt = "20.25"
  41365. struct3501.Memo = ""
  41366. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41367. struct3501.FixmedinsHilistId = miConfig.Code
  41368. struct3501.FixmedinsHilistName = miConfig.OrgName
  41369. struct3501s = append(struct3501s, struct3501)
  41370. data["struct_3501s"] = struct3501s
  41371. client := &http.Client{}
  41372. bytesData, _ := json.Marshal(data)
  41373. var req *http.Request
  41374. if miConfig.MdtrtareaAdmvs == "320921" {
  41375. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41376. } else {
  41377. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41378. }
  41379. resp, _ := client.Do(req)
  41380. defer resp.Body.Close()
  41381. body, ioErr := ioutil.ReadAll(resp.Body)
  41382. if ioErr != nil {
  41383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41385. return
  41386. }
  41387. var respJSON map[string]interface{}
  41388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41391. return
  41392. }
  41393. var res ResultSix
  41394. var resSix10265 ResultSix10265 //1101结果
  41395. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41396. result, _ := json.Marshal(respJSON)
  41397. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41398. utils.ErrorLog("解析失败:%v", err)
  41399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41400. return
  41401. }
  41402. res.InfRefmsgid = resSix10265.InfRefmsgid
  41403. res.Output = resSix10265.Output
  41404. res.ErrMsg = resSix10265.ErrMsg
  41405. res.Cainfo = resSix10265.Cainfo
  41406. res.WarnMsg = resSix10265.WarnMsg
  41407. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41408. res.Infcode = infocode
  41409. if infocode == 0 {
  41410. c.ServeSuccessJSON(map[string]interface{}{
  41411. "msg": "上传成功",
  41412. })
  41413. return
  41414. } else {
  41415. c.ServeSuccessJSON(map[string]interface{}{
  41416. "failed_code": -10,
  41417. "msg": res.ErrMsg,
  41418. })
  41419. return
  41420. }
  41421. }
  41422. func (c *HisApiController) Post3504() {
  41423. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41424. data := make(map[string]interface{})
  41425. var struct3501s []models.Struct3501
  41426. var struct3501 models.Struct3501
  41427. struct3501.OrgName = miConfig.OrgName
  41428. struct3501.AccessKey = miConfig.AccessKey
  41429. struct3501.RequestUrl = miConfig.Url
  41430. struct3501.SecretKey = miConfig.SecretKey
  41431. struct3501.ManuDate = "2022-08-15"
  41432. struct3501.FixmedinsBchno = ""
  41433. struct3501.ManuLotnum = ""
  41434. struct3501.RxFlag = "0"
  41435. struct3501.ExpyEnd = "2022-08-15"
  41436. struct3501.Invdate = "2022-08-15"
  41437. struct3501.InvCnt = "20.25"
  41438. struct3501.Memo = ""
  41439. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41440. struct3501.FixmedinsHilistId = miConfig.Code
  41441. struct3501.FixmedinsHilistName = miConfig.OrgName
  41442. struct3501s = append(struct3501s, struct3501)
  41443. data["struct_3501s"] = struct3501s
  41444. client := &http.Client{}
  41445. bytesData, _ := json.Marshal(data)
  41446. var req *http.Request
  41447. if miConfig.MdtrtareaAdmvs == "320921" {
  41448. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41449. } else {
  41450. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41451. }
  41452. resp, _ := client.Do(req)
  41453. defer resp.Body.Close()
  41454. body, ioErr := ioutil.ReadAll(resp.Body)
  41455. if ioErr != nil {
  41456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41458. return
  41459. }
  41460. var respJSON map[string]interface{}
  41461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41464. return
  41465. }
  41466. var res ResultSix
  41467. var resSix10265 ResultSix10265 //1101结果
  41468. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41469. result, _ := json.Marshal(respJSON)
  41470. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41471. utils.ErrorLog("解析失败:%v", err)
  41472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41473. return
  41474. }
  41475. res.InfRefmsgid = resSix10265.InfRefmsgid
  41476. res.Output = resSix10265.Output
  41477. res.ErrMsg = resSix10265.ErrMsg
  41478. res.Cainfo = resSix10265.Cainfo
  41479. res.WarnMsg = resSix10265.WarnMsg
  41480. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41481. res.Infcode = infocode
  41482. if infocode == 0 {
  41483. c.ServeSuccessJSON(map[string]interface{}{
  41484. "msg": "上传成功",
  41485. })
  41486. return
  41487. } else {
  41488. c.ServeSuccessJSON(map[string]interface{}{
  41489. "failed_code": -10,
  41490. "msg": res.ErrMsg,
  41491. })
  41492. return
  41493. }
  41494. }
  41495. func (c *HisApiController) Post3505() {
  41496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41497. data := make(map[string]interface{})
  41498. var struct3501s []models.Struct3501
  41499. var struct3501 models.Struct3501
  41500. struct3501.OrgName = miConfig.OrgName
  41501. struct3501.AccessKey = miConfig.AccessKey
  41502. struct3501.RequestUrl = miConfig.Url
  41503. struct3501.SecretKey = miConfig.SecretKey
  41504. struct3501.ManuDate = "2022-08-15"
  41505. struct3501.FixmedinsBchno = ""
  41506. struct3501.ManuLotnum = ""
  41507. struct3501.RxFlag = "0"
  41508. struct3501.ExpyEnd = "2022-08-15"
  41509. struct3501.Invdate = "2022-08-15"
  41510. struct3501.InvCnt = "20.25"
  41511. struct3501.Memo = ""
  41512. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41513. struct3501.FixmedinsHilistId = miConfig.Code
  41514. struct3501.FixmedinsHilistName = miConfig.OrgName
  41515. struct3501s = append(struct3501s, struct3501)
  41516. data["struct_3501s"] = struct3501s
  41517. client := &http.Client{}
  41518. bytesData, _ := json.Marshal(data)
  41519. var req *http.Request
  41520. if miConfig.MdtrtareaAdmvs == "320921" {
  41521. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41522. } else {
  41523. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41524. }
  41525. resp, _ := client.Do(req)
  41526. defer resp.Body.Close()
  41527. body, ioErr := ioutil.ReadAll(resp.Body)
  41528. if ioErr != nil {
  41529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41531. return
  41532. }
  41533. var respJSON map[string]interface{}
  41534. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41537. return
  41538. }
  41539. var res ResultSix
  41540. var resSix10265 ResultSix10265 //1101结果
  41541. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41542. result, _ := json.Marshal(respJSON)
  41543. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41544. utils.ErrorLog("解析失败:%v", err)
  41545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41546. return
  41547. }
  41548. res.InfRefmsgid = resSix10265.InfRefmsgid
  41549. res.Output = resSix10265.Output
  41550. res.ErrMsg = resSix10265.ErrMsg
  41551. res.Cainfo = resSix10265.Cainfo
  41552. res.WarnMsg = resSix10265.WarnMsg
  41553. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41554. res.Infcode = infocode
  41555. if infocode == 0 {
  41556. c.ServeSuccessJSON(map[string]interface{}{
  41557. "msg": "上传成功",
  41558. })
  41559. return
  41560. } else {
  41561. c.ServeSuccessJSON(map[string]interface{}{
  41562. "failed_code": -10,
  41563. "msg": res.ErrMsg,
  41564. })
  41565. return
  41566. }
  41567. }
  41568. func (c *HisApiController) Post3506() {
  41569. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41570. data := make(map[string]interface{})
  41571. var struct3501s []models.Struct3501
  41572. var struct3501 models.Struct3501
  41573. struct3501.OrgName = miConfig.OrgName
  41574. struct3501.AccessKey = miConfig.AccessKey
  41575. struct3501.RequestUrl = miConfig.Url
  41576. struct3501.SecretKey = miConfig.SecretKey
  41577. struct3501.ManuDate = "2022-08-15"
  41578. struct3501.FixmedinsBchno = ""
  41579. struct3501.ManuLotnum = ""
  41580. struct3501.RxFlag = "0"
  41581. struct3501.ExpyEnd = "2022-08-15"
  41582. struct3501.Invdate = "2022-08-15"
  41583. struct3501.InvCnt = "20.25"
  41584. struct3501.Memo = ""
  41585. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41586. struct3501.FixmedinsHilistId = miConfig.Code
  41587. struct3501.FixmedinsHilistName = miConfig.OrgName
  41588. struct3501s = append(struct3501s, struct3501)
  41589. data["struct_3501s"] = struct3501s
  41590. client := &http.Client{}
  41591. bytesData, _ := json.Marshal(data)
  41592. var req *http.Request
  41593. if miConfig.MdtrtareaAdmvs == "320921" {
  41594. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41595. } else {
  41596. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41597. }
  41598. resp, _ := client.Do(req)
  41599. defer resp.Body.Close()
  41600. body, ioErr := ioutil.ReadAll(resp.Body)
  41601. if ioErr != nil {
  41602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41604. return
  41605. }
  41606. var respJSON map[string]interface{}
  41607. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41610. return
  41611. }
  41612. var res ResultSix
  41613. var resSix10265 ResultSix10265 //1101结果
  41614. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41615. result, _ := json.Marshal(respJSON)
  41616. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41617. utils.ErrorLog("解析失败:%v", err)
  41618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41619. return
  41620. }
  41621. res.InfRefmsgid = resSix10265.InfRefmsgid
  41622. res.Output = resSix10265.Output
  41623. res.ErrMsg = resSix10265.ErrMsg
  41624. res.Cainfo = resSix10265.Cainfo
  41625. res.WarnMsg = resSix10265.WarnMsg
  41626. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41627. res.Infcode = infocode
  41628. if infocode == 0 {
  41629. c.ServeSuccessJSON(map[string]interface{}{
  41630. "msg": "上传成功",
  41631. })
  41632. return
  41633. } else {
  41634. c.ServeSuccessJSON(map[string]interface{}{
  41635. "failed_code": -10,
  41636. "msg": res.ErrMsg,
  41637. })
  41638. return
  41639. }
  41640. }
  41641. func (c *HisApiController) Post3507() {
  41642. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41643. data := make(map[string]interface{})
  41644. var struct3501s []models.Struct3501
  41645. var struct3501 models.Struct3501
  41646. struct3501.OrgName = miConfig.OrgName
  41647. struct3501.AccessKey = miConfig.AccessKey
  41648. struct3501.RequestUrl = miConfig.Url
  41649. struct3501.SecretKey = miConfig.SecretKey
  41650. struct3501.ManuDate = "2022-08-15"
  41651. struct3501.FixmedinsBchno = ""
  41652. struct3501.ManuLotnum = ""
  41653. struct3501.RxFlag = "0"
  41654. struct3501.ExpyEnd = "2022-08-15"
  41655. struct3501.Invdate = "2022-08-15"
  41656. struct3501.InvCnt = "20.25"
  41657. struct3501.Memo = ""
  41658. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41659. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41660. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41661. struct3501s = append(struct3501s, struct3501)
  41662. data["struct_3501s"] = struct3501s
  41663. client := &http.Client{}
  41664. bytesData, _ := json.Marshal(data)
  41665. var req *http.Request
  41666. if miConfig.MdtrtareaAdmvs == "320921" {
  41667. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41668. } else {
  41669. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41670. }
  41671. resp, _ := client.Do(req)
  41672. defer resp.Body.Close()
  41673. body, ioErr := ioutil.ReadAll(resp.Body)
  41674. if ioErr != nil {
  41675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41677. return
  41678. }
  41679. var respJSON map[string]interface{}
  41680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41683. return
  41684. }
  41685. var res ResultSix
  41686. var resSix10265 ResultSix10265 //1101结果
  41687. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41688. result, _ := json.Marshal(respJSON)
  41689. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41690. utils.ErrorLog("解析失败:%v", err)
  41691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41692. return
  41693. }
  41694. res.InfRefmsgid = resSix10265.InfRefmsgid
  41695. res.Output = resSix10265.Output
  41696. res.ErrMsg = resSix10265.ErrMsg
  41697. res.Cainfo = resSix10265.Cainfo
  41698. res.WarnMsg = resSix10265.WarnMsg
  41699. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41700. res.Infcode = infocode
  41701. if infocode == 0 {
  41702. c.ServeSuccessJSON(map[string]interface{}{
  41703. "msg": "上传成功",
  41704. })
  41705. return
  41706. } else {
  41707. c.ServeSuccessJSON(map[string]interface{}{
  41708. "failed_code": -10,
  41709. "msg": res.ErrMsg,
  41710. })
  41711. return
  41712. }
  41713. }
  41714. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41715. // WebSocket服务器地址
  41716. serverURL := "ws://127.0.0.1:8899"
  41717. // 解析WebSocket服务器地址
  41718. u, err := url.Parse(serverURL)
  41719. if err != nil {
  41720. }
  41721. // 建立WebSocket连接
  41722. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41723. if err != nil {
  41724. }
  41725. defer conn.Close()
  41726. input2 := make(map[string]interface{})
  41727. input := make(map[string]interface{})
  41728. inputData := make(map[string]interface{})
  41729. inputData["orgId"] = code
  41730. inputData["businessType"] = "01101"
  41731. inputData["operatorId"] = operator_id
  41732. inputData["operatorName"] = operator_name
  41733. inputData["officeId"] = "001"
  41734. inputData["officeName"] = "血透室"
  41735. inputData["deviceType"] = ""
  41736. input["data"] = inputData
  41737. input["orgId"] = code
  41738. input["transType"] = "ec.query"
  41739. //if md == ""
  41740. if md[:4] == "4403" {
  41741. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41742. } else if md[:4] == "4401" {
  41743. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41744. } else {
  41745. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41746. }
  41747. input2["indata"] = input
  41748. fmt.Println(input2)
  41749. bytesData, _ := json.Marshal(input2)
  41750. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41751. if err != nil {
  41752. fmt.Println(err)
  41753. }
  41754. // 接收消息
  41755. _, receivedMessage, err := conn.ReadMessage()
  41756. if err != nil {
  41757. fmt.Println(err)
  41758. }
  41759. return "", string(receivedMessage)
  41760. }
  41761. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41762. // WebSocket服务器地址
  41763. serverURL := "ws://127.0.0.1:8899"
  41764. // 解析WebSocket服务器地址
  41765. u, err := url.Parse(serverURL)
  41766. if err != nil {
  41767. }
  41768. // 建立WebSocket连接
  41769. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41770. if err != nil {
  41771. }
  41772. defer conn.Close()
  41773. input2 := make(map[string]interface{})
  41774. input := make(map[string]interface{})
  41775. inputData := make(map[string]interface{})
  41776. inputData["orgId"] = code
  41777. inputData["businessType"] = "01101"
  41778. inputData["operatorId"] = operator_id
  41779. inputData["operatorName"] = operator_name
  41780. inputData["officeId"] = "001"
  41781. inputData["officeName"] = "血透室"
  41782. inputData["deviceType"] = ""
  41783. input["data"] = inputData
  41784. input["orgId"] = code
  41785. input["transType"] = "ec.query"
  41786. //if md == ""
  41787. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41788. input2["indata"] = input
  41789. fmt.Println(input2)
  41790. bytesData, _ := json.Marshal(input2)
  41791. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41792. if err != nil {
  41793. fmt.Println(err)
  41794. }
  41795. // 接收消息
  41796. _, receivedMessage, err := conn.ReadMessage()
  41797. if err != nil {
  41798. fmt.Println(err)
  41799. }
  41800. return "", string(receivedMessage)
  41801. }
  41802. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41803. // WebSocket服务器地址
  41804. serverURL := "ws://127.0.0.1:8899"
  41805. // 解析WebSocket服务器地址
  41806. u, err := url.Parse(serverURL)
  41807. if err != nil {
  41808. }
  41809. // 建立WebSocket连接
  41810. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41811. if err != nil {
  41812. }
  41813. defer conn.Close()
  41814. input2 := make(map[string]interface{})
  41815. input := make(map[string]interface{})
  41816. inputData := make(map[string]interface{})
  41817. inputData["orgId"] = code
  41818. inputData["businessType"] = "01301"
  41819. inputData["operatorId"] = operator_id
  41820. inputData["operatorName"] = operator_name
  41821. inputData["officeId"] = "001"
  41822. inputData["officeName"] = "血透室"
  41823. inputData["deviceType"] = ""
  41824. input["data"] = inputData
  41825. input["orgId"] = code
  41826. input["transType"] = "ec.query"
  41827. //if md == ""
  41828. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41829. input2["indata"] = input
  41830. fmt.Println(input2)
  41831. bytesData, _ := json.Marshal(input2)
  41832. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41833. if err != nil {
  41834. fmt.Println(err)
  41835. }
  41836. // 接收消息
  41837. _, receivedMessage, err := conn.ReadMessage()
  41838. if err != nil {
  41839. fmt.Println(err)
  41840. }
  41841. return "", string(receivedMessage)
  41842. }
  41843. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41844. // WebSocket服务器地址
  41845. serverURL := "ws://127.0.0.1:8899"
  41846. // 解析WebSocket服务器地址
  41847. u, err := url.Parse(serverURL)
  41848. if err != nil {
  41849. }
  41850. // 建立WebSocket连接
  41851. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41852. if err != nil {
  41853. }
  41854. defer conn.Close()
  41855. input2 := make(map[string]interface{})
  41856. input := make(map[string]interface{})
  41857. inputData := make(map[string]interface{})
  41858. inputData["orgId"] = code
  41859. inputData["businessType"] = "01103"
  41860. inputData["operatorId"] = operator_id
  41861. inputData["operatorName"] = operator_name
  41862. inputData["officeId"] = "001"
  41863. inputData["officeName"] = "血透室"
  41864. inputData["deviceType"] = ""
  41865. input["data"] = inputData
  41866. input["orgId"] = code
  41867. input["transType"] = "ec.query"
  41868. //if md ==
  41869. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41870. input2["indata"] = input
  41871. fmt.Println(input2)
  41872. bytesData, _ := json.Marshal(input2)
  41873. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41874. if err != nil {
  41875. fmt.Println(err)
  41876. }
  41877. // 接收消息
  41878. _, receivedMessage, err := conn.ReadMessage()
  41879. if err != nil {
  41880. fmt.Println(err)
  41881. }
  41882. return "", string(receivedMessage)
  41883. }
  41884. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41885. // WebSocket服务器地址
  41886. serverURL := "ws://127.0.0.1:8899"
  41887. // 解析WebSocket服务器地址
  41888. u, err := url.Parse(serverURL)
  41889. if err != nil {
  41890. }
  41891. // 建立WebSocket连接
  41892. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41893. if err != nil {
  41894. }
  41895. defer conn.Close()
  41896. input2 := make(map[string]interface{})
  41897. input := make(map[string]interface{})
  41898. inputData := make(map[string]interface{})
  41899. inputData["orgId"] = code
  41900. inputData["businessType"] = "01101"
  41901. inputData["operatorId"] = operator_id
  41902. inputData["operatorName"] = operator_name
  41903. inputData["officeId"] = "001"
  41904. inputData["officeName"] = "血透室"
  41905. inputData["deviceType"] = ""
  41906. input["data"] = inputData
  41907. input["orgId"] = code
  41908. input["transType"] = "ec.query"
  41909. //if md == ""
  41910. if md[:4] == "4403" {
  41911. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41912. } else if md[:4] == "4401" {
  41913. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41914. } else {
  41915. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41916. }
  41917. input2["indata"] = input
  41918. fmt.Println(input2)
  41919. bytesData, _ := json.Marshal(input2)
  41920. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41921. if err != nil {
  41922. fmt.Println(err)
  41923. }
  41924. // 接收消息
  41925. _, receivedMessage, err := conn.ReadMessage()
  41926. if err != nil {
  41927. fmt.Println(err)
  41928. }
  41929. return "", string(receivedMessage)
  41930. }
  41931. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41932. // WebSocket服务器地址
  41933. serverURL := "ws://127.0.0.1:8899"
  41934. // 解析WebSocket服务器地址
  41935. u, err := url.Parse(serverURL)
  41936. if err != nil {
  41937. }
  41938. // 建立WebSocket连接
  41939. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41940. if err != nil {
  41941. }
  41942. defer conn.Close()
  41943. input2 := make(map[string]interface{})
  41944. input := make(map[string]interface{})
  41945. inputData := make(map[string]interface{})
  41946. inputData["orgId"] = code
  41947. inputData["businessType"] = "01301"
  41948. inputData["operatorId"] = operator_id
  41949. inputData["operatorName"] = operator_name
  41950. inputData["officeId"] = "001"
  41951. inputData["officeName"] = "血透室"
  41952. inputData["deviceType"] = ""
  41953. input["data"] = inputData
  41954. input["orgId"] = code
  41955. input["transType"] = "ec.query"
  41956. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41957. input2["indata"] = input
  41958. bytesData, _ := json.Marshal(input2)
  41959. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41960. if err != nil {
  41961. fmt.Println(err)
  41962. }
  41963. // 接收消息
  41964. _, receivedMessage, err := conn.ReadMessage()
  41965. if err != nil {
  41966. fmt.Println(err)
  41967. }
  41968. return "", string(receivedMessage)
  41969. }
  41970. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41971. newArr = make([]string, 0)
  41972. for i := 0; i < len(arr); i++ {
  41973. repeat := false
  41974. for j := i + 1; j < len(arr); j++ {
  41975. if arr[i] == arr[j] {
  41976. repeat = true
  41977. break
  41978. }
  41979. }
  41980. if !repeat {
  41981. newArr = append(newArr, arr[i])
  41982. }
  41983. }
  41984. return
  41985. }
  41986. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41987. if len(idNumber) != 18 {
  41988. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41989. }
  41990. // 提取出生日期
  41991. year, err := strconv.Atoi(idNumber[6:10])
  41992. if err != nil {
  41993. return "", 0, err
  41994. }
  41995. month, err := strconv.Atoi(idNumber[10:12])
  41996. if err != nil {
  41997. return "", 0, err
  41998. }
  41999. day, err := strconv.Atoi(idNumber[12:14])
  42000. if err != nil {
  42001. return "", 0, err
  42002. }
  42003. // 格式化生日字符串
  42004. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  42005. birthdateFormatted := birthdate.Format("2006-01-02")
  42006. // 计算年龄
  42007. today := time.Now()
  42008. age := today.Year() - birthdate.Year()
  42009. if today.YearDay() < birthdate.YearDay() {
  42010. age--
  42011. }
  42012. return birthdateFormatted, age, nil
  42013. }
  42014. // 从身份证号码中提取出生年月日
  42015. func getBirthDateFromIDCard(idCard string) (string, error) {
  42016. // 身份证号码长度应为18位
  42017. if len(idCard) != 18 {
  42018. return "", fmt.Errorf("身份证号码长度应为18位")
  42019. }
  42020. // 提取出生日期部分 (YYYYMMDD)
  42021. birthDateStr := idCard[6:14]
  42022. // 解析出生日期
  42023. birthDate, err := time.Parse("20060102", birthDateStr)
  42024. if err != nil {
  42025. return "", fmt.Errorf("解析出生日期失败: %v", err)
  42026. }
  42027. // 格式化出生日期为 YYYY-MM-DD
  42028. formattedDate := birthDate.Format("2006-01-02")
  42029. return formattedDate, nil
  42030. }